Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

find CPU utilization + Perl + XP

by isha (Sexton)
on Jul 02, 2007 at 04:28 UTC ( [id://624373]=perlquestion: print w/replies, xml ) Need Help??

isha has asked for the wisdom of the Perl Monks concerning the following question:

I am using Windows XP SP2. I want to create a script which will find the CPU usage in percentage of the local machine as well as of the remote machine. How can i do this with Perl? And same thing on Linux also?

Replies are listed 'Best First'.
Re: find CPU utilization + Perl + XP
by garu (Scribe) on Jul 02, 2007 at 06:15 UTC

    First, a tiny (or not so tiny) remark on your question...

    Are you sure you want to do it, or do you just want us to do it for you? Have you done any code so far that got you stucked so you can share some specific problems that we can actually help you with? Do you at least have a plan on how to do it?

    Don't take this the wrong way, but please read Is PM a good place to get answers for homework? and How (Not) To Ask A Question before posting this kind of questions - and don't be offended by the links' titles, they actually have good pointers on how to ask a question so people can help you (instead of just work for you or not understand your question or simply ignore you).

    Now, on to your question, ...

    ...you should take a look at Sys::Info::CPU as it works for both Windows and Linux, and even has a nice compatibility layer in case you want to give support for other OS'es too.

    To find CPU usage of remote machines you'll probably have to create a client/server program in order to make it portable through different OS'es using something like SOAP::Lite or plain Sockets (if you want to get hardcore ;-)

    Hope this helps!

Re: find CPU utilization + Perl + XP
by BrowserUk (Patriarch) on Jul 02, 2007 at 13:05 UTC

    See Re: CPU usage Windows OP, but realise that if you thinking of using these instantaneous values for anything other than display purposes, by the time you get the numbers in Perl, they are out-of-date and so wildly inaccurate. This will be the case regardless of which OS and how you get the numbers.

    If you are thinking of basing any processing decisions upon them, you are going to be very disappointed. It'd be a bit like trying to play the stock market based upon those 20-minute delayed 'free' price feeds. By the time you get the information, the real situation will have changed, up or down and probably several times up and down.

    Whatever action you take as a 'reaction' to the numbers you obtain will essentially be random.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re: find CPU utilization + Perl + XP
by Anonymous Monk on Jul 02, 2007 at 05:53 UTC
Re: find CPU utilization + Perl + XP
by Anonymous Monk on Jul 02, 2007 at 05:46 UTC
    Win32::Proces::Info Unix::Processors
Re: find CPU utilization + Perl + XP
by sago (Scribe) on Jul 02, 2007 at 09:14 UTC
    Try to use this below command in the perl script. I tried this in linux/unix OS.

    Unix Command
    $ grep "model name" /proc/cpuinfo
    Output:
    model name : Intel(R) Xeon(TM) MP CPU 2.50GHz

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://624373]
Approved by GrandFather
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (1)
As of 2024-04-25 02:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found