[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Getting CPU load (from /proc/?)



cjw44@flatline.org.uk (Colin Watson) writes:

> You could try 'vmstat 1', which will poll every second. Ignoring the
> first line, which is an "up to the time vmstat was started" figure, the
> last field in each line is the percentage of time the CPU is idle.
> 
> I can't speak for how accurate it is, but it seems to be fairly
> reliable.
> 

Great, this does exactly what I want. I do a 
vmstat 10 2 | tail -1 | awk '{print $16}'
and put  my machine to  sleep if this  number is greater than  99 
(after checking the mouse and  kbd interrupts). With xmms streaming an
mp3, the idle number is never greater than 99 so I'm set. 
thanks,
chris



Reply to: