Installation

_$: apt-get install sysstat

Configuration

/etc/default/sysstat:
---------------------
#
# Default settings for /etc/init.d/sysstat, /etc/cron.d/sysstat
# and /etc/cron.daily/sysstat files
#

# Should sadc collect system activity informations? Valid values
# are "true" and "false". Please do not put other values, they
# will be overwritten by debconf!
ENABLED="true"      <===

# Additional options passed to sa1 by /etc/init.d/sysstat
# and /etc/cron.d/sysstat
# By default contains the `-S DISK' option responsible for
# generating disk statisitcs.
SA1_OPTIONS="-S DISK"
### To monitor disk and temperature
### SA1_OPTIONS="-S DISK -S POWER"

# Additional options passed to sa2 by /etc/cron.daily/sysstat.
SA2_OPTIONS=""
/etc/sysstat/sysstat:
---------------------
# sysstat configuration file.

# How long to keep log files (in days).
# Used by sa2(8) script
# If value is greater than 28, then log files are kept in
# multiple directories, one for each month.
HISTORY=28              <===

# Compress (using gzip or bzip2) sa and sar files older than (in days):
COMPRESSAFTER=14        <===

# Parameters for the system activity data collector (see sadc manual page)
# which are used for the generation of log files.
SADC_OPTIONS=""
_$: service sysstat start

Check

Let’s say that we are on day 9 of this month.

_$: cd /var/log/sysstat
_$: ls -l
total 4
-rw-r--r-- 1 root root 656 May  9 18:20 sa09
_$: sar -u 2 5
Linux 3.5.0-49-generic (dceresuela-nix) 	05/09/2014 	_x86_64_	(8 CPU)

06:25:48 PM     CPU     %user     %nice   %system   %iowait    %steal     %idle
06:25:50 PM     all      0.00      0.00      0.25      0.00      0.00     99.75
06:25:52 PM     all      0.25      0.00      0.00      0.00      0.00     99.75
06:25:54 PM     all      0.00      0.00      0.25      0.00      0.00     99.75
06:25:56 PM     all      0.25      0.00      0.25      0.00      0.00     99.50
06:25:58 PM     all      0.25      0.00      0.00      0.00      0.00     99.75
Average:        all      0.15      0.00      0.15      0.00      0.00     99.70

The average time between samples are 10 minutes, so after at least 10 minutes have passed, we can check the data collected:

_$: sar -u
Linux 3.5.0-49-generic (dceresuela-nix) 	05/09/2014 	_x86_64_	(8 CPU)

09:02:19 AM       LINUX RESTART

09:05:01 AM     CPU     %user     %nice   %system   %iowait    %steal     %idle
09:15:01 AM     all      0.81      0.00      0.31      0.38      0.00     98.51
09:25:01 AM     all      0.50      0.00      0.27      0.22      0.00     99.01
09:35:01 AM     all      0.62      0.00      0.36      0.20      0.00     98.82
09:45:01 AM     all      1.16      0.00      0.50      0.23      0.00     98.11
09:55:01 AM     all      0.53      0.00      0.29      0.19      0.00     98.99
10:05:01 AM     all      0.33      0.00      0.21      0.08      0.00     99.38
10:15:01 AM     all      0.33      0.00      0.21      0.10      0.00     99.36
10:25:01 AM     all      0.43      0.00      0.26      0.15      0.00     99.16
10:35:01 AM     all      0.75      0.00      0.47      0.15      0.00     98.62
10:45:01 AM     all      0.67      0.00      0.35      0.18      0.00     98.80
10:55:01 AM     all      0.58      0.00      0.32      0.15      0.00     98.94
11:05:01 AM     all      0.87      0.00      0.39      0.19      0.00     98.56
11:15:01 AM     all      0.53      0.00      0.31      0.20      0.00     98.96
11:25:01 AM     all      0.96      0.00      0.46      0.20      0.00     98.38
_$: sar -s 09:10:00 -e 10:10:00
Linux 3.8.0-29-generic (tux) 	05/09/2014 	_x86_64_	(4 CPU)

09:15:01 AM     CPU     %user     %nice   %system   %iowait    %steal     %idle
09:25:01 AM     all      0.58      0.00      1.89      0.49      0.00     97.04
09:35:01 AM     all      0.57      0.00      2.08      0.48      0.00     96.87
09:45:01 AM     all      0.57      0.00      1.95      0.46      0.00     97.02
09:55:01 AM     all      0.57      0.00      2.01      0.54      0.00     96.88
10:05:01 AM     all      0.57      0.00      2.09      0.55      0.00     96.79
Average:        all      0.57      0.00      2.00      0.50      0.00     96.92
_$: sar -m TEMP 2 5
Linux 3.8.0-29-generic (hal) 	06/18/2014 	_x86_64_	(2 CPU)

12:29:20 PM    TEMP      degC     %temp               DEVICE
12:29:22 PM       1     36.00     46.15    coretemp-isa-0000
12:29:22 PM       2     40.00     51.28    coretemp-isa-0000

12:29:22 PM    TEMP      degC     %temp               DEVICE
12:29:24 PM       1     36.00     46.15    coretemp-isa-0000
12:29:24 PM       2     40.00     51.28    coretemp-isa-0000

12:29:24 PM    TEMP      degC     %temp               DEVICE
12:29:26 PM       1     36.00     46.15    coretemp-isa-0000
12:29:26 PM       2     40.00     51.28    coretemp-isa-0000

12:29:26 PM    TEMP      degC     %temp               DEVICE
12:29:28 PM       1     36.00     46.15    coretemp-isa-0000
12:29:28 PM       2     40.00     51.28    coretemp-isa-0000

12:29:28 PM    TEMP      degC     %temp               DEVICE
12:29:30 PM       1     36.00     46.15    coretemp-isa-0000
12:29:30 PM       2     40.00     51.28    coretemp-isa-0000

Average:       TEMP      degC     %temp               DEVICE
Average:          1     36.00     46.15    coretemp-isa-0000
Average:          2     40.00     51.28    coretemp-isa-0000
_$: sar -n DEV -s 10:00:00 -e 13:15:00 | grep -E "IFACE|[^\.]wlan0"
10:05:01 AM     IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s
10:15:01 AM     wlan0     28.78     63.37      2.18     92.85      0.00      0.00      0.00
10:25:01 AM     wlan0      3.86      5.43      0.33      6.90      0.00      0.00      0.00
10:35:01 AM     wlan0      8.68     21.52      0.88     29.77      0.00      0.00      0.00
10:45:01 AM     wlan0      3.10      2.79      0.47      2.04      0.00      0.00      0.00
10:55:01 AM     wlan0      0.51      0.43      0.06      0.07      0.00      0.00      0.00
11:05:01 AM     wlan0      0.68      0.57      0.13      0.12      0.00      0.00      0.00
11:15:01 AM     wlan0      1.14      0.93      0.20      0.39      0.00      0.00      0.00
11:25:01 AM     wlan0      0.62      0.49      0.09      0.14      0.00      0.00      0.00
11:35:01 AM     wlan0      3.16      3.65      0.48      3.44      0.00      0.00      0.00
11:45:01 AM     wlan0      0.78      1.26      0.12      0.58      0.00      0.00      0.00
11:55:01 AM     wlan0      1.15      1.03      0.20      0.40      0.00      0.00      0.00
12:05:01 PM     wlan0      1.02      0.87      0.14      0.28      0.00      0.00      0.00
12:15:01 PM     wlan0      0.65      0.62      0.12      0.23      0.00      0.00      0.00
12:25:01 PM     wlan0      0.61      0.50      0.07      0.19      0.00      0.00      0.00
12:35:01 PM     wlan0      4.12      3.72      0.50      0.62      0.00      0.00      0.00
12:45:01 PM     wlan0      2.89      2.52      0.51      0.42      0.00      0.00      0.00
12:55:01 PM     wlan0      3.89      3.22      0.79      0.69      0.00      0.00      0.00
Average:        wlan0      3.86      6.64      0.43      8.18      0.00      0.00      0.00

Log files

The logs are saved, in Ubuntu, in /var/log/sysstat. There are two types of log files:

  • saXX files : Logs in binary format. Use sar to read them.
  • sarXX files : Logs in plain text. Use less or cat to read them.