Collect, Save and Report Linux System Activity Information

Gaurav Kar
2 min readJul 19, 2020
Photo by Austin Distel on Unsplash

SAR

The SAR command reports content of selected activity counters in the Linux System which are collected using sysstat over a period of time. You can select information about specific system activities using flags.The data can be redirected to an outfile which can be interrogated later.

Are you using a large SQL query and at the same time running your backup? Well we can report on the performance using the below commands.

CPU & Disk Performance:

We can run the below command to report on our CPU utilisation every 10 minutes.

[root@server ~]# sar -u
01:30:01 PM CPU %user %nice %system %iowait %steal %idle
01:40:01 PM all 0.11 0.00 0.09 0.00 0.02 99.78
01:50:02 PM all 0.10 0.00 0.09 0.00 0.02 99.79
Average: all 0.11 0.00 0.09 0.00 0.02 99.78
01:51:22 PM LINUX RESTART02:00:01 PM CPU %user %nice %system %iowait %steal %idle
02:10:01 PM all 0.12 0.00 0.10 0.00 0.02 99.77
02:20:01 PM all 0.11 0.00 0.09 0.00 0.02 99.78
02:30:01 PM all 0.12 0.00 0.11 0.04 0.02 99.72
02:40:01 PM all 0.12 0.00 0.09 0.00 0.02 99.77

Average: all 0.12 0.00 0.09 0.01 0.02 99.76

We can also use the -b flag to report on disk utilisation.

Report on Network Activity

Do you want to see statistics from your network devices? For e.g. lets report data on our network interface cards. I only have one NIC on my Centos 7.

[root@server~]# sar -n DEV
01:30:01 PM IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s
01:40:01 PM ens5 1.96 2.00 0.46 0.35 0.00 0.00
01:40:01 PM lo 0.00 0.00 0.00 0.00 0.00 0.00
01:50:02 PM ens5 1.93 1.96 0.45 0.35 0.00 0.00

How about printing data for a specific time period?

Lets filter the output based on timestamp and also pull up information from a particular log file by adding the file name as an argument to the sar command.

[root@server~]# sar -s 14:00:00 -e 15:00:00 /var/log/sa/sa15

--

--