Learn a Linux command every day (103): dstat


Command introduction

Dstat command is a tool to replace vmstat, iostat, netstat, nfsstat and ifstat commands. It is a general system resource statistics tool and an all-round system information statistics tool.

[[email protected] ~]# dstat
-bash: dstat: command not found
[[email protected] ~]# yum install dstat -y

Dstat features

  • It combines vmstat, iostat, ifstat, netstat and more

  • Real time display of Statistics

  • When analyzing and troubleshooting, you can enable monitoring items and sort them

  • Modular design

  • Written in Python, it is more convenient to extend the existing work tasks

  • Easily expand and add your counters (please contribute to this)

  • Many extensions included fully illustrate the convenience of adding new monitoring items

  • Block devices / network devices can be grouped and counted, and the total number can be given

  • The current status of each device can be displayed

  • Extremely accurate time accuracy, even if the system load is high, it will not delay the display

  • Displays the exact units and limits the conversion error range

  • Display different units in different colors

  • The delay of displaying intermediate results is less than 1 second

  • It supports the output of reports in CSV format and can be imported into gnumeric and Excel to generate graphics

Syntax format

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

Option description

-c   # Display CPU system occupation, user occupation, idle, waiting, interrupt, software interrupt and other information
-C   # CPU status can be displayed separately as required
-d   # Displays the disk read / write data size
-n   # Display network status
-N   # Specify the network card to display
-l   # Display 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 requests
-y   # system state 
--ipc      # Display IPC message queue, signal and other information
--socket   # Used to display TCP   UDP port status
--output   file   # Redirect the status information to the specified file in CSV format

Application examples

[[email protected] ~]# dstat
You did not select any stats, using -cdngy by default.
----total-cpu-usage---- -dsk/total- -net/total- ---paging-- ---system--
usr sys idl wai hiq siq| read  writ| recv  send|  in   out | int   csw 
  1   0  98   0   0   0|6268B 1784B|   0     0 |   0     0 |  44    39 
  0   0 100   0   0   0|   0     0 | 120B  842B|   0     0 |  50    68 
  0   0  99   1   0   0|   0     0 | 244B  362B|   0     0 |  53    61 
  1   1  98   0   0   0|   0    20k| 152B  362B|   0     0 |  54    55 
  1   0  99   0   0   0|   0     0 |  60B  362B|   0     0 |  42    54 

Output the displayed information. By default, it is divided into five areas:

--Total CPU usage -- CPU usage
usr   # Percentage of programs in user space
sys   # Percentage of system space programs
ide   # Idle percentage
wai   # Percentage consumed waiting for disk I / O
hiq   # Number of hard interrupts
siq   # Number of soft interrupts
--DSK / total -- disk statistics
read   # Total reads
writ   # Total writes
--net/total--   Network statistics
recv   # Total number of network packets received
send   # Total number of network contracts
--Paging - memory paging statistics
in   # PageIn
out  # page   Out
--System -- system information
int   # Interrupt times
csw   # Context switching

Learn a Linux command every day (103): dstat

Monitor swap, process, sockets and file system and display the monitoring time

[[email protected] ~]# dstat -tsp --socket --fs

Learn a Linux command every day (103): dstat

View total memory usage

[[email protected] ~]# dstat -g -l -m -s --top-mem

Learn a Linux command every day (103): dstat

View all parameters that dstat can use

[[email protected] ~]# dstat --list
 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
 battery, battery-remain, cpufreq, dbus, disk-tps, disk-util, dstat, dstat-cpu, dstat-ctxt, 
 dstat-mem, 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, 
 qmail, rpc, rpcd, sendmail, snooze, squid, test, thermal, top-bio, top-bio-adv, 
 top-childwait, top-cpu, top-cpu-adv, top-cputime, top-cputime-avg, top-int, top-io, 
 top-io-adv, 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

Dstat plug-in function

-–disk-util     # Displays the busy status of the disk at a certain time
-–freespace     # Displays the current disk space usage
-–proc-count    # Displays the number of programs running
-–top-bio       # Indicates the process with the largest block I / O
-–top-cpu       # Graphically display the processes with the largest CPU consumption
-–top-io        # Displays the processes with the largest normal I / O
-–top-mem       # Displays the processes that consume the most memory

Learn a Linux command every day (103): dstat

Learn a Linux command every day (100): iotop

Learn a Linux command (101) every day: pstree

Learn a Linux command every day (102): TAC

Recommended Today


Supervisor [note] Supervisor – H view supervisor command help Supervisorctl – H view supervisorctl command help Supervisorctl help view the action command of supervisorctl Supervisorctl help any action to view the use of this action 1. Introduction Supervisor is a process control system. Generally speaking, it can monitor your process. If the process exits abnormally, […]