Contents
About
sysstat contains the following system performance tools:
- sar: collects and reports system activity information;
- iostat: reports CPU utilization and disk I/O statistics;
- tapestat: reports statistics for tapes connected to the system;
- mpstat: reports global and per-processor statistics;
- pidstat: reports statistics for Linux tasks (processes);
- sadf: displays data collected by sar in various formats;
- cifsiostat: reports I/O statistics for CIFS filesystems.
The statistics reported by sar deal with I/O transfer rates, paging activity, process-related activities, interrupts, network activity, memory and swap space utilization, CPU utilization, kernel activities and TTY statistics, among others. Both UP and SMP machines are fully supported.
Installation
apt-get install sysstat
Sar
Sar is set of tools that helps you to collect and report the system activity.
- sar collects, reports and saves system activity information (see below a list of metrics collected by sar).
- sadc is the system activity data collector, used as a backend for sar.
- sa1 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 writes a summarized daily activity report. It is a front end to sar designed to be run from cron or systemd.
- sadf 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.
You can schedule via cron or systemd to collect and historize performance and activity data on Debian. Default sampling interval is 10 minutes but this can be changed of course (it can be as small as 1 second).
Enable Sar
Technically is sar the program that collect the information but packagers decided to handle this through sysstat name.
Once you install sysstat package edit the file /etc/default/sysstat and change the string ENABLED="false" to ENABLED="true".
After execute the following commands:
systemctl start sysstat systemctl enable sysstat
You can check if sysstat or sar is running with the following command:
systemctl status sysstat
You can check if sar is storing the performance information on the following directory /var/log/sysstat, you will get a file with the format sa followed by a number that represents day of the month... for sample sa31.
Once the day is finished a process will convert that binary file to a text file that contains the information in a human readable form wit the name sar followed by a number that represents day of the month... for example sar30.
Tune Sar
Sar is configured by default to take the information every 10 minutes, that can be useful or not that can depends of the space on disk, granurality of the information of you want. You can change the frequency of the samples to a minimun of 1 minute.
You can check the frequency of the samples with the following command:
sar -q
Observe the first column, you will notice the sample interval.
To change the frequency on Debian 11 use the following command:
vim /etc/systemd/system/sysstat.service.wants/sysstat-collect.timer
Change the line:
[Timer] OnCalendar=*:00/10
To:
[Timer] OnCalendar=*:00/1
Reload systemctl daemon:
systemctl daemon-reload
Restart sysstat service:
systemctl restart sysstat
References
https://access.redhat.com/solutions/3511971 (requires user and pass, you can get one free developer account from RedHat developer site)
