There are a number of common command line tools that we can use to monitor system resources. We have df for disk space, free for RAM usage, top for processes, bmon for network usage, etc. Quite often though, I find it useful to monitor them all simultaneously, and constantly switching commands or using ‘watch’ with free/df is annoying.
I came across dstat recently that gives a nice colorful overview of a choice of statistics. Here are some useful command line options from the man page:
-c [Show CPU stats]
-d [Show disk stats]
-l [Show load stats]
-m [Show memory stats]
-n [Show network stats]
-s [Show swap stats]
-t [Show time stats]
-y [Show system stats]
-a [All stats (-cdngy1)
-C[0,1,2,3,4,5,6,7,total] [Show individual CPU usage]
You can also output to CSV with –csv and disable color with –nocolor.
I usually use dstat as follows:
(If this looks like a complete mess in your browser just copy and paste it into your favorite text editor with line wrap turned off)
apnic03:~# dstat -d -l -m -n -s -c -C total,0
-dsk/total- —load-avg— ——memory-usage—– -net/total- —-swap— —-total-cpu-usage————cpu0-usage——
_read _writ|_1m_ _5m_ 15m_|_used _buff _cach _free|_recv _send|_used _free|usr sys idl wai hiq siq:usr sys idl wai hiq siq
199k 337k| 3.2 2.4 1.8| 547M 37M 7242M 287M| 0 0 | 36k 3812M| 1 7 90 3 0 0: 1 11 74 13 0 0
24k 672k| 3.2 2.4 1.8| 547M 37M 7242M 287M|4549B 50k| 36k 3812M| 1 6 89 4 0 0: 1 19 48 31 0 1
16k 0 | 3.2 2.4 1.8| 547M 37M 7242M 287M|3361B 19k| 36k 3812M| 1 3 97 0 0 0: 2 5 92 1 0 0
8192B 816k| 3 2.4 1.8| 547M 37M 7242M 287M|4801B 22k| 36k 3812M| 0 10 85 4 0 0: 1 8 55 36 0 0
8192B 328k| 3 2.4 1.8| 547M 37M 7242M 287M|4779B 18k| 36k 3812M| 0 6 91 3 0 0: 0 4 71 25 0 0
48k 456k| 3 2.4 1.8| 547M 37M 7242M 286M| 9.9k 46k| 36k 3812M| 1 7 89 3 0 0: 1 18 59 22 0 0
24k 980k| 3 2.4 1.8| 547M 37M 7242M 286M| 11k 113k| 36k 3812M| 0 4 89 7 0 0: 1 9 34 56 0 0
20k 8192B| 3 2.4 1.8| 547M 37M 7243M 286M|2636B 6404B| 36k 3812M| 1 3 95 1 0 0: 2 9 86 3 0 0
4096B 760k| 2.8 2.4 1.8| 547M 37M 7243M 286M|3973B 7628B| 36k 3812M| 0 3 89 7 0 0: 1 11 33 54 1 0
8192B 696k| 2.8 2.4 1.8| 547M 37M 7243M 286M|5876B 8419B| 36k 3812M| 0 3 92 5 0 0: 1 8 55 36 0 0
Now I’ll use the same, but change -C to monitor CPU 8:
apnic03:~# dstat -d -l -m -n -s -c -C total,7
-dsk/total- —load-avg— ——memory-usage—– -net/total- —-swap— —-total-cpu-usage————cpu7-usage——
_read _writ|_1m_ _5m_ 15m_|_used _buff _cach _free|_recv _send|_used _free|usr sys idl wai hiq siq:usr sys idl wai hiq siq
199k 337k| 2.7 2.4 1.8| 546M 38M 7248M 282M| 0 0 | 36k 3812M| 1 7 90 3 0 0: 0 5 93 1 0 0
8192B 380k| 2.7 2.4 1.8| 547M 38M 7248M 282M| 12k 24k| 36k 3812M| 0 4 91 4 0 0: 1 4 95 0 0 0
48k 0 | 2.7 2.4 1.8| 546M 38M 7248M 282M| 10k 36k| 36k 3812M| 1 7 92 0 0 0: 0 4 96 0 0 0
80k 764k| 2.6 2.4 1.8| 546M 38M 7248M 281M| 12k 180k| 36k 3812M| 1 4 93 3 0 0: 1 3 96 0 0 0
32k 800k| 2.6 2.4 1.8| 546M 38M 7248M 281M| 21k 111k| 36k 3812M| 0 4 92 4 0 0: 0 2 92 6 0 0
As we can see CPU1 is more heavily loaded than CPU8 in general. I can now optimize my VMs to put more pressure on CPU8 and take some off CPU1.
Hope you find this helpful!
Tags: bandwidth usage, bmon, df, disk space, dstat, free, io statistics, linux benchmark, linux statistics, monitor, network usage, process, processes, RAM usage, system statistics, top
Leave a Comment