sar
sar (System Activity Report, man) is a system utility command used to collect and report different metrics such us system load, CPU activity, memory (sar -r), paging (sar -B), swap (sar -S), disk (sar -d), device load and network. It is extremely useful in analyzing current and recent recorded system performance. Most Linux distributions provide sar utility binary in the sysstat package. You will also find sar in Solaris, AIX, HP-UX but not in MacOs or FreeBSD.
Contents
Sar installation[edit]
Binaries[edit]
/usr/bin/sadc- System Activity Data Collector, a backend to the sar command. Writes binary log of kernel data to the/var/log/sa/saXXfile, where the XX parameter indicates the current day/usr/bin/sadf- System Activity Data Formatter. Display data collected by sar in multiple formats./usr/bin/sar.sysstat-- (sar is a symbolink link to this binary)
Configuration files[edit]
/etc/default/sysstat/etc/cron.d/sysstat(Collection interval defined in cron configuration)/etc/sysstat/sysstat(SADC_OPTIONS)/etc/sysstat/sysstat.ioconf- Data directory:
/var/log/sysstat/
- Data directory:
Activation in Debian[edit]
- To start collection data modify file
/etc/default/sysstat, changing textdisabledbyenabled:vi /etc/default/sysstat service sysstat restart(sysstat written with two "ss" do not misspell with systat with just one "s")
Modifying number of days to keep and some other options are done in /etc/sysstat/sysstat file. By default Debian collect files for HISTORY=7 7 days.
Configuration in Debian/Ubuntu[edit]
Main Configuration file: /etc/sysstat/sysstat[edit]
/etc/sysstat/sysstat Everything configured in this file, including data collection (sadc) options, except collection interval configured in crontab: /etc/cron.d/sysstat
/etc/sysstat/sysstat HISTORY=7 COMPRESSAFTER=10 SADC_OPTIONS="-S XALL" SA_DIR=/var/log/sysstat ZIP="bzip2"
By default configuration SADC_OPTIONs is configure to SADC_OPTIONS="-S DISK" you can change SADC_OPTIONS default option to collect all data:
SADC_OPTIONS from -S DISK to -S XALL. See man sadc for more options: { DISK | INT | IPV6 | POWER | SNMP | XDISK | ALL | XALL [,...] }.
Collection interval configuration[edit]
Usage[edit]
System activity collection is provided by 4 programs, two binaries sar,sadc and two shell scriptssa1sa2.
Binaries
/usr/bin/sar-- reporting utility -- it is a link to /usr/bin/sar.sysstat/usr/lib64/sa/sadc-- System activity data collector binary, a backend to the sar command. Writes binary log of kernel data to the /var/log/sa/sadd file, where the dd parameter indicates the current day
Shell scripts
/usr/lib64/sa/sa1or/usr/lib/sysstat/sa1Collect and store binary data/usr/lib64/sa/sa2Create a report
Basic Usage[edit]
- Displays collected system activity, execute
sar, you will have to wait some time, depending on your configuration, for getting collected information:
Disk, filesystems
sar -dTo report disk activity. See alsoiostat -x.sar -FTo report filesystems statistics, disk and inodes usage. Requires sadc option in/etc/sysstat/sysstat-S XDISKor-S XALLactivated.
sar -n ALLTo show network data collected
power management
sar -m ALLTo show power management data collected including cpu temperature (Requiressensors/lm-sensorsutility to be installed)
sar -I ALL
systemctl status sysstatsystemctl restart sysstat
Activities[edit]
- Install and configure sar to record system activity every 5 minutes
- Read sysstat changelog: https://github.com/sysstat/sysstat/blob/master/CHANGES
- Read data from day 07 to day 11:
echo /var/log/sysstat/sa{07..11} | xargs -n1 sar -f - Read all sar collected files:
for SA_FILE in $(ls -1 /var/log/sysstat/sa??); do sar -f $SA_FILE; done - sar troubleshooting
- Change Collection interval configuration
Related[edit]
See also[edit]
- IO performance:
iotop, iostat, sar -d, fio, nmon, vmstat -d,dd,nmon,stress sar, installation, sar -A,sar -F, sar -d,sar -I ALL,sar -n NFS,sar -r,sar -S,sar -W,sar -n ALL, Installing sysstat using Ansible,/etc/sysstat/sysstat,/etc/cron.d/sysstat,sar --help, Sysstat changelog,/var/log/sysstat/,cpu time steal, sargraph, isag, Telegraf- systat FreeBSD[1] or NetBSD commands.
- Performance: sysstat,
sar,sadc,debian-sa1,sa1, sa2,iostat,nfsiostatmpstat,changelog,/usr/lib/sysstat/sadc,/etc/sysstat/sysstat,pidstat, irqstat - Metric colletion tools:
prometheus-node-exporter,metricbeat,sysstat,zabbix_agent,Icingabeat, Telegraf, AWS CloudWatch agent
Text is available under the Creative Commons Attribution-ShareAlike License; additional terms may apply. By using this site, you agree to the Terms of Use and Privacy Policy.
Original source: https://en.wikiversity.org/wiki/Linux_server_administration/sar
Advertising: