We can use the dstat tool to generate statistics on system resource usage.

Options

Here are some options for dstat command:

Option Description
‑‑list Lists the names of all available plug-ins.
-a or ‑‑all Show default plugin set, this is equivalent to dstat -cdngy.
-c or ‑‑cpu Show CPU statistics. (system, user, idle, wait)
-C 0,1,N Show CPU0, CPU1 and CPUN statistics. (Must be used with the -c or ‑‑cpu option.)
-d or ‑‑disk Show disk statistic.
-D disk1,disk2,N Show disk1, disk2 and N staistics. (Must be used with the -d or ‑‑disk option.)
-g or ‑‑page Show page statistics.
-i or ‑‑int Show interrupt statistics.
-I 27,28,N Show interrupt 27, 28 and N. (Must be used with the -i or ‑‑int option.)
-l or ‑‑load Show load average statistics. (1, 5, 15 mins)
-m or ‑‑mem Show memory statistics.
-n or ‑‑net Show network I/O statistics.
-N eth1,eth2,N Show network interface eth1, eth2 and N. (Must be used with the -n or ‑‑net option.)
‑‑net-packets Displays received and sent network packets.
-p or ‑‑proc Show process statistics.
‑‑proc-count Displays the total number of processes.
-r or ‑‑io Show I/O request statistics.
-s or ‑‑swap Show swap statistics.
-S swap1,swap2,N Show swap1, swap2 and N statistics. (Must be used with the -s or ‑‑swap option.)
‑‑snooze Show the number of seconds consumed per row.
-t or ‑‑time Show each row’s output time.
-T or ‑‑epoch Show each row’s output timestamp.
-y or ‑‑sys Show system statistics. (interrupts, context switches)
‑‑aio Show aio statistics.
‑‑fs or ‑‑filesystem Show filesystem statistics. (open files, inodes)
‑‑freespace Used and usable space for each file system. (A window with a width of 2700 pixels or more is required)
‑‑ipc Show ipc statistics. (message queue, semaphores, shared memory)
‑‑lock Show file lock statistics. (posix, flock, read, write)
‑‑raw Show raw sockets statistics.
‑‑socket Show socket statistics. (total, tcp, udp, raw, ip-fragments)
‑‑tcp Show tcp statistics. (listen, established, syn, time_wait, close)
‑‑udp Show udp statistics. (listen, active)
‑‑unix Show unix statistics. (datagram, stream, listen, active)
‑‑vm Show virtual memory statistics. (hard pagefaults, soft pagefaults, allocated, free)
‑‑top-bio Show the block I/O process that consumes the most.
‑‑top-bio-adv Show the block I/O process that consumes the most. (include the process PID)
‑‑top-childwait Show the process that has been waiting for the child process for the longest time.
‑‑top-cpu Show the CPU process that consumes the most.
‑‑top-cpu-adv Show the CPU process that consumes the most. (include the process PID)
‑‑top-cputime Show the process that consumes the most CPU time. (in milliseconds)
‑‑top-cputime-avg Shows the process with the highest average time slice. (in milliseconds)
‑‑top-io Show the I/O process that consumes the most.
‑‑top-io-avg Show the I/O process that consumes the most. (include the process PID)
‑‑top-latency Show the process with the highest latency. (in milliseconds)
‑‑top-latency-avg Show the process with the highest average latency. (include the process PID)
‑‑top-mem Show the process that consumes the most memory.
‑‑top-oom Show the process that is most likely to be killed by the out-of-memory killer.
-f or ‑‑full Show the contents similar to the expansion of the CDINS options.
‑‑bits Converts values displayed in bytes to bits.
‑‑float Show values as floating points.
‑‑integer Show values as integer points.
‑‑bw or ‑‑blackonwhite Show non-empty values.
‑‑nocolor Show black and white content.
‑‑noheaders Show headers once.

Examples

Output All Available Plug-ins

1
dstat --list
img

Output One Row Per Second Five Lines in Total

1
dstat 1 5    # Output 5 rows, 1 second per row
img

Output All Default Plugin Set

1
dstat -a 1 1    # This is equivalent to dstat --all 1 1
img

Output CPU Statistics

1
dstat -c 1 1    # This is equivalent to dstat --cpu 1 1
img

Output Disk Statistics

1
dstat -d 1 1    # This is equivalent to dstat --disk 1 1
img

Output Page Statistics

1
dstat -g 1 1    # This is equivalent to dstat --page 1 1
img

Output Interrupt Statistics

1
dstat -i 1 1    # This is equivalent to dstat --int 1 1
img

Output Memory Statistics

1
dstat -m 1 1    # This is equivalent to dstat --mem 1 1
img

Output Network Statistics

1
dstat -n 1 1    # This is equivalent to dstat --net 1 1
img

Output Process Statistics

1
dstat -p 1 1    # This is equivalent to dstat --proc 1 1
img

Output Process Amount

1
dstat --proc-count 1 1
img

Output I/O Statistics

1
dstat -r 1 1    # This is equivalent to dstat --io 1 1
img

Output Swap Statistics

1
dstat -s 1 1    # This is equivalent to dstat --swap 1 1
img

Output System Statistics

1
dstat -y 1 1    # This is equivalent to dstat --sys 1 1
img

Output AIO Statistics

1
dstat --aio 1 1
img

Output Filesystem Statistics

1
dstat -fs 1 1    # This is equivalent to dstat --filesystem 1 1
img

Output Statistics of Used and Usable Space

1
dstat --freespace 1 1    # Should expand the width of the window to 2700 pixel
img

Output IPC Statistics

1
dstat --ipc 1 1
img

Output File Lock Statistics

1
dstat --lock 1 1
img

Output Raw Sockets Statistics

1
dstat --raw 1 1
img

Output Socket Statistics

1
dstat --socket 1 1
img

Output TCP Statistics

1
dstat --tcp 1 1
img

Output UDP Statistics

1
dstat --udp 1 1
img

Output UNIX Statistics

1
dstat --unix 1 1
img

Output Virtual Memory Statistics

1
dstat --vm 1 1
img

Output Block I/O Processes that Consumes the Most

1
dstat --top-bio 1 1
img

Output Processes that Has Been Waiting for Child Processes for the Longest Time

1
dstat --top-childwait 1 1
img

Output CPU Processes that Consumes the Most

1
dstat --top-cpu 1 1
img

Output Processes that Consumes the Most CPU Time

1
dstat --top-cputime 1 1
img

Output I/O Processes that Consumes the Most

1
dstat --top-io 1 1
img

Output Processes With the Highest Latency

1
dstat --top-latency 1 1
img

Output Processes that Consumes the Most

1
dstat --top-mem 1 1
img

Output Processes that is Most Likely to be killed by the Out-Of-Memory Killer

1
dstat --top-oom 1 1
img

References PCP-DSTAT(1)

Buy me a coffeeBuy me a coffee