Installing and configuring sysstat on CentOS 6

[1] Install SYSSTAT


[root@dlp ~]#yum -y install sysstat
[root@dlp ~]#/etc/rc.d/init.d/sysstat start

Calling the system activity data collector (sadc):


[root@dlp ~]# chkconfig sysstat on

[2] The jobs getting system information are set like follows. Logs are stored in “/var/log/sa/sa**” and “/var/log/sa/sar**”.


[root@dlp ~]# cat /etc/cron.d/sysstat


# Run system activity accounting tool every 10 minutes
*/10 * * * * root /usr/lib64/sa/sa1 1 1
# 0 * * * * root /usr/lib64/sa/sa1 600 6 &
# Generate a daily summary of process accounting at 23:53
53 23 * * * root /usr/lib64/sa/sa2 -A

View RAM usage

# sar -r
12:00:01 AM kbmemfree kbmemused  %memused kbbuffers  kbcached  kbcommit   %commit
12:10:01 AM    419648   1502728     78.17     66732    397336   1376580     38.26
12:20:01 AM    419276   1503100     78.19     66984    397428   1376580     38.26
12:30:01 AM    419152   1503224     78.20     67196    397488   1376580     38.26
12:40:01 AM    418904   1503472     78.21     67316    397528   1376580     38.26


view Swap usage

sar -S
12:00:01 AM kbswpfree kbswpused  %swpused  kbswpcad   %swpcad
12:10:01 AM   1607192     68068      4.06      8468     12.44
12:20:01 AM   1607196     68064      4.06      8464     12.44
12:30:01 AM   1607200     68060      4.06      8460     12.43
12:40:01 AM   1607208     68052      4.06      8464     12.44

It’s possible to output current or past status of system with “sar” command like follows.
[3] Output the past CPU usage from the log file.


[root@dlp ~]#
sar -u -f /var/log/sa/sa24


Linux 2.6.32-358.6.2.el6.x86_64 (dlp.server.world)      06/24/2013      _x86_64_        (2 CPU)

04:45:47 AM       LINUX RESTART

01:50:01 PM     CPU     %user     %nice   %system   %iowait    %steal     %idle
01:59:03 PM     all      0.00      0.00      0.02      0.09      0.00     99.89
02:00:01 PM     all      0.02      0.00      0.07      0.29      0.02     99.60
02:10:01 PM     all      0.00      0.00      0.01      0.05      0.00     99.94
02:20:01 PM     all      0.00      0.00      0.00      0.01      0.00     99.99
02:30:01 PM     all      0.00      0.00      0.00      0.01      0.00     99.99
02:40:01 PM     all      0.00      0.30      0.50      0.36      0.00     98.84
02:50:01 PM     all      0.00      0.00      0.00      0.02      0.00     99.98
03:00:01 PM     all      0.00      0.00      0.00      0.02      0.00     99.98
03:10:01 PM     all      0.00      0.00      0.00      0.04      0.00     99.95
Average:        all      0.00      0.04      0.07      0.08      0.00     99.82

03:19:29 PM       LINUX RESTART
...
...

[4] Output the current CPU usage for 3 times every second.


[root@dlp ~]# sar -u 1 3


Linux 2.6.32-358.6.2.el6.x86_64 (dlp.server.world)      06/24/2013      _x86_64_        (2 CPU)

05:29:12 PM     CPU     %user     %nice   %system   %iowait    %steal     %idle
05:29:13 PM     all      0.00      0.00      0.00      0.00      0.00    100.00
05:29:14 PM     all      0.00      0.00      0.00      0.00      0.50     99.50
05:29:15 PM     all      0.50      0.00      0.50      0.00      0.00     99.00
Average:        all      0.17      0.00      0.17      0.00      0.17     99.50

[5] Output the current Disk usage for 3 times every second.


[root@dlp ~]#sar -b 1 3


Linux 2.6.32-358.6.2.el6.x86_64 (dlp.server.world)      06/25/2013      _x86_64_        (2 CPU)

06:02:27 AM       tps      rtps      wtps   bread/s   bwrtn/s
06:02:28 AM      0.00      0.00      0.00      0.00      0.00
06:02:29 AM      0.00      0.00      0.00      0.00      0.00
06:02:30 AM      0.00      0.00      0.00      0.00      0.00
Average:         0.00      0.00      0.00      0.00      0.00

[6] Output the current Memory usage for 3 times every second.


[root@dlp ~]# sar -r 1 3


Linux 2.6.32-358.6.2.el6.x86_64 (dlp.server.world)      06/25/2013      _x86_64_        (2 CPU)

03:06:52 PM kbmemfree kbmemused  %memused kbbuffers  kbcached  kbcommit   %commit
03:06:53 PM   1832648     89916      4.68      5796     24552     53452      0.88
03:06:54 PM   1832648     89916      4.68      5796     24552     53452      0.88
03:06:55 PM   1832648     89916      4.68      5796     24552     53452      0.88
Average:      1832648     89916      4.68      5796     24552     53452      0.88


[7] 	Output the current send/receive packets for 3 times every second.
[root@dlp ~]#
sar -n DEV 1 3


Linux 2.6.32-358.6.2.el6.x86_64 (dlp.server.world)      06/25/2013      _x86_64_        (2 CPU)

03:20:05 PM     IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s
03:20:06 PM        lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00
03:20:06 PM      eth2      0.00      0.00      0.00      0.00      0.00      0.00      0.00

03:20:06 PM     IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s
03:20:07 PM        lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00
03:20:07 PM      eth2      0.00      0.00      0.00      0.00      0.00      0.00      0.00

03:20:07 PM     IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s
03:20:08 PM        lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00
03:20:08 PM      eth2      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
Average:           lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00
Average:         eth2      0.00      0.00      0.00      0.00      0.00      0.00      0.00

[8] Output the current paging usage for 3 times every second.


[root@dlp ~]# sar -B 1 3


Linux 2.6.32-358.6.2.el6.x86_64 (dlp.server.world)      06/25/2013      _x86_64_        (2 CPU)

03:13:12 PM  pgpgin/s pgpgout/s   fault/s  majflt/s  pgfree/s pgscank/s pgscand/s pgsteal/s    %vmeff
03:13:13 PM      0.00      0.00     80.00      0.00     65.00      0.00      0.00      0.00      0.00
03:13:14 PM      0.00      0.00     40.00      0.00     63.00      0.00      0.00      0.00      0.00
03:13:15 PM      0.00      0.00     32.00      0.00     63.00      0.00      0.00      0.00      0.00
Average:         0.00      0.00     50.67      0.00     63.67      0.00      0.00      0.00      0.00

It’s possible to output every CPU cores’ usage with “mpstat” command like follows.
[9] Output the current all CPU cores’ usage for 3 times every second.


[root@dlp ~]# mpstat -P ALL 1 3


Linux 2.6.32-358.6.2.el6.x86_64 (dlp.server.world)      06/25/2013      _x86_64_        (2 CPU)

03:55:12 PM  CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle
03:55:13 PM  all    0.00    0.00    0.00    0.00    0.50    0.00    0.00    0.00   99.50
03:55:13 PM    0    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00
03:55:13 PM    1    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00

03:55:13 PM  CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle
03:55:14 PM  all    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00
03:55:14 PM    0    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00
03:55:14 PM    1    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00

03:55:14 PM  CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle
03:55:15 PM  all    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00
03:55:15 PM    0    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00
03:55:15 PM    1    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00

Average:     CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle
Average:     all    0.00    0.00    0.00    0.00    0.17    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  100.00
Average:       1    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00

It’s possible to output disk I/O usage with “iostat” command like follows.
[10] Output the current I/O usage with Mega-bytes for 3 times every second.


[root@dlp ~]# iostat -mx 1 3


Linux 2.6.32-358.6.2.el6.x86_64 (dlp.server.world)      06/25/2013      _x86_64_        (2 CPU)

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0.01    0.00    0.03    0.08    0.00   99.87

Device:         rrqm/s   wrqm/s     r/s     w/s    rMB/s    wMB/s avgrq-sz avgqu-sz   await  svctm  %util
vda               0.38     0.15    0.67    0.10     0.01     0.00    29.46     0.03   41.78   4.44   0.35
dm-0              0.00     0.00    0.76    0.25     0.01     0.00    20.34     0.06   54.84   3.25   0.33
dm-1              0.00     0.00    0.08    0.00     0.00     0.00     8.00     0.00    1.05   0.53   0.00

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0.00    0.00    0.50    0.00    0.00   99.50

Device:         rrqm/s   wrqm/s     r/s     w/s    rMB/s    wMB/s avgrq-sz avgqu-sz   await  svctm  %util
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

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0.00    0.00    0.50    0.00    0.00   99.50

Device:         rrqm/s   wrqm/s     r/s     w/s    rMB/s    wMB/s avgrq-sz avgqu-sz   await  svctm  %util
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

It’s possible to output every CPU usage for processes with “pidstat” command like follows.
[11] Output the CPU usage for a process ID “1169” for 3 times every second.


[root@dlp ~]# pidstat -p 1169 1 3


Linux 2.6.32-358.6.2.el6.x86_64 (dlp.server.world)      06/25/2013      _x86_64_        (2 CPU)

04:09:09 PM       PID    %usr %system  %guest    %CPU   CPU  Command
04:09:10 PM      1169    0.00    0.00    0.00    0.00     1  bash
04:09:11 PM      1169    0.00    0.00    0.00    0.00     1  bash
04:09:12 PM      1169    0.00    0.00    0.00    0.00     1  bash
Average:         1169    0.00    0.00    0.00    0.00     -  bash