dstat

General system resource statistics tool

Supplementary instructions

dstat command is a tool used to replace vmstat, iostat, netstat, nfsstat and ifstat commands. It is an all-round system information statistics tool. Compared with sysstat, dstat has a colorful interface. When manually observing performance conditions, the data is more conspicuous and easy to observe; and dstat supports instant refresh. For example, entering dstat 3 will collect it every three seconds, but the latest data will be collected every three seconds. Refresh the display in seconds. Like sysstat, dstat can also collect specified performance resources. For example, dstat -c displays CPU usage.

Download and install

method one

yum install -y dstat

Method Two

Official website download address: http://dag.wieers.com/rpm/packages/dstat

wget http://dag.wieers.com/rpm/packages/dstat/dstat-0.6.7-1.rh7.rf.noarch.rpm
rpm -ivh dstat-0.6.7-1.rh7.rf.noarch.rpm

Instructions for use

It can be used after installation. dstat is very powerful and can monitor the usage of CPU, disk, network, IO, memory and so on in real time.

Use dstat directly. The -cdngy parameter is used by default to display cpu, disk, net, page, and system information respectively. The default is to display one message every 1 second. You can specify the time interval for displaying a piece of information at the end. For example, dstat 5 means that one message will be displayed every 5 seconds, and dstat 5 10 means that one message will be displayed every 5 seconds. A total of 10 messages will be displayed.

[root@iZ23uulau1tZ ~]# dstat
----total-cpu-usage---- -dsk/total- -net/total- ---paging-- ---system--
usr sys idl wai hiq siq| read writ| recv send| in out | int csw
   0 0 99 0 0 0|7706B 164k| 0 0 | 0 0 | 189 225
   0 0 100 0 0 0| 0 0 |4436B 826B| 0 0 | 195 248
   1 0 99 0 0 0| 0 0 |4744B 346B| 0 0 | 203 242
   0 0 100 0 0 0| 0 0 |5080B 346B| 0 0 | 206 242
   0 1 99 0 0 0| 0 0 |5458B 444B| 0 0 | 214 244
   1 0 99 0 0 0| 0 0 |5080B 346B| 0 0 | 208 242

The following is some explanation of some of the displayed information:

Everything else is easy to understand.

grammar

dstat [-afv] [options..] [delay [count]]

Common options

-c: Displays CPU system occupancy, user occupancy, idle, waiting, interrupts, software interrupts and other information.
-C: When there are multiple CPUs, this parameter can display the cpu status separately as needed. For example: -C 0,1 displays the information of cpu0 and cpu1.
-d: Display disk read and write data size.
-D hda,total: include hda and total.
-n: Display network status.
-N eth1,total: When there are multiple network cards, specify the network card to be displayed.
-l: Display the system load.
-m: Display memory usage.
-g: Display page usage.
-p: Display process status.
-s: Display swap partition usage.
-S: Similar to D/N.
-r: I/O request status.
-y: system status.
--ipc: Display ipc message queue, signal and other information.
--socket: used to display tcp udp port status.
-a: This is the default option, equivalent to -cdngy.
-v: Equivalent to -pmgdsc -D total.
--output file: This option is also useful. It can redirect the status information to the specified file in csv format for later viewing. Example: dstat --output /root/dstat.csv & At this time, let the program run silently in the background and output the results to the /root/dstat.csv file.

Of course, there are many more advanced uses of dstat. These are the basic options that are commonly used. More advanced uses can be combined with the man documentation.

Example

If you want to monitor swap, process, sockets, filesystem and display the monitoring time:

[root@iZ23uulau1tZ ~]# dstat -tsp --socket --fs
----system---- ----swap--- ---procs--- ------sockets------ --filesystem-
   date/time | used free|run blk new|tot tcp udp raw frg|files inodes
26-07 09:23:48| 0 0 | 0 0 0.0|104 8 5 0 0| 704 6488
26-07 09:23:49| 0 0 | 0 0 0|104 8 5 0 0| 704 6488
26-07 09:23:50| 0 0 | 0 0 0|104 8 5 0 0| 704 6489
26-07 09:23:51| 0 0 | 0 0 0|104 8 5 0 0| 704 6489
26-07 09:23:52| 0 0 | 0 0 0|104 8 5 0 0| 704 6489
26-07 09:23:53| 0 0 | 0 0 0|104 8 5 0 0| 704 6489

If you want to output the results to a file, you can add --output filename:

[root@iZ23uulau1tZ ~]# dstat -tsp --socket --fs --output /tmp/ds.csv
----system---- ----swap--- ---procs--- ------sockets------ --filesystem-
   date/time | used free|run blk new|tot tcp udp raw frg|files inodes
26-07 09:25:31| 0 0 | 0 0 0.0|104 8 5 0 0| 736 6493
26-07 09:25:32| 0 0 | 0 0 0|104 8 5 0 0| 736 6493
26-07 09:25:33| 0 0 | 0 0 0|104 8 5 0 0| 736 6493
26-07 09:25:34| 0 0 | 0 0 0|104 8 5 0 0| 736 6493
26-07 09:25:35| 0 0 | 0 0 0|104 8 5 0 0| 736 6494
26-07 09:25:36| 0 0 | 0 0 0|104 8 5 0 0| 736 6494

The csv file generated in this way can be opened with excel and then a chart can be generated.

You can view all the parameters that dstat can use through dstat --list. The above internal are some monitoring parameters that come with dstat itself. The following /usr/share/dstat is the plug-in for dstat. These plug-ins can extend dstat. Functions, such as monitoring power supply (battery), mysql, etc.

Not all of the following plug-ins can be used directly, and some also rely on other packages. If you want to monitor mysql, you must install some packages that connect python to mysql.

[root@iZ23uulau1tZ ~]# dstat --list
internal:
         aio, cpu, cpu24, disk, disk24, disk24old, epoch, fs, int, int24, io, ipc, load, lock, mem, net, page, page24, proc, raw, socket, swap, swapold, sys, tcp, time, udp, unix, vm
/usr/share/dstat:
         battery, battery-remain, cpufreq, dbus, disk-util, fan, freespace, gpfs, gpfs-ops, helloworld, innodb-buffer, innodb-io, innodb-ops, lustre, memcache-hits, mysql-io, mysql- keys, mysql5-cmds, mysql5-conn, mysql5-io, mysql5-keys,
         net-packets, nfs3, nfs3-ops, nfsd3, nfsd3-ops, ntp, postfix, power, proc-count, rpc, rpcd, sendmail, snooze, thermal, top-bio, top-cpu, top-cputime, top- cputime-avg, top-io, top-latency, top-latency-avg, top-mem, top-oom, utmp,
         vm-memctl, vmk-hba, vmk-int, vmk-nic, vz-cpu, vz-io, vz-ubc, wifi

That’s all for the basic usage of the dstat command. More usage needs to be explored. If you need additional content, please send us an email. Thank you!