1836303 Members
1797 Online
110099 Solutions
New Discussion

sar -M & top command

 
SOLVED
Go to solution
Mariko.N
New Member

sar -M & top command

Hello!

I'd like to know difference between 'top' & 'sar -M' command.

When I execute 'top' & 'sar -M 1 1' simultaneously to check CPU status, the results seem something different.
(top: USER SYS IDLE, sar: %usr %sys %idle)

I'd like to know the reason why.
Thank you.

Mariko
4 REPLIES 4
Mark Grant
Honored Contributor

Re: sar -M & top command

Possibly down to the sampling time of the two tools. If you run "sar -M 1 5", presuming "top" is sampling every five seconds (the default) then I would think the results would be more similar. Remember, the figures are an average over the time period.
Never preceed any demonstration with anything more predictive than "watch this"
Simon Hargrave
Honored Contributor
Solution

Re: sar -M & top command

try sar -M 5 100

top, by default, is taking a sample over 5 seconds, so your sar over 1 second is effectively looking at a smaller set of data. If you sar based on 5 seconds (or run top with -s to set a different sample rate), you'll probably have similar results.

You'll probably only get "very similar" values if you start sam at the same time as top, to ensure they're sampling the same 5 seconds, too.
Sanjay Kumar Suri
Honored Contributor

Re: sar -M & top command

man top

Set the delay between screen updates to time seconds. The default delay between updates is 5 seconds

If you use following command:

sar -M 5 5

then the output from sar & top may match.

sks
A rigid mind is very sure, but often wrong. A flexible mind is generally unsure, but often right.
Mark Grant
Honored Contributor

Re: sar -M & top command

woops, I did get my "sar" arguments the wrong way around didn' I! I keep doing that. Shoud, of course, be "sar -M 5 1" though porbably best to change that "1" for a higher figure for more accurate results.
Never preceed any demonstration with anything more predictive than "watch this"