Sar: Difference between revisions
Jump to navigation
Jump to search
(Created page with "Monitoring server resources is a crucial part of identifying any bottlenecks and possible issues on your server. The <code>sar</code> command allows you to capture the utilization of your resources like RAM, CPU, Disk I/O and etc on Ubuntu, sar can be installed by $sudo apt install sysstat == sar system service == sar can be run as system service # sudo systemctl start sysstat # sudo systemctl enable sysstat # This will add the required cron jobs so that the system...") |
|||
Line 1: | Line 1: | ||
Monitoring server resources is a crucial part of identifying any bottlenecks and possible issues on your server. | 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. | |||
$sudo apt install sysstat | |||
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 | |||
$ 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 | |||
</syntaxhighlight> | |||
== sar system service == | == sar system service == | ||
sar can be run as system service | sar can be run as system service as well, | ||
# sudo systemctl start sysstat | # sudo systemctl start sysstat | ||
Line 18: | Line 33: | ||
!Options | !Options | ||
!Description | !Description | ||
!output format | |||
|- | |- | ||
|<code>sar -u 2 30</code> | |<code>sar -u 2 30</code> | ||
| -u for all CPU, | | -u for all CPU, | ||
<code>2</code> means that the sar command should run every 2 seconds | <code>2</code> means that the sar command should run every 2 seconds | ||
<code>30</code> means that the command should be executed 30 times. | <code>30</code> means that the command should be executed 30 times. | ||
| | |||
|- | |- | ||
|<code>sar -r 2 30</code> | |<code>sar -r 2 30</code> | ||
| -r for memory | | -r for memory | ||
| | |||
|- | |- | ||
|sar -n DEV 4 | |sar -n DEV 4 | ||
| -n for network interfaces, | | -n for network interfaces, | ||
4 means that the sar command should run every 2 seconds | 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 == | == References == | ||
<references /> | <references /> |
Revision as of 12:06, 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,
- sudo systemctl start sysstat
- sudo systemctl enable sysstat
- 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,
Options | Description | output format |
---|---|---|
sar -u 2 30
|
-u for all CPU,
|
|
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 |