Friday, August 29, 2008

monitor the system totally with dstat

You must have ever monitored the system with different tools:
  1. "vmstat 2" to get a total system "proc,mem,swap,io,sys,cpu" load;
  2. "iostat 2" to get all block devices with seperated I/O bandwidth data;
  3. "ifstat 2" to get different network interfaces network activity;
  4. "top" to get the most CPU-consuming processes;
Now you can do all these things within dstat:
gektop@tux ~ 0 $ dstat -M proc,cpu,mem,sys,page,net,disk,topcpu,topmem,topio,topbio 5
---procs--- ----total-cpu-usage---- ------memory-usage----- ---system-- ---paging-- -net/total- -dsk/total- -most-expensive- -most-expensive- ----most-expensive---- ----most-expensive----
run blk new|usr sys idl wai hiq siq| used buff cach free| int csw | in out | recv send| read writ| cpu process | memory process | i/o process | block i/o process
0 0 6| 39 9 37 14 0 1| 272M 25M 193M 12M| 760 2178 | 0 21B| 0 0 |5577k 1645k|firefox 10|firefox 125M|mount.ntfs- 10M:8223k|mount.ntfs-2699k: 736k
3 0 8| 93 6 0 0 0 1| 252M 25M 189M 37M| 546 980 | 0 0 |3197B 564B| 109k 675k|firefox 15|firefox 125M|mount.ntfs- 771k:3056B|pdflush 0 : 82k
3 0 71| 77 16 0 7 0 1| 257M 26M 191M 29M| 548 1247 | 0 0 |5445B 689B| 230k 544k|firefox 13|firefox 125M|mount.ntfs- 771k:3056B|pdflush 0 : 94k
2 0 24| 85 14 0 1 0 0| 251M 26M 192M 33M| 550 1046 | 0 0 |1173B 418B| 50k 344k|firefox 12|firefox 125M|mount.ntfs- 771k:3056B|pdflush 0 : 85k
2 0 25| 85 12 0 2 0 0| 275M 26M 194M 8044k| 517 1024 | 0 0 |1206B 448B| 104k 642k|cc1 22|firefox 125M|mount.ntfs- 771k:3056B|pdflush 0 : 47k
2 0 9| 88 9 0 2 0 1| 278M 26M 193M 5568k| 558 1056 | 0 0 |1383B 615B| 110k 451k|cc1 26|firefox 125M|mount.ntfs- 771k:3056B|pdflush 0 : 51k
The meanings of "proc,cpu,mem,sys,page,net,disk,topcpu,topmem,topio,topbio" is obvious, it speaks for itself, the design of dstat is all modular, you can use many other modules than this:
$ (cd /usr/share/dstat/; ls *.py)
dstat_battery.py dstat_gpfs.py dstat_mysql5_com.py dstat_mysql_keys.py dstat_postfix.py dstat_thermal.py dstat_topoom.py dstat_vzcpu.py
dstat_cpufreq.py dstat_helloworld.py dstat_mysql5_conn.py dstat_nfs3op.py dstat.py dstat_topbio.py dstat_utmp.py dstat_vzubc.py
dstat_dbus.py dstat_innodb_buffer.py dstat_mysql5_io.py dstat_nfs3.py dstat_rpcd.py dstat_topcpu.py dstat_vmkhba.py dstat_wifi.py
dstat_freespace.py dstat_innodb_io.py dstat_mysql5_keys.py dstat_nfsd3op.py dstat_rpc.py dstat_topio.py dstat_vmkint.py
dstat_gpfsop.py dstat_innodb_ops.py dstat_mysql_io.py dstat_nfsd3.py dstat_sendmail.py dstat_topmem.py dstat_vmknic.py
So with "dstat -M battery 5", you can get the most battery consuming components when hardware supports ACPI.

Its module is just a simple py file with a simple class derived from dstat, so if there's no one fit for you, you can write your own dstat module.

Note: only CLI-based utils discussed here, I know there are many GUI-based or graph-generating tools can do better graphics, but on ther server side, "
Simple is better than complex.
"

No comments: