Monitor Linux Resources using SAR

Spread the love

Installing System Activity Reporter [SAR] on Linux

 

System Activity Reporter (SAR) is a tool for collecting, reporting, and tracking system activity. And keeping track of system activity, such as resource usage, performance, and so on and more on Linux systems. SAR is a component of the sysstat package. How to configure and use SAR on a Linux system is detailed below:

On systems running Debian or Ubuntu:

sudo apt-get update
sudo apt-get install sysstat

 

On systems running Red Hat/CentOS:
sudo yum install sysstat

 

Start the sar service and turn it on:
sudo systemctl start sysstat
sudo systemctl enable sysstat

 

SAR collects data on system activity at regular intervals and stores it in log records. By default, it collects data every 10 minutes. The data collection interval can be changed by editing the /etc/cron.d/sysstat file.
 
Examining SAR Data:
Following data collection, use the sar command to view system activity reports.
 

View the current day’s CPU utilization:

sar -u

 

To report on previously captured data – type:
sar -u -f filename > file

 

View disk i/o and transfer rate statistics:
sar -b 3 10

 

View the memory and swap space statistics:
sar -r 3 10

 

View stats on swapping:
sar -W 3 10

 

View network statistics:
sar -n DEV 3 10

 

View CPU statistics:
sar -P ALL 3 10

 

Report Creation:
Using the sar command, you can generate daily reports from the collected data. To create a CPU utilization report for yesterday, for example:
sar -u -f /var/log/sysstat/sa<YYMMDD>

 

Replace <YYMMDD> with the date for which you want the report to be generated. You can further customize SAR behavior by editing the configuration file /etc/sysconfig/sysstat (on Red Hat/CentOS) or /etc/default/sysstat (on Debian/Ubuntu).

 

See also  How To Fix Apache 403 Forbidden Error

SAR is an effective tool for tracking and analyzing system activity over time. It can assist you in diagnosing performance issues, tracking resource utilization, and making informed system management and optimization decisions.

Linuxguru

Leave a Comment