Useful links:

The Linux Foundation
Linux Kernel Archives
Linux Kernel Mailing List
The Linux Documentation Project

Valid HTML 4.01 Transitional


 Some of the following notes come from the Linux From Scratch documentation.

 Introduction to sysstat

The sysstat package contains various utilities, common to many commercial Unixes, to monitor system performance and usage activity:
  • iostat(1) reports CPU statistics and input/output statistics for devices, partitions and network filesystems.
  • mpstat(1) reports individual or combined processor related statistics.
  • pidstat(1) reports statistics for Linux tasks (processes) : I/O, CPU, memory, etc.
  • tapestat(1) reports statistics for tape drives connected to the system.
  • cifsiostat(1) reports CIFS statistics.
  • sysstat(5) is just a manual page for sysstat configuration file, giving the meaning of environment variables used by sysstat commands.
Sysstat also contains tools you can schedule via cron or systemd to collect and historize performance and activity data:
  • sar(1) collects, reports and saves system activity information (CPU, memory, disks, interrupts, network interfaces, TTY, kernel tables,etc.)
  • sadc(8) is the system activity data collector, used as a backend for sar.
  • sa1(8) collects and stores binary data in the system activity daily data file. It is a front end to sadc designed to be run from cron or systemd.
  • sa2(8) writes a summarized daily activity report. It is a front end to sar designed to be run from cron or systemd.
  • sadf(1) displays data collected by sar in multiple formats (CSV, XML, JSON, etc.) and can be used for data exchange with other programs. This command can also be used to draw graphs for the various activities collected by sar using SVG (Scalable Vector Graphics) format.
Go to the Features page to display a list of sysstat's main features, and to the Matrix of activities to list all the possible activities for sar and corresponding options to use with sar and sadc.
And if you don't find here what you are looking for, try out Qwant , the new search engine that respects your privacy...!

Installation of sysstat:

Compile and install sysstat by running the following commands:

$ make
$ su
<enter root password>
make install
Note: With older versions of sysstat that don't support autoconf (up to v7.0.4), configuring sysstat was done with "make config" instead of "./configure".

Command explanations:
./configure: Runs the auto-configuration process. This script attempts to guess correct values for various system-dependent variables used during compilation.  It uses those values to create a "Makefile" in the current directory.
You can give "configure" values for configuration parameters. For example, you can set the installation directory with the "--prefix" parameter. The following example shows how to set the installation directory to /usr (instead of the default value /usr/local):

$ ./configure --prefix=/usr

Enter "./configure --help" to display all the available parameters.
Note: Instead of running "./configure", you can run "iconfig", the Interactive Configuration script. This is a front-end to "configure". It will prompt you for various parameters values used by "configure".

make: Compiles sysstat from sources. The various commands are then available.
make install: Installs sysstat binaries, and even create a crontab to start collecting data automatically if requested to do so at config stage.

Configuring sysstat:

Please read the file included in sysstat package or go to sysstat's public repository on GitHub to get more detailed and up-to-date information.

Cron information:
To begin gathering sysstat history information, you must add to, or create a privileged user's crontab. The default history data location is /var/log/sa. The user running sysstat utilities via cron must have write access to this location. 
Below is an example of what to install in the crontab "sysstat" located in /etc/cron.d directory and using Vixie cron syntax. Adjust the parameters to suit your needs. Use man sa1 and man sa2 for information about the commands.

# Run system activity accounting tool every 10 minutes
*/10 * * * * root /usr/lib/sa/sa1 1 1
# 0 * * * * root /usr/lib/sa/sa1 600 6 &
# Generate a daily summary of process accounting at 23:53
53 23 * * * root /usr/lib/sa/sa2 -A

Each day a file will be created in the /var/log/sa directory.

Startup script information:

At system startup, a LINUX RESTART message must be inserted in the daily data file to tell sar that the kernel counters have been reinitialized. Here is a sample sysstat bootscript used to accomplish this:

$ cat > /etc/rc.d/init.d/sysstat << "EOF"
# Begin $rc_base/init.d/sysstat

# Based on sysklogd script from LFS-3.1 and earlier.
# Rewritten by Gerard Beekmans  -

. /etc/sysconfig/rc
. $rc_functions

case "$1" in
                echo "Calling the system activity data collector (sadc)..."
                /usr/lib/sa/sadc -F -L -
                echo "Usage: $0 start"
               exit 1

# End $rc_base/init.d/sysstat
chmod 754 /etc/rc.d/init.d/sysstat

The sysstat bootscript only needs to run at system startup, therefore only one symlink is required. Create this symlink in /etc/rc.d/rcsysinit.d using the following command:

# ln -sf ../init.d/sysstat /etc/rc.d/rcsysinit.d/S85sysstat

If you are using systemd, then a service file is used instead of the bootscript and symlink above. Here is a sample service file (put it in your systemd service directory):

# /usr/lib/systemd/system/sysstat.service
# (C) 2012 Peter Schiffer (pschiffe <at>
# sysstat-10.1.7 systemd unit file:
#     Insert a dummy record in current daily data file.
#     This indicates that the counters have restarted from 0.

Description=Resets System Activity Logs

ExecStart=/usr/local/lib64/sa/sa1 --boot


Now the good news: The above crontab, startup script and link or systemd service file may be automatically created and installed for you when you enter "make install", providing that you have set configure's  option "--enable-install-cron" during configuration stage:

$ ./configure

If you prefer using the Interactive Configuration script (iconfig), answer 'y' (for "yes") at the question:
Set crontab to start sar automatically? (y/n) [--enable-install-cron]