Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Access Win "performance counter" from unix?

by sauoq (Abbot)
on Aug 02, 2003 at 21:07 UTC ( #280336=perlquestion: print w/ replies, xml ) Need Help??
sauoq has asked for the wisdom of the Perl Monks concerning the following question:

Is there an equivalent to Win32::PerfLib for unix? In other words, I want to retrieve the performance counters on some of our Windows machines from a unix box.

If not, is the necessary documentation to create such a thing available, or would reverse engineering really be necessary (as ybiC hinted at in the CB?)

If I can't come up with a solution, I expect I'll have to write a server that will run on a Windows machine, use Win32::PerfLib to retrieve the data I want from other machines, and then serve it up as requested. I'd rather avoid that. Any other suggestions? I'm pretty clueless when it comes to Windows, so I'm hoping I'm missing something obvious.

-sauoq
"My two cents aren't worth a dime.";

Comment on Access Win "performance counter" from unix?
Re: Access Win "performance counter" from unix?
by BrowserUk (Pope) on Aug 02, 2003 at 23:35 UTC

    I'm not aware of any tools/modules for accessing Win32 performance data from a *nix machine, but then I wouldn't be:)

    However, if such a tools exists, it might be available as a part of the WINE project. I did take a quick peruse, but the search options don't seem to work for me... maybe it didn't like my browser?

    The Win32 PerfMon.exe can (with appropriate permissions) connect and display performance data gathered from other Win32 machines, so at least there is a remote access protocol available that could be (theoretically) connected to. This relies upon MS authentication and transport protocols (RAS/WMI). Whether WINE has succeeded in emulating these I don't know.

    If you decide that you need to go the route of writing your own server, then I'd recommend Win32::Process::Info as a starting point. It provides access to the same information as Win32::PerfMon, but the interface is considerably easier to use, as the author has abstracted the (horrible!) native apis in a perl freindly manner taking care of a huge amount of nasty detail that you would have to do yourself using PerfMon.

    If you have to go this route and would like a hand...


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller
    If I understand your problem, I can solve it! Of course, the same can be said for you.

Re: Access Win "performance counter" from unix?
by t0mas (Priest) on Aug 03, 2003 at 00:18 UTC
    If you feel comfortable with sending unencrypted passwords across your network, then you can start the telnet server on a win2000 box, and if you disable NTLM authentication (set NTLM to 0 with the tlntadmn.exe program) you can log in on it and run programs from a *nix terminal.

    One oddity, you need to print to STDOUT or STDERR to get any teminal output if you play with perl -e. perl -e "print yoo" won't work but perl -e "print STDOUT yoo" will.

    Create a script on the win2000 machine and run it from the terminal, capture the output and do whatever with it.

    Note: I don't advocate using telnet because you usually want your session encrypted and use ssh or something. But if you have a specific situation that makes it OK, then this solution will probably work.

    /brother t0mas
      At least with cygwin you also have ssh when you have security concerns. BTW I did this telnet stuff alot and it works great. Murat
      Net::Telnet is your friend for working with telnet. It's easily scriptable and most systems have telnet support. This comes in handy when I have to use machines which I'm not sysadmin on, but I have a need to use, and the machine is on a private lan. (If a clever hacker can gain access to the lan, they can have access to my machine.)

      ----
      Zak
      Pluralitas non est ponenda sine neccesitate - mysql's philosphy
Re: Access Win "performance counter" from unix?
by Anonymous Monk on Aug 03, 2003 at 03:07 UTC
    If you don't mind running a process on your win32 boxen, maybe you could use PlRPC as part of a solution.

    I don't know of any easier way to get at the live data, but you can use performance counter logs... If you set up a Counter Log, you can tell it to log to a text file, or any ODBC System DSN. Either of those can be easily accessible using samba tools or DBI. Anyway, HTH!

    -hattmoward
      Wow, even changing my default theme didn't save me from that one... Anyway, reply to this one so I get the notify! Hehe, sorry!

      mhoward - at - hattmoward.org
Re: Access Win "performance counter" from unix?
by kschwab (Priest) on Aug 03, 2003 at 16:04 UTC
    The nagios monitoring tool has a contrib type tool that does just what you are asking for.

    It's called nsclient, and it talks with the windows performance manager. It was designed as a plug-in for netsaint/nagios, but it's easily integrated:

    ./check_nt -H 192.168.1.1 -p 1248 -v COUNTER -l "\\Paging File(_Total +)\\% Usage","Paging file usage is %.2f %%" -w 80 -c 90 ./check_nt -H 192.168.1.1 -p 1248 -v COUNTER -l "\\Process(_Total)\\Th +read Count","Thread Count: %.f" -w 600 -c 800 ./check_nt -H 192.168.1.1 -p 1248 -v COUNTER -l "\\Server\\Server Sess +ions","Server Sessions: %.f" -w 20 -c 30

      Oh... This is perfect! (And if it isn't, it comes with source.)

      Thank you very much ++kschwab.

      -sauoq
      "My two cents aren't worth a dime.";
      

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://280336]
Approved by phydeauxarff
Front-paged by Enlil
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2014-08-02 02:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Who would be the most fun to work for?















    Results (53 votes), past polls