Question Regarding sar
Hi,
I have a question for sar command.
When I execute "sar 300 10", cpu usage information is shown with 300 seconds interval, and 10 times.
As I know this shows CPU usage information in snapshot with 300 seconds interval, it is not averaged.
For example, I execute "sar 300 3" at 01:00:00.
And I assume actual cpu usage (usr) like the followings.
01:00:00, 1%
01:00:05 ~ 01:04:55, average 50%
01:05:00, 1%
But sar picks up the usage at 01:00:00 and 01:05:00, so it will tell you CPU usr mode usage is 1%.
Am I wrong?
But if this is right, the following sa1 command of crontab has same problem with the above sar example, it'sjust snapshot per 5 minutes interval.
It is not averaged data in 5 minutes, it does not consider the peak time usage and minimum usage.
0,5,10,15,20,25,30,35,40,45,50,55 * * * 0-6 /usr/lib/sa/sa1
I want to get the average value during polling interval.
Would you let me know the solution to accomplish this?
And one more question.
Would you let me know whichi system call is used when sar is executed?
Thanks!
A. H.
[1170 byte] By [
appleeye] at [2007-11-25 23:19:36]

# 1
Your thinking too hard about this.
SAR reads data from KSTAT. All SAR is doing is reading the CPU statistics, waits 5 minutes, reads them again, computes the CPU utilization for that 5 minute interval, and displays it. That's it.Nothing magical about it. Your 30-second, 1-minute, 2-minute, etc statistics will probably be very different.
Say the CPU could provide 10000 clock cycles per minute or 5000 every 30 seconds. Let's say you run a "sar 30 10". The utilization might look something like this:
Minute AvailUSED Utilization
00:00 -- -
00:30 5000200040%
01:00 5000501%
01:30 5000150030%
02:00 5000400080%
02:30 50001002%
03:00 50001002%
03:30 50001002%
04:00 5000300060%
04:30 5000300060%
05:00 5000102%
Now say you ran another SAR during the same period for the full 5 minutes:
Minute AvailUSED Utilization
00:00 -- -
05:0050000 13860 0.2772 ~ 28%
That's what your sar is basically doing and there is nothing wrong with that number. That IS the 5 minute CPU utilization - this is NOT an average. Now take all the 30 second utilization number and compute the 5 minute AVERAGE from them: you'll get something like 27.9%.
Sar simple performs a read() to gets the statistics from kstat.