0

I am using sar utility for collecting and saving system activity information. After saving the information, I am seeing/reporting the information but the output is not matching. Can some one please help me in understanding the behavior or if I am doing a silly mistake in my understanding. Below are the details.

Step 1: To collect and save system activity

sar -o sa_30_dec_2012 1 > /dev/null 2>&1 & 

Step 2: To report first 10 minutes readings with an interval of 1 second

sar 1 10 -f sa_30_dec_2012 

Step 3: To report first 10 readings within an interval of 2 seconds

sar 2 5 -f sa_30_dec_2012 

Output of Step 2

07:18:34 IST CPU %user %nice %system %iowait %steal %idle 07:18:35 IST all 1.51 0.00 1.51 3.02 0.00 93.97 07:18:36 IST all 1.50 0.00 1.00 0.00 0.00 97.50 07:18:37 IST all 1.02 0.00 0.51 0.00 0.00 98.48 07:18:38 IST all 2.55 0.00 0.51 0.00 0.00 96.94 07:18:39 IST all 3.03 0.00 0.51 0.00 0.00 96.46 07:18:40 IST all 1.49 0.00 1.49 3.48 0.00 93.53 07:18:41 IST all 1.52 0.00 0.51 0.00 0.00 97.97 07:18:42 IST all 1.01 0.00 1.01 0.00 0.00 97.99 07:18:43 IST all 1.53 0.00 0.00 0.00 0.00 98.47 07:18:44 IST all 2.53 0.00 1.52 0.00 0.00 95.96 Average: all 1.77 0.00 0.86 0.66 0.00 96.72 

Output of Step 3

07:18:34 IST CPU %user %nice %system %iowait %steal %idle 07:18:36 IST all 1.50 0.00 1.25 1.50 0.00 95.74 07:18:38 IST all 1.78 0.00 0.51 0.00 0.00 97.71 07:18:40 IST all 2.26 0.00 1.00 1.75 0.00 94.99 07:18:42 IST all 1.26 0.00 0.76 0.00 0.00 97.98 07:18:44 IST all 2.03 0.00 0.76 0.00 0.00 97.21 Average: all 1.77 0.00 0.86 0.66 0.00 96.72 

If you observe, the readings for timestamp 07:18:36 match but the readings after that do not match (the values are not equal). For example, the values of the following timestamps are not equal:-

Step 2 output

07:18:38 IST all 2.55 0.00 0.51 0.00 0.00 96.94 07:18:40 IST all 1.49 0.00 1.49 3.48 0.00 93.53 

Step 3 output

07:18:38 IST all 1.78 0.00 0.51 0.00 0.00 97.71 07:18:40 IST all 2.26 0.00 1.00 1.75 0.00 94.99 

Why are the Step 2 and Step 3 outputs not matching?

These commands were executed on Ubuntu 12.04 LTS.

Any help is very much appreciated.

1 Answer 1

1

Since the interval is changed to 2 seconds, it averages the data for those two seconds. If we take two lines from the first output (two 1-second intervals):

07:18:34 IST CPU %user %nice %system %iowait %steal %idle ... 07:18:37 IST all 1.02 0.00 0.51 0.00 0.00 98.48 07:18:38 IST all 2.55 0.00 0.51 0.00 0.00 96.94 

%user (column 4) averages to 1.78 -> (1.02 + 2.55)/2=1.78. Same goes for all other columns.

07:18:38 IST all 1.78 0.00 0.51 0.00 0.00 97.71 
1
  • Oh, that is a nice observation. By sar <interval> <count> command, I was expecting that if I specify sar 2 5, it will display every alternate reading. Thank you very much. Commented Dec 30, 2012 at 18:00

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.