Sar command generates the stats for CPU usage, RAM usage and load average of the server and stores them in a file at regular interval. By default, the command without an option displays CPU stats of the current day.
Download the latest version from sysstat download page.
tar xvfj sysstat-10.0.0.tar.bz2
# sar -V
sysstat version 7.0.2
(C) Sebastien Godard
Edit /etc/cron.d/sysstat, enter:
# vi /etc/cron.d/sysstat
Update it as follows to log all disk stats (the -d option force to log stats for each block device and the -I option force report statistics for all system interrupts)
# Run system activity accounting tool every 10 minutes
*/10 * * * * root /usr/lib64/sa/sa1 -I -d 1 1
# Generate a daily summary of process accounting at 23:53
53 23 * * * root /usr/local/lib/sa/sa2 -A
Save and close the file. Turn on the service, enter:
# chkconfig sysstat on
# service sysstat start
Edit /etc/sysconfig/sysstat file specify how long to keep log files in days.
# 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.
Usage sar -function
-a reports usage of file access system calls.
-b reports buffer cache usage and hit rate.
-c reports system calls.
-d report block device activity.
-g report paging activity (V.4 only)
-k report kernel memory allocation activity. (v.4 only)
-m report message and sephamore activity.
-p report paging activity.
-q report average queue length waiting for CPU.
-r report unused memory pages and disk blocks.
-u report CPU utilization.
-v report status of system tables.
-w report swapping and paging activity.
-x report RFS operation (V.4 only)
-y reports terminal activity.
-A reports all data (same as sar -udqbwcayvmprgkxSDC)
-C reports RFS buffer caching overhead.
-Db report buffer cache usage for RFS and local activity.
-Dc report system calls separately for RFS and local activity.
-Du report CPU utilization by RFS and local activity.
-S reports RFS server and request queue status.
3 = interval
10 = count
To view process creation statistics, enter:
# sar -c 3 10
To view I/O and transfer rate statistics, enter:
# sar -b 3 10
To view paging statistics, enter:
# sar -B 3 10
To view block device statistics, enter:
# sar -d 3 10
To view statistics for all interrupt statistics, enter:
# sar -I XALL 3 10
To view device specific network statistics, enter:
# sar -n DEV 3 10
# sar -n EDEV 3 10
To view CPU specific statistics, enter:
# sar -P ALL
# Only 1st CPU stats
# sar -P 1 3 10
To view queue length and load averages statistics, enter:
# sar -q 3 10
To view memory and swap space utilization statistics, enter:
# sar -r 3 10
# sar -R 3 10
To view status of inode, file and other kernel tables statistics, enter:
# sar -v 3 10
To view system switching activity statistics, enter:
# sar -w 3 10
To view swapping statistics, enter:
# sar -W 3 10
To view statistics for a given process called Apache with PID # 4252, enter:
# sar -x 4252 3 10