Ubuntu 22.04
Sponsored Link

SysStat : How to use
2022/05/19
 
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

Linux 5.15.0-25-generic (dlp.srv.world)         05/19/22        _x86_64_        (2 CPU)

05:39:26     LINUX RESTART      (2 CPU)

05:40:31        CPU     %user     %nice   %system   %iowait    %steal     %idle
05:45:40        all      5.34      1.76      4.73     11.92      0.00     76.25
05:50:19        all      0.23      0.19      0.35      0.20      0.00     99.03
05:55:40        all      0.46      0.00      0.39      0.57      0.00     98.58
Average:        all      2.04      0.65      1.85      4.30      0.00     91.15

# memory

root@dlp:~#
sar -r

Linux 5.15.0-25-generic (dlp.srv.world)         05/19/22        _x86_64_        (2 CPU)

05:39:26     LINUX RESTART      (2 CPU)

05:40:31    kbmemfree   kbavail kbmemused  %memused kbbuffers  kbcached  kbcommit   %commit  kbactive   kbinact   kbdirty
05:45:40      2163784   3477732    218220      5.43     68996   1397040    807504     11.59    689924    897476        84
05:50:19      2229096   3502648    193388      4.81     69100   1356616    662584      9.51    692392    811152       136
05:55:40      2235820   3510832    185272      4.61     69832   1357380    693648      9.96    728256    783768        84
Average:      2209567   3497071    198960      4.95     69309   1370345    721245     10.36    703524    830799       101

# I/O

root@dlp:~#
sar -b

Linux 5.15.0-25-generic (dlp.srv.world)         05/19/22        _x86_64_        (2 CPU)

05:39:26     LINUX RESTART      (2 CPU)

05:40:31          tps      rtps      wtps      dtps   bread/s   bwrtn/s   bdscd/s
05:45:40       213.49     11.50    201.99      0.00   1547.74  12369.85      0.00
05:50:19         1.00      0.02      0.98      0.00      1.38     29.17      0.00
05:55:40         2.63      0.45      2.18      0.00      6.76    157.78      0.00
Average:        73.71      4.07     69.65      0.00    528.27   4264.31      0.00

# network

root@dlp:~#
sar -n DEV

Linux 5.15.0-25-generic (dlp.srv.world)         05/19/22        _x86_64_        (2 CPU)

05:39:26     LINUX RESTART      (2 CPU)

05:40:31        IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s   %ifutil
05:45:40           lo      1.02      1.02      0.06      0.06      0.00      0.00      0.00      0.00
05:45:40       enp1s0     57.10     37.61    429.22      2.61      0.00      0.00      0.00      0.00
05:50:19           lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
05:50:19       enp1s0      0.66      0.01      0.08      0.00      0.00      0.00      0.00      0.00
05:55:40           lo      0.95      0.95      0.05      0.05      0.00      0.00      0.00      0.00
05:55:40       enp1s0      4.69      3.41      1.32     13.16      0.00      0.00      0.00      0.00
Average:           lo      0.68      0.68      0.04      0.04      0.00      0.00      0.00      0.00
Average:       enp1s0     21.24     13.98    146.21      5.53      0.00      0.00      0.00      0.00

# load avarage

root@dlp:~#
sar -q

Linux 5.15.0-25-generic (dlp.srv.world)         05/19/22        _x86_64_        (2 CPU)

05:39:26     LINUX RESTART      (2 CPU)

05:40:31      runq-sz  plist-sz   ldavg-1   ldavg-5  ldavg-15   blocked
05:45:40            0       175      0.14      0.49      0.29         0
05:50:19            3       174      0.06      0.20      0.21         0
05:55:40            0       172      0.10      0.10      0.15         1
Average:            1       174      0.10      0.26      0.22         0
[2] Display past statics with specifying a log file.
Log files are stored under the [/var/log/sa] directory by default.
# display all statics by a log file

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

Linux 5.15.0-25-generic (dlp.srv.world)         05/19/22        _x86_64_        (2 CPU)

05:39:26     LINUX RESTART      (2 CPU)

05:40:31        CPU      %usr     %nice      %sys   %iowait    %steal      %irq     %soft    %guest    %gnice     %idle
05:45:40        all      5.34      1.76      4.61     11.92      0.00      0.00      0.11      0.00      0.00     76.25
05:45:40          0      6.93      1.84      6.03     10.99      0.00      0.00      0.07      0.00      0.00     74.13
05:45:40          1      3.74      1.67      3.20     12.86      0.00      0.00      0.16      0.00      0.00     78.38

.....
.....

05:40:31     %smem-10  %smem-60 %smem-300     %smem  %fmem-10  %fmem-60 %fmem-300     %fmem
05:45:40         0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
05:50:19         0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
05:55:40         0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
Average:         0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00

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

root@dlp:~#
sar -q -s 05:40:00 -e 05:50:00 -f /var/log/sysstat/sa19

Linux 5.15.0-25-generic (dlp.srv.world)         05/19/22        _x86_64_        (2 CPU)

05:40:31      runq-sz  plist-sz   ldavg-1   ldavg-5  ldavg-15   blocked
05:45:40            0       175      0.14      0.49      0.29         0
Average:            0       175      0.14      0.49      0.29         0
[3] Display current statics.
# display CPU utilization per a second 3 times

root@dlp:~#
sar -u 1 3

Linux 5.15.0-25-generic (dlp.srv.world)         05/19/22        _x86_64_        (2 CPU)

06:00:02        CPU     %user     %nice   %system   %iowait    %steal     %idle
06:00:03        all      0.00      0.00      1.00      0.00      0.00     99.00
06:00:04        all      0.51      0.00      0.00      0.00      0.00     99.49
06:00:05        all      0.00      0.00      0.00      0.00      0.00    100.00
Average:        all      0.17      0.00      0.34      0.00      0.00     99.50

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

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

Linux 5.15.0-25-generic (dlp.srv.world)         05/19/22        _x86_64_        (2 CPU)

06:00:22          tps      rtps      wtps      dtps   bread/s   bwrtn/s   bdscd/s
06:00:24         0.00      0.00      0.00      0.00      0.00      0.00      0.00

06:00:22        IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s   %ifutil
06:00:24           lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
06:00:24       enp1s0      0.50      0.00      0.03      0.00      0.00      0.00      0.00      0.00

06:00:24          tps      rtps      wtps      dtps   bread/s   bwrtn/s   bdscd/s
06:00:26         0.00      0.00      0.00      0.00      0.00      0.00      0.00

.....
.....

06:00:30        IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s   %ifutil
06:00:32           lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
06:00:32       enp1s0      0.50      0.00      0.03      0.00      0.00      0.00      0.00      0.00

Average:          tps      rtps      wtps      dtps   bread/s   bwrtn/s   bdscd/s
Average:         0.00      0.00      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:       enp1s0      0.50      0.00      0.03      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

Linux 5.15.0-25-generic (dlp.srv.world)         05/19/22        _x86_64_        (2 CPU)

Device            r/s     rMB/s   rrqm/s  %rrqm r_await rareq-sz     w/s     wMB/s   wrqm/s  %wrqm w_await wareq-sz     d/s     dMB/s   drqm/s  %drqm d_await dareq-sz     f/s f_await  aqu-sz  %util
dm-0             9.44      0.37     0.00   0.00    0.11    40.32   74.62      1.39     0.00   0.00    4.04    19.07    1.42     15.01     0.00   0.00    0.03 10819.09    0.00    0.00    0.30   6.41
loop0            0.04      0.00     0.00   0.00    0.07     8.64    0.00      0.00     0.00   0.00    0.00     0.00    0.00      0.00     0.00   0.00    0.00     0.00    0.00    0.00    0.00   0.00
loop1            0.04      0.00     0.00   0.00    0.19     9.46    0.00      0.00     0.00   0.00    0.00     0.00    0.00      0.00     0.00   0.00    0.00     0.00    0.00    0.00    0.00   0.00
loop2            0.05      0.00     0.00   0.00    0.22    18.54    0.00      0.00     0.00   0.00    0.00     0.00    0.00      0.00     0.00   0.00    0.00     0.00    0.00    0.00    0.00   0.00
loop3            0.04      0.00     0.00   0.00    0.18     8.53    0.00      0.00     0.00   0.00    0.00     0.00    0.00      0.00     0.00   0.00    0.00     0.00    0.00    0.00    0.00   0.00
loop4            0.01      0.00     0.00   0.00    0.00     1.50    0.00      0.00     0.00   0.00    0.00     0.00    0.00      0.00     0.00   0.00    0.00     0.00    0.00    0.00    0.00   0.00
vda              8.32      0.43     2.26  21.37    0.14    53.19   46.27      1.47    29.11  38.62    1.94    32.51    1.44     16.29     0.00   0.00    0.02 11581.51   24.41    2.57    0.15   6.42

.....
.....

# display all CPU utilization per 2 seconds 3 times

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

Linux 5.15.0-25-generic (dlp.srv.world)         05/19/22        _x86_64_        (2 CPU)

06:02:19     CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest  %gnice   %idle
06:02:21     all    0.00    0.00    0.50    0.00    0.00    0.00    0.00    0.00    0.00   99.50
06:02:21       0    0.00    0.00    1.00    0.00    0.00    0.00    0.00    0.00    0.00   99.00
06:02:21       1    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00

06:02:21     CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest  %gnice   %idle
06:02:23     all    0.00    0.00    1.00    0.00    0.00    0.00    0.00    0.00    0.00   99.00
06:02:23       0    0.00    0.00    1.50    0.00    0.00    0.00    0.00    0.00    0.00   98.50
06:02:23       1    0.00    0.00    0.50    0.00    0.00    0.00    0.00    0.00    0.00   99.50

06:02:23     CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest  %gnice   %idle
06:02:25     all    0.25    0.00    0.50    0.75    0.00    0.00    0.00    0.00    0.00   98.50
06:02:25       0    0.50    0.00    1.00    0.00    0.00    0.00    0.00    0.00    0.00   98.50
06:02:25       1    0.00    0.00    0.00    1.51    0.00    0.00    0.00    0.00    0.00   98.49

Average:     CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest  %gnice   %idle
Average:     all    0.08    0.00    0.67    0.25    0.00    0.00    0.00    0.00    0.00   99.00
Average:       0    0.17    0.00    1.16    0.00    0.00    0.00    0.00    0.00    0.00   98.67
Average:       1    0.00    0.00    0.17    0.50    0.00    0.00    0.00    0.00    0.00   99.33

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

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

Linux 5.15.0-25-generic (dlp.srv.world)         05/19/22        _x86_64_        (2 CPU)

06:03:23      UID       PID  minflt/s  majflt/s     VSZ     RSS   %MEM  Command
06:03:24      998     15539      0.00      0.00  271148   38876   0.97  netdata
06:03:25      998     15539      0.00      0.00  271148   38876   0.97  netdata
06:03:26      998     15539      0.00      0.00  271148   38876   0.97  netdata
Average:      998     15539      0.00      0.00  271148   38876   0.97  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