SAR command is collect and report system activity in the operating system, easily to get system status number of times spaced at the specified intervals in seconds.
Analysis of load values of different sub-system process like, CPU, Network interface, Memory Usage, Load and etc.
How to Install :
You want get these logs, install sysstat package in your system using yum command or apt-get.
Fedora / CentOS /Redhat
# yum install sysstat
Debain / Ubuntu
# sudo apt-get install sysstat
Configuration :
# cat /etc/sysconfig/sysstat
# How long to keep log files (in days).
# If value is greater than 28, then log files are kept in
# multiple directories, one for each month.
HISTORY=28
# Compress (using gzip or bzip2) sa and sar files older than (in days):
COMPRESSAFTER=31
By default set cron job for collect logs,
# cat /etc/cron.d/sysstat
# Run system activity accounting tool every 10 minutes
*/10 * * * * root /usr/lib64/sa/sa1 1 1
# Generate a daily summary of process accounting at 23:53
53 23 * * * root /usr/lib64/sa/sa2 -A
Command Reports:
Sysstat logs stores in /var/log/sa/ direcotry,
Displaying the CPU Load
The following command shows report CPU load average on 11 th of the current month,
# sar -P ALL -f /var/log/sa/sa11
08:40:01 IST CPU %user %nice %system %iowait %steal %idle
08:50:01 IST all 0.03 0.00 0.06 0.58 0.01 99.32
08:50:01 IST 0 0.03 0.00 0.06 0.58 0.01 99.32
Average: CPU %user %nice %system %iowait %steal %idle
Average: all 0.04 0.00 0.05 0.99 0.02 98.90
Average: 0 0.04 0.00 0.05 0.99 0.02 98.90
Displaying the RAM memory load
The following command shows RAM memory usage reports on current day,
# sar -r
Linux 2.6.32-71.29.1.el6.x86_64 (host.thelinuxfaq.com) Thursday 22 January 2015 _x86_64_ (1 CPU)
04:30:02 IST kbmemfree kbmemused %memused kbbuffers kbcached kbcommit %commit
05:31:05 IST 13684 1984888 99.32 2128 25460 6411100 105.19
05:42:13 IST 16808 1981764 99.16 2032 28568 7642764 125.40
06:24:03 IST 13716 1984856 99.31 2136 29068 8273452 135.75
06:50:54 IST 1076812 921760 46.12 12632 475708 890436 14.61
Average: 295721 1702851 85.20 117332 1088327 900681 14.78
Displaying Load average:
The following command shows report load average on current day,
# sar -q
04:30:02 IST runq-sz plist-sz ldavg-1 ldavg-5 ldavg-15
05:20:01 IST 3 131 0.70 0.81 0.80
05:31:05 IST 0 637 184.33 142.72 71.64
05:42:13 IST 0 867 360.59 275.42 170.43
06:24:03 IST 0 819 274.38 299.45 315.26
06:50:54 IST 4 166 6.52 2.43 0.87
Average: 3 144 7.70 6.82 5.43
Give interval time of 1 second and shows 3 reports,
# sar -q 1 3
Linux 3.13.0-37-generic (laks) Friday 30 January 2015 _x86_64_ (4 CPU)
11:33:25 IST runq-sz plist-sz ldavg-1 ldavg-5 ldavg-15 blocked
11:33:26 IST 0 473 0.15 0.28 0.29 0
11:33:27 IST 0 473 0.15 0.28 0.29 0
11:33:28 IST 1 473 0.14 0.27 0.29 0
Average: 0 473 0.15 0.28 0.29 0
Displaying Network Statistics :
The following command shows network values on current day, DEV -> eth0
# sar -n DEV
06:50:54 IST IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s
07:00:01 IST lo 3.79 3.79 0.48 0.48 0.00 0.00 0.00
07:00:01 IST eth0 55.12 29.81 5.47 57.30 0.00 0.00 0.00
07:10:01 IST lo 2.88 2.88 0.38 0.38 0.00 0.00 0.00
Average: lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
Average: eth0 0.00 0.00 0.00 0.00 0.00 0.00 0.00
Give interval time of 1 second and shows 2 reports,
# sar -n DEV 1 2
Linux 2.6.32-71.29.1.el6.x86_64 (host.thelinuxfaq.com) Friday 30 January 2015 _x86_64_ (1 CPU)
11:32:05 IST IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s
11:32:06 IST lo 3.19 3.19 0.25 0.25 0.00 0.00 0.00
11:32:06 IST eth0 12.77 2.66 1.69 0.96 0.00 0.00 0.00
11:32:06 IST IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s
11:32:07 IST lo 4.04 4.04 0.39 0.39 0.00 0.00 0.00
11:32:07 IST eth0 5.56 2.02 1.07 0.34 0.00 0.00 0.00
Average: IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s
Average: lo 3.63 3.63 0.32 0.32 0.00 0.00 0.00
Average: eth0 9.07 2.33 1.38 0.64 0.00 0.00 0.00
CPU Usage of Individual CPU or Core (sar -P)
Displaying I/O Transfer:
# sar -b
Linux 2.6.32-71.29.1.el6.x86_64 (host.thelinuxfaq.com) Thursday 22 January 2015 _x86_64_ (1 CPU)
04:30:02 IST tps rtps wtps bread/s bwrtn/s
05:20:01 IST 11.31 0.03 11.28 0.41 102.17
05:31:05 IST 121.52 57.23 64.30 2473.33 4040.15
05:42:13 IST 106.05 75.11 30.95 2774.17 1943.50
06:24:03 IST 95.98 60.98 35.00 2299.69 853.22
06:50:54 IST 100.00 100.00 100.00 100.00 100.00
07:00:01 IST 7.58 1.94 5.64 104.72 53.06
Average: 100.00 100.00 100.00 100.00 100.00
tps : This is specified to total number transfer per second, its an I/O request to a physical device. Multiple logcal request combined combined into a single I/O to the device.
rtps: This is specified to total number of read request per second shared to physical devices.
wtps: This si specified to Total number of write requests per second shared to physical devices.
bread/s : This is specified to total number of data read from the devices in block per second.
bwrtn/s : This is specified to total number of data written to device in block per second.
Displaying CPU utilization for each 2 seconds. 3 lines.
# sar -u 2 3
Linux 2.6.32-71.29.1.el6.x86_64 (host.thelinuxfaq.com) Friday 30 January 2015 _x86_64_ (1 CPU)
11:15:39 IST CPU %user %nice %system %iowait %steal %idle
11:15:41 IST all 1.28 0.00 1.53 2.56 0.00 94.63
11:15:43 IST all 4.61 0.00 2.71 0.00 0.00 92.68
11:15:45 IST all 0.00 0.00 0.25 4.03 0.00 95.72
Average: all 1.90 0.00 1.47 2.25 0.00 94.38
Displaying memory and network statistics:
The following command shows report of memory and networks on 29th
# sar -r -n DEV -f /var/log/sa/sa29
10:40:01 IST IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s
10:50:02 IST lo 0.10 0.10 0.02 0.02 0.00 0.00 0.00
10:50:02 IST eth0 13.70 0.09 0.65 0.02 0.00 0.00 0.00
11:00:01 IST lo 0.10 0.10 0.02 0.02 0.00 0.00 0.00
11:00:01 IST eth0 13.62 0.09 0.65 0.02 0.00 0.00 0.00
Average: lo 7.93 7.93 2.39 2.39 0.00 0.00 0.00
Average: eth0 15.84 1.94 1.09 1.05 0.00 0.00 0.00
Also can viewing report on current day,
Display context switch :
The following command shows report the total number of processes created per second, and total number of context switches,
# sar -w 1 3
Linux 3.13.0-37-generic (laks) Friday 30 January 2015 _x86_64_ (4 CPU)
11:32:08 IST proc/s cswch/s
11:32:09 IST 0.00 1211.00
11:32:10 IST 0.00 1217.00
11:32:11 IST 0.00 1218.00
Average: 0.00 1215.33
Displaying yesterday logs report:
The following command can help to views on yesterday report.
# sar -f /var/log/sa/sa$(date +%d -d yesterday)
Linux 2.6.18-164.2.1.el5xen (host.thelinuxfaq.com) 02/10/15
00:00:01 CPU %user %nice %system %iowait %steal %idle
00:10:01 all 25.42 0.00 41.81 13.92 3.59 15.27
00:20:01 all 28.26 0.00 52.86 4.16 4.93 9.79
00:30:01 all 26.89 0.00 41.00 6.33 3.56 22.22
00:40:01 all 27.00 0.00 34.05 6.11 2.85 30.00
If you want to save the statistics:
# sar -A > $(date +`hostname`-%d-%m-%y-%H%M.log)
To Print the Values at particular time.
# sar -f /var/log/sa/sa10 -s 23:00:00
Find Sar Version:
# sar -V
sysstat version 10.2.0
(C) Sebastien Godard (sysstat <at> orange.fr)
Comments (0)