LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 704|回复: 1

sar + gnuplot 进行性能分析?

[复制链接]
发表于 2006-3-17 20:37:05 | 显示全部楼层 |阅读模式
上次去参加 RHCE day 活动时,介绍了一种结合 sar 和 gnuplot 进行性能分析的方法,具体的方法无从得知,只能凭借简陋的笔记和推断,大致如下的一种思路吧:
# sar -r 5 100 >meminfo.dat
# head -n -1 meminfo.out \
| sed -n '4,$p' \
| awk '{$1=""; print $0}' >meminfo.dat
# gnuplot
> plot '/tmp/meminfo.dat' using 3 with lines title '%mem'

这时可以得到一个图形显示出来,但 sar 的结果是多列的,如果想同时显示多列的图形化结果应该怎么办呢,比如第 8 列,%swap。我使用如下方法是不行的:
> plot '/tmp/meminfo.dat' using 3 with lines title '%mem', 8 with lines title '%swap'

另外,用 sar 分别统计 memory, CPU 等得到若干数据文件,怎样将这些文件的结果叠加显示在同一个图形中?我想这样通过对比能够比较直观的找出系统的瓶颈。

谢谢
 楼主| 发表于 2006-3-17 20:46:35 | 显示全部楼层
参考了一下 gnuplot 的 demo,用如下办法解决了:
plot '/tmp/cpuinfo.dat' using 3 with lines title '%cpu.user', \
> '/tmp/cpuinfo.dat' using 6 with lines title '%cpu.iowait', \   
> '/tmp/cpuinfo.dat' using 5 with lines title '%cpu.system', \   
> '/tmp/meminfo.dat' using 3 with lines title '%mem', \
> '/tmp/meminfo.dat' using 8 with lines title '%swap'
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表