Subject: Re: CPU states
To: Jukka Salmi <j+nbsd@2006.salmi.ch>
From: Johnny Billquist <bqt@update.uu.se>
List: netbsd-users
Date: 04/06/2006 00:15:33
Note that top does a delta for each sample.
Ie, it calculates the differences in each category to the previous 
sample, and does the calculations based on that.
Otherwise you get the total since boot.

	Johnny

Jukka Salmi wrote:
> Petar Bogdanovic --> netbsd-users (2006-04-05 22:31:34 +0200):
> 
>>Hi,
>>
>>is there another way then top(1) to get the following line?
>>
>>*****************************************************
>>CPU states: 1.0% user, 3.9% nice, 5.9% system, 28.4% interrupt, 60.8% idle
>>*****************************************************
> 
> 
> Hmm, maybe like this:
> 
> $ sysctl -n kern.cp_time | awk -F'[, ]' '{u=$3;n=$7;s=$11;i=$15;j=$19;}END{t=u+n+s+i+j;printf "CPU states: %.1f%% user, %.1f%% nice, %.1f%% system, %.1f%% interrupt, %.1f%% idle\n",100*u/t,100*n/t,100*s/t,100*i/t,100*j/t;}'
> CPU states: 3.2% user, 0.0% nice, 1.5% system, 1.8% interrupt, 93.5% idle
> 
> ;-)
> 
> 
> HTH, Jukka
> 

-- 
Johnny Billquist                  || "I'm on a bus
                                   ||  on a psychedelic trip
email: bqt@update.uu.se           ||  Reading murder books
pdp is alive!                     ||  tryin' to stay hip" - B. Idol