http://qs321.pair.com?node_id=759634

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

I am looking for a way to monitor if a process has stopped responding on a server, I cannot seem to find anything that will help me with this and I really need it, could someone please point me to something that I can use that will help with this? further information, Operating system is windows server 2003, process is mercury loadrunner, it spawns some subprocesses as well as the main executable which is called vugen.exe, namely mmdrv.exe and thumbprocess.exe occasionally it will hang (stop responding) and my scripts will stall. The purpose of the server is to monitor website performance of a custom application. I run the script on the server via remote desktop, I use windows script to restart the process if it has ended succesfully, the script itself in vuserend calls and executes a batch file using process.exe to kill itself then it calls a vbscript which is to restart the application and set focus and finally call a perlscript using win32guitest to get the window id and sendkeys to the application to restart it. I notice that thumbprocess.exe appears to be causing the hang, and if I kill it the application will sometimes start responding again. I am looking for a solution, I downloaded win32 process and win32 process info yesterday but am not sure what to do to solve this problem and was hoping for some guidance. I am reading about win32process info but I don't understand how to get anything out of it. I looked at planetscapes hash tutorial and now I am able to print out the info for a process but I am looking to do something with the information, which I am not clear on how to do with this module, any suggestions? oh and here is the code I have so far, I know its not much but it does at least display some info.
use Win32::Process::Info; use Data::Dumper; $pi = Win32::Process::Info->new (); $pi->Set (elapsed_in_seconds => 0); # In clunks, not seconds. @pids = $pi->ListPids (); # Get all known PIDs @info = $pi->GetProcInfo (); # Get the max %subs = $pi->Subprocesses (); # Figure out subprocess relationships. @info = grep {$_->{Name} =~ m/perl/} $pi->GetProcInfo (); # All processes with 'perl' in name. #print $info; #print $pi; foreach(@info) { print $_; } my $href=\%subs; print Dumper $href; print Dumper @info;