How To Increase The Retention Of “sar” Data To ‘N’ Days in Linux

The system performance is constantly monitored by the sysstat tools. Performance logs are not retained for as long a time as desired. This post outlines steps to increase the retention of sar data to the desired number of days.

How To Change The Performance Log Retaining Period

Logs are kept for a period of days. Edit the file /etc/sysconfig/sysstat so that the HISTORY value indicates the desired number of days for keeping the performance logs:

$ cat etc/sysconfig/sysstat
# sysstat-9.0.4 configuration file.

# How long to keep log files (in days).
# 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=31

# Parameters for the system activity data collector (see sadc manual page)
# which are used for the generation of log files.
SADC_OPTIONS="-S DISK"

The setting becomes active immediately and will be used for automated sar daily processing.

How To Reduce Disk Space

The COMPRESSAFTER setting, as shown in the above code snippet, will automatically compress performance data older than a given number of days.

How To Collect Optional Performance Categories

In addition to the built-in performance statistics, the sysstat subsystem has a number of optional statistic stats which can be enabled. Please refer to the sadc (system activity data collector) manual page to see the current optional statistic sets available.

# man sadc
Related Post