On Feb 4, 2008 12:50 PM, James G. Sack (jim) <[EMAIL PROTECTED]> wrote:
> How many ways are there to get CPU idle-time percentages
>   (my examples not all from the same system, in case anyone cares)
>
> top -n1 | grep ^Cpu
> > Cpu(s):  3.0%us,  0.5%sy, 96.2%ni,  0.3%id,  0.0%wa,  0.0%hi,  0.0%si, 
> > 0.0%st
>
> iostat|grep -A1 avg-cpu
> > avg-cpu:  %user   %nice %system %iowait  %steal   %idle
> >            3.12   96.33    0.32    0.01    0.00    0.22
>
> vmstat 1 3
> > procs -----------memory---------- ---swap-- -----io---- --system-- 
> > -----cpu------
> >  r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id 
> > wa st
> >  0  0 397328 180788  21712 308620    4    6    36    34  116   59  9  5 85  
> > 1  0
> >  0  0 397328 180780  21720 308612    0    0     0    48 1017  178  8  1 91  
> > 0  0
> >  0  0 397328 180780  21720 308620    0    0     0     0 1076  602  8  0 92  
> > 0  0
>
> (if the sysstat service is running..)
> sar -P | egrep 'CPU|Average'
> > 09:50:02 AM     CPU     %user     %nice   %system   %iowait    %steal     
> > %idle
> > Average:        all      8.58      0.01      0.64      0.75      0.00     
> > 90.02
>
>
> I'm sure it can be done via ps, but I've sort-of given up on
> understanding what options control what for ps. :-(
>
>
> Then there are the GUI programs:
>
> System Monitor (gnome-system-monitor)
>   subtract: 100% system-usage, I guess
> gkrellm
>   subtract ..
>

I have a feeling that you need to read the numbers in /proc/stat at
two times and subtract corresponding values to get total elapsed time,
and time dedicated to each of user, system, nice, io, and whatever.
This is probably what top(1) does.  But I haven't looked at the source
for top in a long time.

Allegedly there is a package "systat" which can be used.  But
instantaneously I can't find it.

More news a few hours later, since I haven't sent this yet.  There is
a program packagfe "sysstat"
<http://pagesperso-orange.fr/sebastien.godard/> that does lots of
things.  One of its parts is mpstat(1) which gives reports like this:
(best viewed with constant width font)

[EMAIL PROTECTED] transfer]$ mpstat -P ALL
Linux 2.6.12-1.1378_FC3smp (delta)      02/04/08

20:11:39     CPU   %user   %nice    %sys %iowait    %irq   %soft
%steal   %idle    intr/s
20:11:39     all    2.49   48.30    0.86    1.15    0.08    0.20
0.00   46.91   1225.15
20:11:39       0    2.48   47.49    0.88    1.30    0.13    0.39
0.00   47.33    679.09
20:11:39       1    2.51   49.10    0.84    1.01    0.04    0.01
0.00   46.49    546.07

    carl
-- 
    carl lowenstein         marine physical lab     u.c. san diego
                                                 [EMAIL PROTECTED]


-- 
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-list

Reply via email to