Installation and usage examples of SAR utility
Installation:
apt-get install sysstat
Enable:
vim /etc/default/sysstat:
ENABLED="true"
SAR CRON jobs:
vim /etc/cron.d/sysstat
To run via CRON every minute (default is 10 minutes):
# Activity reports every 10 minutes everyday
* * * * * root command -v debian-sa1 > /dev/null && debian-sa1 1 1
* * * * * root command -v debian-sa1 > /dev/null && debian-sa1 1 1
After changes need to restart the service:
service sysstat restart
Runtime (online) usage:
sar -u 1 3
Some keys:
-u CPU Usage of ALL CPUs
-q Reports run queue and load average
-r Memory Free and Used
-S Swap Space Used
-b Overall I/O Activities
-d Individual Block Device I/O Activities
-n Report network statistics
-u CPU Usage of ALL CPUs
-q Reports run queue and load average
-r Memory Free and Used
-S Swap Space Used
-b Overall I/O Activities
-d Individual Block Device I/O Activities
-n Report network statistics
Examples:
To view process creation statistics, enter:
To view I/O and transfer rate statistics, enter:
To view paging statistics, enter:
To view block device statistics, enter:
To view statistics for all interrupt statistics, enter:
To view device specific network statistics, enter:
To view CPU specific statistics, enter:
To view queue length and load averages statistics, enter:
To view memory and swap space utilization statistics, enter:
To view status of inode, file and other kernel tables statistics, enter:
To view system switching activity statistics, enter:
To view swapping statistics, enter:
To view statistics for a given process called Apache with PID # 3256, 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 # 3256, enter:
# sar -x 3256 3 10
CRON usage:
All gathered statistics to file:
sar -A > $(date +`hostname`-%d-%m-%y-%H%M.log)
Load average for certain period:
sar -f /var/log/sa/sa19 -q -s 19:00:00 -e 20:00:00
Graphic visualizer (ksar):
Download:
wget https://github.com/vlsi/ksar/releases/download/v5.2.3/ksar-5.2.3-all.jar