Linux server administration/sar

sar (System Activity Report) is a system utility command used to collect and report different metrics such us system load, CPU activity, memory, paging , swap , 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  package. You will also find sar in Solaris, AIX, HP-UX but not in MacOs or FreeBSD.

Installation
One line command for installation and basic configuration for collecting :
 * Debian/Ubuntu:
 * Optionally modify collection interval in:
 * Optionally modify collection options in (SADC_OPTIONS="-S XALL"):
 * Optionally modify collection options in (SADC_OPTIONS="-S XALL"):


 * Redhat/Oracle Linux/AWS AMI:

Installing sar Debian, you have to install sysstat package that includes sar and some other performance tools: /usr/bin/sadc - System Activity Data Collector, a backend to the sar command. Writes binary log of kernel data to the /var/log/sa/saXX file, 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) /usr/bin/cifsiostat /usr/bin/iostat /usr/bin/mpstat /usr/bin/pidstat /usr/bin/tapestat
 * Checking installation:
 * Binaries installed in /usr/bin/ directory: . Sysstat package contains sar and some other utilities.
 * /Installing sysstat using Ansible/
 * /Installing sysstat using Ansible/

Debian/Ubuntu:
 * Config files:
 * // Collection interval defined in cron configuration
 * Data directory:
 * Data directory:
 * Data directory:
 * Data directory:

RedHat cat /etc/sysconfig/sysstat cat /etc/cron.d/sysstat

Activation in Debian

 * To start collection data modify file, changing text   by  :
 * (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  file. By default Debian collect files for  7 days.

Main Configuration file: /etc/sysstat/sysstat
Everything configured in this file, including data collection (sadc) options, except collection interval configured in crontab: /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  you can change SADC_OPTIONS default option to collect all data: . See  for more options: { DISK | INT | IPV6 | POWER | SNMP | XDISK | ALL | XALL [,...] }.

Collection interval configuration
To change for every 10 minutes to every 2 minutes or every minute, modify cron job in file: 5-55/10 * * * * root command -v debian-sa1 > /dev/null && debian-sa1 1 1 Every 2 minutes Every minute
 * /2 * * * * root command -v debian-sa1 > /dev/null && debian-sa1 1 1
 * * * * * root command -v debian-sa1 > /dev/null && debian-sa1 1 1

Usage
System activity collection is provided by 4 programs, two binaries,   and two shell scripts.

Binaries
 * -- reporting utility -- it is a link to /usr/bin/sar.sysstat
 * -- 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

Scripts

Basic Usage

 * Displays collected system activity, execute, you will have to wait some time, depending on your configuration, for getting collected information:
 * Report all collected date
 * Report all collected date

Memory

Disk
 * To report disk activity. See also.
 * To report disk and inodes usage. Requires sadc option in  -S XDISK or -S XALL activated.

network
 * To show network data collected

power management
 * To show power management data collected including cpu temperature (Requires  utility to be installed)

Activities

 * 1) Install and configure sar to record system activity every 5 minutes
 * 2) Read /sysstat changelog/: https://github.com/sysstat/sysstat/blob/master/CHANGES