Thursday, 5 January 2017

Using sar to monitor activity counters with Fedora 25

sar allows you to view various different activity counters on your system, such as read and write speeds and memory information.

It is also a useful tool when troubleshooting potentially abnormal system performance since it provides you with a historical overview of average performance - rather than real time utilities such as iotop and htop.

Although on Fedora 25 you will need to install the sysstat package firstly:

sudo dnf install sysstat

On initial launch I received the following error message:

Cannot open /var/log/sa/sa05: No such file or directory
Please check if data collecting is enabled

It turns out that sysstat is not automatically enabled upon installation:

sudo systemctl enable sysstat
sudo systemctl start sysstat

Digging a little deeper we can find out when sysstat is invoked:

cat /etc/systemd/system/sysstat.service.wants/sysstat-collect.timer

# (C) 2014 Tomasz Torcz <>
# sysstat-11.3.5 systemd unit file:
#        Activates activity collector every 10 minutes

Description=Run system activity accounting tool every 10 minutes



We can see from the output that sysstat collects data from the activity counters every 10 minutes by default.

Now to retrieve disk statistics we can issue:

sar -d

Although unfortunately sar does not output the devices in an easily identifiable fashion e.g. using block device names - /dev/sda etc. Instead we get something like:

DEV       tps  rd_sec/s  wr_sec/s  avgrq-sz  avgqu-sz     await     svctm     %util
Average:     dev8-0    354.10      1.31   3504.20      9.90      1.46      4.12      2.78     98.29

To map the sar output to our disks / lvm volumes we issue:

ls -lL /dev/mapper /dev/sd*

brw-rw----. 1 root disk 8,  0 Jan  5 13:53 /dev/sda

The addition of the '-l' switch provides us with additional information, such as file and group owner, last time modified among others.

We want to pay particular attention to the 'size' column - which in this case is '8, 0' - hence indicating it is the /dev/sda block device.

sar -b will provide you with an overall overview of I/O rates:

15:00:00          tps      rtps      wtps   bread/s   bwrtn/s
15:10:00       231.64     21.99    209.65    218.40   3436.20

To get an overview of CPU performance we can issue:

sar -u

15:00:00        CPU     %user     %nice   %system   %iowait    %steal     %idle
15:10:00        all      2.47      0.01      0.61     13.69      0.00     83.21

and memory with:

sar -r

5:00:00    kbmemfree kbmemused  %memused kbbuffers  kbcached  kbcommit   %commit  kbactive   kbinact   kbdirty
15:10:00      9642072   6701572     41.00    247968   2134388  11042116     44.91   3313348   2980900      2632

sar can also be used to provide real-time statistics like follows (where a report is generated every 1 second 5 times:

sar -d 1 5


Post a Comment