首页 > 学院 > 操作系统 > 正文

统计和分析系统性能【IO CPU 内存】的工具集合

2024-06-28 13:19:17
字体:
来源:转载
供稿:网友
统计和分析系统性能【IO CPU 内存】的工具集合

统计和分析系统性能【IO CPU 内存】的工具集合

blktrace

http://www.oschina.net/p/blktrace

获取磁盘写入的信息

root@demo:~/install/percona-toolkit-2.2.1# debugfs -R 'stats' /dev/sda1

debugfs 1.41.11 (14-Mar-2010)

debugfs -R 'stats' /dev/sda1|grep Block

debugfs 1.41.11 (14-Mar-2010)

Block count: 5012992

Block size: 4096

Blocks per group: 32768

Mount -t debugfs none /sys/kernel/debug

dd if=/dev/zero of=/root/a.s bs=1024 count=1000

./blktrace -d /dev/sda -o - | ./blkparse -i -

8,0 0 1070 71.884893141 6075 M W 575360 + 8 [dd]

8,0 0 1071 71.884894103 6075 A W 575368 + 8 <- (8,1) 573320

8,0 0 1072 71.884894272 6075 Q W 575368 + 8 [dd]

8,0 0 1073 71.884894481 6075 M W 575368 + 8 [dd]

8,0 0 1074 71.884895481 6075 A W 575376 + 8 <- (8,1) 573328

8,0 0 1075 71.884895621 6075 Q W 575376 + 8 [dd]

8,0 0 1076 71.884895830 6075 M W 575376 + 8 [dd]

root@demo:~/install/blktrace# debugfs -R "icheck `echo 573320/8|bc`" /dev/sda1

debugfs 1.41.11 (14-Mar-2010)

Block Inode number

71665 937613

root@demo:~/install/blktrace#

root@demo:~/install/blktrace# debugfs -R "ncheck 937613" /dev/sda1

debugfs 1.41.11 (14-Mar-2010)

Inode Pathname

937613 /root/a.s

此时通过lsof可以查到是谁在写/root/a.s

iotop

http://www.oschina.net/p/iotop

./iotop.py -p ##

这个工具是python脚本

wps99A7.tmp

和top的使用有些类似

strace ltrace

http://sourceforge.net/PRojects/strace/

http://ltrace.alioth.debian.org/

统计、跟踪程序使用库函数、系统函数

Ø 执行跟踪执行某个文件

n strace prog

n ltrace prog

Ø 已经执行的文件跟踪

n strace -p pid

n ltrace -p pid

n 这种情况有pthread的程序,附加会出现问题SIG_TRAP

Percona toolkit

https://www.percona.com/downloads/percona-toolkit/

http://blog.chinaunix.net/uid-20639775-id-3206802.html percona-toolkit工具包的使用教程之开发工具类使用 http://blog.chinaunix.net/uid-20639775-id-3207926.html percona-toolkit工具包的使用教程之性能类工具 http://blog.chinaunix.net/uid-20639775-id-3210834.html percona-toolkit工具包的使用教程之配置类工具 http://blog.chinaunix.net/uid-20639775-id-3210843.html percona-toolkit工具包的使用教程之监控类工具使用 http://blog.chinaunix.net/uid-20639775-id-3215742.html percona-toolkit工具包的使用教程之复制类工具 http://blog.chinaunix.net/uid-20639775-id-3229211.html percona-toolkit工具包的使用教程之系统类工具 http://blog.chinaunix.net/uid-20639775-id-3236839.html percona-toolkit工具包的使用教程之实用类工具 http://blog.chinaunix.net/uid-20639775-id-3236864.html

Ø pt-diskstats

An interactive I/O monitoring tool for GNU/linux.

Ø pt-ioprofile

Watch process IO and print a table of file and I/O activity.

pt-ioprofile --profile-pid=### --cell=sizes

Ø pt-summary

Summarize system information nicely.

sysstat

http://pagesperso-orange.fr/sebastien.godard/

./iostat -x 2

Report Central Processing Unit (CPU) statistics and input/output

statistics for devices and partitions.

#CPU

# ?秒 ?次

./pidstat -u 2 &> cpu.txt &

#内存

./pidstat -r 10 &> mem.txt &

#磁盘

./pidstat -d 2 &> io.txt &

#

./iostat -x 2 &> iostat.txt &

#

./mpstat -P ALL 2 &> mpstat.txt &

#

sudo mkdir /var/log/sa -p

sudo chmod 777 /var/log/sa

sudo cp sad* /sbin/.

./sar -u 2 &> sacpu.txt &

./sar -b 2 &> saio.txt &

#创建的线程数

#./sar -c 2 &> sathread.txt &

#进程队列和平均负载统计信息

./sar -q 2 &> saproc.txt &

#内存和交换空间

./sar -r 10 &> samem.txt &

如上的例子就是采样信息写入到文件中

top/htop

http://sourceforge.net/projects/htop/

htop 是一个 Linux 下的交互式的进程浏览器,可以用来替换Linux下的top命令。

内存

Linux系统没运行多少程序,显示的可用内存这么少?其实Linux与Win的内存管理不同,会尽量缓存内存以提高读写性能,通常叫做Cache Memory

http://www.ha97.com/4337.html

http://blog.csdn.net/heizistudio/article/details/25125061 这个文章讲解的更详细


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表