Ubuntu 24.04
Sponsored Link

SysStat : How to use2024/05/28

 
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 statistics reports.
# CPU

root@dlp:~#
sar -u

Linux 6.8.0-31-generic (dlp.srv.world)  05/28/24        _x86_64_        (2 CPU)

02:42:59     LINUX RESTART      (2 CPU)

02:45:01        CPU     %user     %nice   %system   %iowait    %steal     %idle
02:50:04        all      0.06      0.00      0.05      0.04      0.00     99.85
02:55:01        all      0.00      0.00      0.00      0.01      0.00     99.99
03:00:04        all      0.00      0.00      0.00      0.02      0.00     99.97
03:05:01        all      0.00      0.00      0.00      0.01      0.00     99.99
03:10:01        all      0.02      0.00      0.01      0.02      0.00     99.96
03:15:04        all      0.00      0.00      0.00      0.01      0.00     99.98
03:20:01        all      0.30      0.25      0.18      0.18      0.00     99.09
Average:        all      0.06      0.04      0.04      0.04      0.00     99.83

# memory

root@dlp:~#
sar -r

Linux 6.8.0-31-generic (dlp.srv.world)  05/28/24        _x86_64_        (2 CPU)

02:42:59     LINUX RESTART      (2 CPU)

02:45:01    kbmemfree   kbavail kbmemused  %memused kbbuffers  kbcached  kbcommit   %commit  kbactive   kbinact   kbdirty
02:50:04      3597672   3615612    126676      3.16     16932    211236    186576      2.33    208452     46112        88
02:55:01      3596916   3614920    127404      3.18     16988    211232    186572      2.33    208540     46172         0
03:00:04      3596676   3615328    126848      3.16     17516    211232    186572      2.33    208460     46692         4
03:05:01      3594912   3613712    128460      3.20     17556    211324    188204      2.35    209888     46748       168
03:10:01      3566196   3614480    127056      3.17     18160    239948    276940      3.45    243212     48228         4
03:15:04      3566196   3615028    126568      3.16     18224    240420    221620      2.76    238240     48312       168
03:20:01      3380380   3606080    132640      3.31     18812    414784    258228      3.22    202140    262532         0
Average:      3556993   3613594    127950      3.19     17741    248597    214959      2.68    216990     77828        62

# I/O

root@dlp:~#
sar -b

Linux 6.8.0-31-generic (dlp.srv.world)  05/28/24        _x86_64_        (2 CPU)

02:42:59     LINUX RESTART      (2 CPU)

02:45:01          tps      rtps      wtps      dtps   bread/s   bwrtn/s   bdscd/s
02:50:04         1.77      0.69      1.08      0.00     61.35     13.32      0.00
02:55:01         0.22      0.00      0.22      0.00      0.00      2.40      0.00
03:00:04         0.76      0.38      0.39      0.00      3.01      4.04      0.00
03:05:01         0.18      0.00      0.18      0.00      0.00      1.81      0.00
03:10:01         1.80      1.31      0.48      0.00    193.73      6.56      0.00
03:15:04         0.33      0.02      0.31      0.00      3.03      3.56      0.00
03:20:01        16.80      5.59      2.30      8.92   1167.62   1291.42 163021.58
Average:         3.10      1.13      0.71      1.26    202.52    187.17  23052.73

# network

root@dlp:~#
sar -n DEV

Linux 6.8.0-31-generic (dlp.srv.world)  05/28/24        _x86_64_        (2 CPU)

02:42:59     LINUX RESTART      (2 CPU)

02:45:01        IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s   %ifutil
02:50:04           lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
02:50:04       enp1s0      0.67      0.03      0.04      0.00      0.00      0.00      0.00      0.00
02:55:01           lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
02:55:01       enp1s0      0.72      0.00      0.07      0.00      0.00      0.00      0.00      0.00
03:00:04           lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
03:00:04       enp1s0      0.56      0.01      0.04      0.00      0.00      0.00      0.00      0.00
03:05:01           lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
03:05:01       enp1s0      0.77      0.00      0.08      0.00      0.00      0.00      0.00      0.00
03:10:01           lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
03:10:01       enp1s0      0.92      0.00      0.06      0.00      0.00      0.00      0.00      0.00
03:15:04           lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
03:15:04       enp1s0      0.66      0.00      0.07      0.00      0.00      0.00      0.00      0.00
03:20:01           lo      0.10      0.10      0.02      0.02      0.00      0.00      0.00      0.00
03:20:01       enp1s0      2.42      1.93      4.10      0.15      0.00      0.00      0.00      0.00
Average:           lo      0.01      0.01      0.00      0.00      0.00      0.00      0.00      0.00
Average:       enp1s0      0.96      0.28      0.63      0.02      0.00      0.00      0.00      0.00

# load avarage

root@dlp:~#
sar -q

Linux 6.8.0-31-generic (dlp.srv.world)  05/28/24        _x86_64_        (2 CPU)

02:42:59     LINUX RESTART      (2 CPU)

02:45:01      runq-sz  plist-sz   ldavg-1   ldavg-5  ldavg-15   blocked
02:50:04            0       151      0.00      0.00      0.00         0
02:55:01            0       149      0.00      0.00      0.00         1
03:00:04            0       149      0.00      0.00      0.00         1
03:05:01            1       149      0.00      0.00      0.00         0
03:10:01            0       159      0.00      0.00      0.00         1
03:15:04            0       153      0.00      0.00      0.00         0
03:20:01            0       159      0.00      0.00      0.00         1
Average:            0       153      0.00      0.00      0.00         1
[2] Display past statistics with specifying a log file.
Log files are stored under the [/var/log/sa] directory by default.
# display all statistics by a log file

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

Linux 6.8.0-31-generic (dlp.srv.world)  05/28/24        _x86_64_        (2 CPU)

02:42:59     LINUX RESTART      (2 CPU)

02:45:01        CPU      %usr     %nice      %sys   %iowait    %steal      %irq     %soft    %guest    %gnice     %idle
02:50:04        all      0.06      0.00      0.05      0.04      0.00      0.00      0.00      0.00      0.00     99.85
02:50:04          0      0.08      0.00      0.05      0.07      0.00      0.00      0.00      0.00      0.00     99.80
02:50:04          1      0.04      0.00      0.06      0.01      0.00      0.00      0.00      0.00      0.00     99.89

.....
.....

02:45:01     %smem-10  %smem-60 %smem-300     %smem  %fmem-10  %fmem-60 %fmem-300     %fmem
02:50:04         0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
02:55:01         0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
03:00:04         0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
03:05:01         0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
03:10:01         0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
03:15:04         0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
03:20:01         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 03:00:00 -e 04:00:00 -f /var/log/sysstat/sa28

Linux 6.8.0-31-generic (dlp.srv.world)  05/28/24        _x86_64_        (2 CPU)

03:00:04      runq-sz  plist-sz   ldavg-1   ldavg-5  ldavg-15   blocked
03:05:01            1       149      0.00      0.00      0.00         0
03:10:01            0       159      0.00      0.00      0.00         1
03:15:04            0       153      0.00      0.00      0.00         0
03:20:01            0       159      0.00      0.00      0.00         1
Average:            0       155      0.00      0.00      0.00         0
[3] Display current statistics.
# display CPU utilization per a second 3 times

root@dlp:~#
sar -u 1 3

Linux 6.8.0-31-generic (dlp.srv.world)  05/28/24        _x86_64_        (2 CPU)

03:29:38        CPU     %user     %nice   %system   %iowait    %steal     %idle
03:29:39        all      0.00      0.00      0.00      0.00      0.00    100.00
03:29:40        all      0.00      0.00      0.00      0.00      0.00    100.00
03:29:41        all      0.00      0.00      0.00      0.50      0.00     99.50
Average:        all      0.00      0.00      0.00      0.17      0.00     99.83

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

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

Linux 6.8.0-31-generic (dlp.srv.world)  05/28/24        _x86_64_        (2 CPU)

03:30:10          tps      rtps      wtps      dtps   bread/s   bwrtn/s   bdscd/s
03:30:12         0.00      0.00      0.00      0.00      0.00      0.00      0.00

03:30:10        IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s   %ifutil
03:30:12           lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
03:30:12       enp1s0      0.50      0.00      0.03      0.00      0.00      0.00      0.00      0.00

03:30:12          tps      rtps      wtps      dtps   bread/s   bwrtn/s   bdscd/s
03:30:14         0.00      0.00      0.00      0.00      0.00      0.00      0.00

.....
.....

03:30:18        IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s   %ifutil
03:30:20           lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
03:30:20       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.60      0.00      0.60      0.00      0.00      5.60      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 statistics with them like follows.
# display I/O with Mega bytes per 2 seconds

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

Linux 6.8.0-31-generic (dlp.srv.world)  05/28/24        _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             3.12      0.14     0.00   0.00    0.19    44.86    1.20      0.07     0.00   0.00    0.60    57.81    0.87      7.23     0.00   0.00    0.04  8513.83    0.00    0.00    0.00   0.14
loop0            0.00      0.00     0.00   0.00    0.00     1.27    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              2.45      0.14     0.78  24.13    0.19    58.03    0.84      0.07     0.42  33.36    1.04    82.93    0.88      7.84     0.00   0.00    0.05  9142.26    0.15    3.55    0.00   0.14


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             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    0.00     0.00    0.00    0.00    0.00   0.00
loop0            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    0.00     0.00    0.00    0.00    0.00   0.00
vda              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    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

Linux 6.8.0-31-generic (dlp.srv.world)  05/28/24        _x86_64_        (2 CPU)

03:31:41     CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest  %gnice   %idle
03:31:43     all    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00
03:31:43       0    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00
03:31:43       1    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00

03:31:43     CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest  %gnice   %idle
03:31:45     all    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00
03:31:45       0    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00
03:31:45       1    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00

03:31:45     CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest  %gnice   %idle
03:31:47     all    0.00    0.00    0.25    0.25    0.00    0.00    0.00    0.00    0.00   99.50
03:31:47       0    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00
03:31:47       1    0.00    0.00    0.50    0.50    0.00    0.00    0.00    0.00    0.00   99.00

Average:     CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest  %gnice   %idle
Average:     all    0.00    0.00    0.08    0.08    0.00    0.00    0.00    0.00    0.00   99.83
Average:       0    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00
Average:       1    0.00    0.00    0.17    0.17    0.00    0.00    0.00    0.00    0.00   99.67

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

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

Linux 6.8.0-31-generic (dlp.srv.world)  05/28/24        _x86_64_        (2 CPU)

03:33:39      UID       PID  minflt/s  majflt/s     VSZ     RSS   %MEM  Command
03:33:40      103       678      0.00      0.00  222508    6144   0.15  rsyslogd
03:33:41      103       678      0.00      0.00  222508    6144   0.15  rsyslogd
03:33:42      103       678      0.00      0.00  222508    6144   0.15  rsyslogd
Average:      103       678      0.00      0.00  222508    6144   0.15  rsyslogd

# display CIFS statistics 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