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.
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:
Download the scripts.
http://www.zhuzhaoyuan.com/download/dstat/cpu.sh
http://www.zhuzhaoyuan.com/download/dstat/memory.sh
Arbow said,
March 17, 2009 @ 11:01 pm
great! I love it
Tank said,
March 18, 2009 @ 12:17 am
可以去了解下Windows Management Instrumentation,你也许看到过MOM(http://www.microsoft.com/systemcenter/operationsmanager/)的广告,吹得牛逼得不得了,建议去玩玩,给咱普及普及。
一个Linuxer可以憎恨m$,但不得不学m$的产品技术