Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: How to Monitor System Resources

by sflitman (Hermit)
on Oct 26, 2008 at 04:07 UTC ( #719606=note: print w/ replies, xml ) Need Help??


in reply to How to Monitor System Resources

Check out Sys::Info, it's a great little module and it is cross-platform. This code is directly from the POD documentation, except the call to $info->device requires just 'CPU', not CPU => %options.

use strict; use Sys::Info; use Sys::Info::Constants qw( :device_cpu ); my $info = Sys::Info->new; my $cpu = $info->device('CPU'); printf "CPU: %s\n", scalar($cpu->identify) || 'N/A'; printf "CPU speed is %s MHz\n", $cpu->speed || 'N/A'; printf "There are %d CPUs\n" , $cpu->count || 1; printf "CPU load: %s\n" , $cpu->load || 0; exit;
This prints on my linux box:
CPU: 2 x Intel(R) Pentium(R) 4 CPU 2.80GHz CPU speed is 2801.015 MHz There are 2 CPUs CPU load: 0.21
It should run on my windows box, but I found out with ActivePerl 5,the latest version was 0.51 as PPMs tend to lag, and I'm not sure how to install a module with XS code from CPAN on Windows.

HTH,

SSF


Comment on Re: How to Monitor System Resources
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://719606]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2014-07-12 20:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (241 votes), past polls