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

Respected Monks,

We have been working to administrate(start/stop) and monitor the health status of processes running on either Linux/Solaris systems. We have built easy to use web based applications on a dedicated linux server for performing the start/stop/status operations for all remote systems processes and using SSH protocol for connectivity ( Net::SSH::Expect ).

Also the client is looking forward to administrate and monitor few processess running on Windows platform. So, we have tried few options in monitoring the Windows processess from a the linux server.

OPTION-1)

We have installed SNMP service on the windows system and written a sample perl script to obtain the status of the processes. Used the snmpwalk command and grepped out the service name and its statistics like Status, CPU Performance, Memory Utilised, PID and Path etc.

Here is the part of code of this script

my $IP=$ARGV[0]; my $COMMUNITY=$ARGV[1]; my $Service=$ARGV[2]; my $resultat =`snmpwalk -v 1 -c $COMMUNITY $IP | grep $Service`; ###Sn +mp Object host resource names my @sid; my $pb_calcul; my @memory; if($resultat){ $resultat =~ s/HOST-RESOURCES-MIB::hrSWRunName.(\d+)\s+=\s+\w+:\s+ +(.*)/$1:$2/g; @sid=split(/:/,$resultat); my @nextresult =`snmpwalk -v 1 -c $COMMUNITY $IP | grep $sid[0]`; foreach my $rec(@nextresult){ if($rec =~ m/HOST-RESOURCES-MIB::hrSWRun(\w+).\d+\s+=\s+\w+:\s ++(.*)/){ print "$1 ------> $2\n"; } }

Usage -> $PROGNAME <IP> <COMMUNITY> <service>

Output of the Script

[root@station17 sushil]# perl check_win_processall.pl station16 p +ublic services Index ------> 1208 Name ------> "services.exe" ID ------> SNMPv2-SMI::zeroDotZero Path ------> "C:\\WINDOWS\\system32\\" Type ------> application(4) Status ------> running(1) PerfCPU ------> 271 PerfMem ------> 4144 KBytes

But using this we are just able to monitor the status and don't have to ability to start and stop the process.

OPTION - 2) On Windows system we have installed OpenSSH software and made few basic configurations, created password and group files for authentication. And using this we can connect to windows system from the linux box using the ssh command

# ssh <Windows IP Address>
And we can successfully login to the Windows systems and we get the prompt. With this we have written a script using Net::SSH::Expect module to connect to the Windows systems and check for the status and also start/stop the processes. So, we have used the above two options, I wanted to now is there any other way to administrate and monitor the status of the Windows processes. Main reason is that with the above 2 Options we have few cons

Option 1 => Unable to start/stop a process

Option 2 => Need to install OpenSSH s/w on all the remote system boxes ( Say if there are 50 + systems then a major drawback )

Also when we have gone througth the old threads, we have found that WMI is also an other method to administrator windows processes. When we have searched in cpan for any module that supports this technology, and tried to install that module in a linux box, it prompted us with a message "OS unsupported".

So, please let me know if there is any other way to do the monitoring and start/stoping the processes.

Thanks In Advance
Sushil Kumar

Replies are listed 'Best First'.
Re: Options on Windows Process Managment
by roboticus (Chancellor) on Aug 22, 2008 at 13:34 UTC
    msk_0984:

    You might check out WMI ... there are a couple modules on CPAN (e.g., DBD::WMI) that may be helpful. WMI has *bunches* of junk for you to view/monitor.

    ...roboticus

      msk_0984 didn't explicitly mention it, but DBD::WMI is one of these modules that won't work on Linux, unless you install Wine on Linux. But of course, there is a Unix version of WMI, and it's mentioned in the DBD::WMI documentation as well, WBEM (http://www.dmtf.org/standards/wbem/). I haven't used that though.

        msk_0984:

        On re-reading the OP, I see what you mean. I had originally interpreted it as him wanting to have programs on the Windows box that he could control from his Linux box. But after reading the post, I can't tell *where* I would've gotten that impression. Just a thinko on my side... Thanks for the catch (and the pointer to WBEM!)

        ...roboticus