in reply to Finding out Processor Usage
use warnings; use strict; use Inline "C"; my $one_minute_avg = one_minute_avg(); printf "Load avg: $one_minute_avg\n"; __END__ __C__ #include <sys/sysinfo.h> long one_minute_avg() { struct sysinfo si; if(sysinfo(&si) == 0) { return si.loads[0]; } else { return -1L; } }
For the XS version and some more info (provided you don't mind it's in German), check out this article. The numbers returned are longs, not sure how they relate to what uptime is returning.
Oh, and the /proc/loadavg pseudo file shows the load average on Linux also, as in
0.63 0.65 0.79 1/112 6661
|
|---|