Ubuntu 18.04
Sponsored Link

SysStat : How to Use2018/05/15

 
How to use SysStat.
To input sar command with specifying options like follows, it's possible to display logs. (refer to "man sar" for more details)
Option Description
-u CPU utilization statistics
-r Memory utilization statistics
-b I/O and transfer rate statistics
-B Paging statistics
-d Activity for each block device
-n [keyword] Network statistics
-q Queue length and load averages
-A Display All

[1] Display today's statics reports.
# CPU

root@dlp:~#
sar -u

01:10:01 AM     CPU     %user     %nice   %system   %iowait    %steal     %idle
10:20:01 AM     all      0.90      0.00      0.23      1.19      0.03     97.65
...
...
01:30:01 PM     all      0.04      0.00      0.06      0.14      0.04     99.72
Average:        all      3.60      0.00      0.05      0.21      0.01     96.13

# memory

root@dlp:~#
sar -r

01:10:01 AM kbmemfree kbmemused  %memused kbbuffers  kbcached  kbcommit   %commit
10:20:01 AM   3681144    241544      6.16     10744    138392     83984      1.04
...
...
01:40:01 PM   3663328    259360      6.61     14752    145988     87996      1.09
Average:      3666930    255758      6.52     13204    144710     88273      1.10

# I/O

root@dlp:~#
sar -b

01:10:01 AM       tps      rtps      wtps   bread/s   bwrtn/s
10:20:01 AM     45.21      9.35     35.87    257.22    409.24
...
...
01:40:01 PM      0.52      0.00      0.52      0.00      5.43
Average:         3.11      0.49      2.62     14.55     29.32

# network

root@dlp:~#
sar -n DEV

01:10:01 AM     IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s
10:20:01 AM        lo      1.04      1.04      0.09      0.09      0.00      0.00      0.00
10:20:01 AM      eth0      7.48      4.48     10.06      0.30      0.00      0.00      0.00
...
...
01:40:01 PM        lo      0.01      0.01      0.00      0.00      0.00      0.00      0.00
01:40:01 PM      eth0      0.05      0.04      0.00      0.00      0.00      0.00      0.00
Average:           lo      0.08      0.08      0.01      0.01      0.00      0.00      0.00
Average:         eth0      0.54      0.38      0.51      0.03      0.00      0.00      0.00

# load avarage

root@dlp:~#
sar -q

01:10:01 AM   runq-sz  plist-sz   ldavg-1   ldavg-5  ldavg-15
10:20:01 AM         1        99      0.04      0.07      0.04
...
...
01:30:01 PM         1       104      0.00      0.00      0.00
01:40:01 PM         1       101      0.00      0.00      0.00
Average:            1       102      0.11      0.08      0.06
[2] Display past statics with specifying a log file.
Log files are stored under the /var/log/sysstat directory.
# display all statisc by a log file

root@dlp:~#
sar -A -f /var/log/sysstat/sa15

01:10:01 AM     CPU      %usr     %nice      %sys   %iowait    %steal      %irq     %soft    %guest     %idle
10:20:01 AM     all      0.90      0.00      0.19      1.19      0.03      0.04      0.00      0.00     97.65
10:20:01 AM       0      0.96      0.00      0.19      1.27      0.03      0.04      0.00      0.00     97.51
...
...
01:50:01 PM       125         3         4         0         0         0
02:00:01 PM       125         3         4         0         0         0
Average:          122         3         4         0         0         0

# display the load average with specifying times by a log file

root@dlp:~#
sar -q -s 11:00:00 -e 12:00:00 -f /var/log/sysstat/sa15

11:00:01 AM   runq-sz  plist-sz   ldavg-1   ldavg-5  ldavg-15
11:10:01 AM         1       103      0.01      0.03      0.14
11:20:01 AM         1       102      0.01      0.01      0.06
11:30:01 AM         1       102      0.00      0.00      0.01
11:40:01 AM         1       101      0.00      0.00      0.00
11:50:01 AM         1       101      0.01      0.01      0.00
Average:            1       102      0.01      0.01      0.04
[3] Display current statics.
# display CPU utilization per a second 3 times

root@dlp:~#
sar -u 1 3

04:54:12 PM     CPU     %user     %nice   %system   %iowait    %steal     %idle
04:54:13 PM     all      0.00      0.00      1.01      0.00      0.00     98.99
04:54:14 PM     all      0.50      0.00      0.50      0.00      0.50     98.50
04:54:15 PM     all      0.50      0.00      0.50      0.00      0.00     99.00
Average:        all      0.33      0.00      0.67      0.00      0.17     98.83

# display I/O and network per 2 seconds 5 times

root@dlp:~#
sar -b -n DEV 2 5

04:54:36 PM       tps      rtps      wtps   bread/s   bwrtn/s
04:54:38 PM      0.00      0.00      0.00      0.00      0.00

04:54:36 PM     IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s   %ifutil
04:54:38 PM        lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
04:54:38 PM      ens3      1.50      0.00      0.08      0.00      0.00      0.00      0.00      0.00
.....
.....
04:54:44 PM       tps      rtps      wtps   bread/s   bwrtn/s
04:54:46 PM      0.00      0.00      0.00      0.00      0.00

04:54:44 PM     IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s   %ifutil
04:54:46 PM        lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
04:54:46 PM      ens3      1.50      0.00      0.08      0.00      0.00      0.00      0.00      0.00

Average:          tps      rtps      wtps   bread/s   bwrtn/s
Average:         0.00      0.00      0.00      0.00      0.00

Average:        IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s   %ifutil
Average:           lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
Average:         ens3      1.50      0.00      0.08      0.00      0.00      0.00      0.00      0.00
[4] SysStat packages includes other commands not only Sar command, so it's possible to display current statics with them like follows.
# display I/O with Mega bytes per 2 seconds

root@dlp:~#
iostat -mx -d 2

Device      r/s     w/s     rMB/s     wMB/s   rrqm/s   wrqm/s  %rrqm  %wrqm r_await w_await aqu-sz .....
vda        0.00    0.00      0.00      0.00     0.00     0.00   0.00   0.00    0.00    0.00   0.00 .....
dm-0       0.00    0.00      0.00      0.00     0.00     0.00   0.00   0.00    0.00    0.00   0.00 .....
dm-1       0.00    0.00      0.00      0.00     0.00     0.00   0.00   0.00    0.00    0.00   0.00 .....
.....
.....

# display all CPU utilization per 2 seconds 3 times

root@dlp:~#
mpstat -P ALL 2 3

04:56:43 PM  CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest  %gnice   %idle
04:56:46 PM  all    0.50    0.00    0.25    0.00    0.00    0.00    0.00    0.00    0.00   99.25
04:56:46 PM    0    1.00    0.00    0.50    0.00    0.00    0.00    0.00    0.00    0.00   98.50
04:56:46 PM    1    0.50    0.00    0.50    0.00    0.00    0.00    0.00    0.00    0.00   99.00
.....
.....

# display memory utilization of a process per a second 3 times

root@dlp:~#
pidstat -r -p 3036 1 3

04:57:26 PM   UID       PID  minflt/s  majflt/s     VSZ     RSS   %MEM  Command
04:57:27 PM   110      3036      0.00      0.00  182480   32988   0.82  netdata
04:57:28 PM   110      3036      0.00      0.00  182480   32988   0.82  netdata
04:57:29 PM   110      3036      0.00      0.00  182480   32988   0.82  netdata
Average:      110      3036      0.00      0.00  182480   32988   0.82  netdata
.....
.....

# display CIFS statics with Mega bytes per a 1 second 3 times

root@dlp:~#
cifsiostat -m 1 3

Filesystem:               rB/s         wB/s    rops/s    wops/s         fo/s         fc/s         fd/s
\\10.0.0.100\tmp          0.00        20.93      0.00      0.00         0.00         0.00         0.00
.....
.....
Matched Content