kelsey hudson wrote:
> jim sack wrote:
>> Who's got more?
>
> snmp through the oids:
Hah! That sounds like a great tee-shirt slogan or bumper sticker. :-)
Wonder what the clueful % rankings would be?
>
> ssCpuRaw{User,System,Nice}.0
>
> I believe there's a ssCpuRawIdle.0 as well, but its easy enough to add
> those and subtract from nCPUs * 100.
>
> /proc/stat has these values. almost all the implementations take their
> data from /proc/stat for overall system usage; you can also get this if
> you traverse the /proc/$PID/ structure and eat the stat output from all
> processes.
>
> under /proc/stat the lines are as follows:
>
> id user nice system idle iowait irq softirq steal
>
> so under my system:
> cpu 7962966 15058995 16388089 1320628215 563366 93238 1379810 0
> cpu0 3706897 6831738 5723878 662197779 259599 39888 362236 0
> cpu1 4256068 8227257 10664210 658430435 303767 53350 1017573 0
> [snip]
>
> the first line is an aggregate, that is, the totals of all the CPUs in
> the system.
>
> The units above are in jiffies (whatever USER_HZ is set to in the
> kernel; this will typically be 10 ms or 1/100th of a second).
>
> user is the amount of time spent in user mode
> nice is the amount of time spent in user mode but niced down
> system is the amount of time spent in kernel mode
> idle is well, time spent doing nothing
> iowait is time spent blocking on I/O
> irq is time spent servicing hardware interrupts
> softirq is time spent servicing software interrupts (context switches)
> steal is the amount of ticks "stolen" from this kernel by other VMs that
> may be running on the same host -- a high steal is a good sign that your
> hardware is oversubscribed. systems which are not virtualized won't
> increment this number (but i digress)
>
> to make use of this information, poll on /proc/stat every n seconds.
> take the current value and subtract from it the previous value, and you
> have the delta. divide this by n seconds times USER_HZ (typically 100,
> but being careful not to ?DIV/0!) and you have an average percentage of
> CPU utilization in each time slice. viola, wasn't that easy?
>..
OK, I'll put this on my to-look-at list -- for when I want to get a bit
more serious about it. Use snmp if doing snmp-like things (duh!, ok).
>..
Thanks,
..jim
--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-list