Sar: Difference between revisions

From HPCWIKI
Jump to navigation Jump to search
No edit summary
Line 2: Line 2:


sar stands for “System Activity Reporter” and provides a wide range of metrics related to system usage, including CPU utilization, memory usage, disk I/O, network activity.
sar stands for “System Activity Reporter” and provides a wide range of metrics related to system usage, including CPU utilization, memory usage, disk I/O, network activity.
on Ubuntu, sar can be installed by following<ref>https://stackoverflow.com/questions/45725414/cannot-open-var-log-sysstat-sa16-please-check-if-data-collecting-is-enabled-in</ref> <syntaxhighlight lang="bash">
on Ubuntu, sar can be installed by following<ref>https://stackoverflow.com/questions/45725414/cannot-open-var-log-sysstat-sa16-please-check-if-data-collecting-is-enabled-in</ref> <syntaxhighlight lang="bash">
#install sar
#install sar
Line 28: Line 26:


== Command and options ==
== Command and options ==
sar has a lot of arguments and options,
sar has a lot of arguments and options and basic comman syntax is following,
 
 
$ sar -[ options ] time_interval number_of_tines_to_display
 
$sar --help
 
 
Full description is available in sar man page<ref>https://linux.die.net/man/1/sar</ref>
 
 
Here are few examples,  
{| class="wikitable"
{| class="wikitable"
|+
|+

Revision as of 12:13, 7 December 2023

Monitoring server resources is a crucial part of identifying any bottlenecks and possible issues on your server.

sar stands for “System Activity Reporter” and provides a wide range of metrics related to system usage, including CPU utilization, memory usage, disk I/O, network activity.

on Ubuntu, sar can be installed by following[1]

#install sar
$ sudo apt-get install -y sysstat

# Enable data collecting
sed -i 's/false/true/g' /etc/default/sysstat

# Change the collection interval from every 10 minutes to every 2 minutes
sed -i 's/5-55\/10/*\/2/g' /etc/cron.d/sysstat

# Restart service
$ sudo systemctl start sysstat

sar system service

sar can be run as system service as well,

  1. sudo systemctl start sysstat
  2. sudo systemctl enable sysstat
  3. This will add the required cron jobs so that the system data is collected accordingly. The cron jobs will be added at cat /etc/cron.d/sysstat

Command and options

sar has a lot of arguments and options and basic comman syntax is following,


$ sar -[ options ] time_interval number_of_tines_to_display

$sar --help


Full description is available in sar man page[2]


Here are few examples,

Options Description output format
sar -u 2 30 -u for all CPU,

2 means that the sar command should run every 2 seconds

30 means that the command should be executed 30 times.

sar -r 2 30 -r for memory
sar -n DEV 4 -n for network interfaces,

4 means that the sar command should run every 2 seconds

sar -d -d command to view disk I/O statistics, including IOPS DEV       tps     rkB/s     wkB/s     dkB/s   areq-sz    aqu-sz     await     %util

tps is IOPS

References