linuxsar

How to get second-level output from sar when used with -f option?


sar man page says that one can specify the resolution in seconds for its output.
However, I am not able to get a second level resolution by the following command.

sar -i 1 -f /var/log/sa/sa18

11:00:01 AM     CPU     %user     %nice   %system   %iowait    %steal     %idle
11:10:01 AM     all      0.04      0.00      0.04      0.00      0.01     99.91
11:20:01 AM     all      0.04      0.00      0.04      0.00      0.00     99.92
11:30:01 AM     all      0.04      0.00      0.04      0.00      0.00     99.92

Following command too does not give second level resolution:

sar  -f /var/log/sa/sa18 1

I am able to get second-level result only if I do not specify the -f option:

sar 1 10
08:34:31 PM     CPU     %user     %nice   %system   %iowait    %steal     %idle
08:34:32 PM     all      0.12      0.00      0.00      0.00      0.00     99.88
08:34:33 PM     all      0.00      0.00      0.12      0.00      0.00     99.88
08:34:34 PM     all      0.00      0.00      0.12      0.00      0.00     99.88

But I want to see system performance varying by second for some past day.

How do I get sar to print second-level output with the -f option?

Linux version: Linux 2.6.32-642.el6.x86_64
sar version : sysstat version 9.0.4


Solution

  • I think the exist sar report file 'sa18' collected with an interval 10 mins. So we don't get the output in seconds.

    Please check the /etc/cron.d/sysstat file.

    [root@testserver ~]# cat /etc/cron.d/sysstat
     #run system activity accounting tool every 10 minutes
    */10 * * * * root /usr/lib64/sa/sa1 1 1
     #generate a daily summary of process accounting at 23:53
    53 23 * * * root /usr/lib64/sa/sa2 -A
    

    If you want to reduce the sar interval interval you can modify the sysstat file.