Unfortunately, when you use the -f option in sar along with the interval and count, it does not return the average value for this interval (as you would expect). Instead, it always returns the first recorded value in the sar file
The only way around this is to use the -s option, which allows you to specify the start time of the sampling period. I have provided a perl script below that ends with a sar call, which is constructed in such a way as to return what you are looking for.
Hope this helps.
Peter Rhodes.
#!/usr/bin/perl $interval = 300; # seconds. $epoch = `date +%s`; $epoch -= $interval; $time = `date -d \@$epoch +%H:%M:00`; $dom = `date +%d`; chomp($time,$dom); system("sar -f /var/log/sysstat/sa$dom -B -s $time 300 1");
source share