Dstat, an Excellent Replacement for Vmstat

For a long time, I was not satisfied with vmstat, because it does not generate timestamps. Then I came across a cool program named Dstat yesterday, which can be an excellent replacement for vmstat.

A screenshot of Dstat

A screenshot of Dstat

By using Dstat, now not only all my needs can be met but also it is pretty easy to do resource usage analysis and graphing.

As the author described, “Dstat is a versatile replacement for vmstat, iostat, netstat, nfsstat and ifstat. Dstat overcomes some of their limitations and adds some extra features, more counters and flexibility. Dstat is handy for monitoring systems during performance tuning tests, benchmarks or troubleshooting.” So why use three or more tools when one tool can give you everything you need?

Here is an example showing how to use it.

First, capture the resource usage information (CPU and memory) to a file, e.g. stat.dat:

$ dstat -tcmn > stat.dat

Then use the scripts below to create CPU and memory usage graphs:

#!/usr/bin/gnuplot
 
set terminal png
set output "cpu.png"
set title "CPU usage"
set xlabel "time"
set ylabel "percent"
set xdata time
set timefmt "%d-%m %H:%M:%S"
set format x "%H:%M"
plot "stat.dat" using 1:4 title "system" with lines, \
"stat.dat" using 1:3 title "user" with lines, \
"stat.dat" using 1:5 title "idle" with lines
#!/usr/bin/gnuplot
 
set terminal png
set output "memory.png"
set title "memory usage"
set xlabel "time"
set ylabel "size(M Bytes)"
set xdata time
set timefmt "%d-%m %H:%M:%S"
set format x "%H:%M"
plot "stat.dat" using 1:9 title "used" with lines, \
"stat.dat" using 1:10 title "buff" with lines, \
"stat.dat" using 1:11 title "cach" with lines, \
"stat.dat" using 1:12 title "free" with lines

Resource usage graph examples:
cpu

memory

Download the scripts.
http://www.zhuzhaoyuan.com/download/dstat/cpu.sh
http://www.zhuzhaoyuan.com/download/dstat/memory.sh

2 Comments »

  1. Arbow said,

    March 17, 2009 @ 11:01 pm

    great! I love it

  2. Tank said,

    March 18, 2009 @ 12:17 am

    可以去了解下Windows Management Instrumentation,你也许看到过MOM(http://www.microsoft.com/systemcenter/operationsmanager/)的广告,吹得牛逼得不得了,建议去玩玩,给咱普及普及。
    一个Linuxer可以憎恨m$,但不得不学m$的产品技术

::...
免责声明:
当前网页内容, 由 大妈 ZoomQuiet 使用工具: ScrapBook :: Firefox Extension 人工从互联网中收集并分享;
内容版权归原作者所有;
本人对内容的有效性/合法性不承担任何强制性责任.
若有不妥, 欢迎评注提醒:

或是邮件反馈可也:
askdama[AT]googlegroups.com


订阅 substack 体验古早写作:


点击注册~> 获得 100$ 体验券: DigitalOcean Referral Badge

关注公众号, 持续获得相关各种嗯哼:
zoomquiet


自怼圈/年度番新

DU22.4
关于 ~ DebugUself with DAMA ;-)
粤ICP备18025058号-1
公安备案号: 44049002000656 ...::