General
cancel
Showing results for 
Search instead for 
Did you mean: 

command to get CPU Utilization for RIGHT NOW?

SOLVED
Go to solution
Steve Post
Trusted Contributor

command to get CPU Utilization for RIGHT NOW?

I know I have sar running. I know I can run "sar -u" to get the CPU utilitization over the course of the day. But is there a command that tells me how busy the CPU is at RIGHT NOW instead of average over the last X minutes?

4 REPLIES
Michal Kapalka (mikap)
Honored Contributor

Re: command to get CPU Utilization for RIGHT NOW?

hi Steve,

you could use glance.

mikap
Patrick Wallek
Honored Contributor
Solution

Re: command to get CPU Utilization for RIGHT NOW?

'top' and 'glance' come to mind.
Steve Post
Trusted Contributor

Re: command to get CPU Utilization for RIGHT NOW?

ah. that's right. I forgot that top -f filename will give me the info.

top -f tmpfile
BUSY=`grep -E "^avg " file | sed 's/\%//g' | awk '// { print ( 100 - $6 ) }' `
echo "the CPU is ${BUSY}% busy."
rm tmpfile


Rick Garland
Honored Contributor

Re: command to get CPU Utilization for RIGHT NOW?

sar -uM 1 10

This will tell you what the per-CPU utilization is right now and for the next 10 seconds in 1 second intervals, providing an average for that 10 second time period as well.

Run the command and see the time stamps off to the left - those time stamps are RIGHT NOW.

If you are not using the timing parameters then yes, you will get average output from various times, but use those parameters and you will get you data in real time. In the above example, you are watching per-CPU utilization starting now and going forward for 10 seconds in 1 second intervals. The average provided at the completion of the command in for the last 10 seconds, the parameter that was used.

top and glance are just as good, no doubt, but don't leave out sar.