Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: monitor process

by targetsmart (Curate)
on Apr 23, 2009 at 19:51 UTC ( [id://759640]=note: print w/replies, xml ) Need Help??


in reply to monitor process

We generally used to check a process is alive by some methods.

on *nix systems
'top' command or ps command output
kill -0 pid
heart beats, this method will check the process is functional apart from alive status, heart beats are simple messages(usually program name+timestamp) will be sent to heart beat monitoring(hbm) server through socket, and the duty of the hbm server is to restart that process if no heart beats received for a configured amount of time.
hope this helps


Vivek
-- In accordance with the prarabdha of each, the One whose function it is to ordain makes each to act. What will not happen will never happen, whatever effort one may put forth. And what will happen will not fail to happen, however much one may seek to prevent it. This is certain. The part of wisdom therefore is to stay quiet.

Replies are listed 'Best First'.
Re^2: monitor process
by grashoper (Monk) on Apr 24, 2009 at 15:14 UTC
    I am able to connect to my process when passing in the process id which I obtained from processinfo.pl..(idea is to grab the new process id and pass it in and then use it to monitor process so it keeps running continuously or something.. ) process info code followed by my process.pl code which is just to connect and tell me exit code as I don't really know yet how to do anything with it. stuff below code is ignorable.
    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/vugen/} $pi->GetProcInfo (); # All processes with 'perl' in name. #print $info; #print $pi; my $href=\%subs; print Dumper $href; print Dumper @info; #print Dumper @pids;
    use Win32::Process; use Win32; sub ErrorReport{ print Win32::FormatMessage( Win32::GetLastError() ); } Win32::Process::Open($Obj,$pid=12732,$iflags)|| die ErrorReport(); print "connected to process $pid "; $Obj->GetExitCode($exitcode); print $exitcode;
    that sounds very much like what I want to do but how can I do it on a winblows system..(er I mean windows). I am looking at win32 process, but it's not clear how to export "still-active" I manage to get a bit over my head on this one,how do I explicitly export? so far I haven't gotten much, trying to figure out how to tell if still_active or setup a heartbeat or something. I can get it to launch but not to open my script.
    use Win32::Process; use Win32; sub ErrorReport{ print Win32::FormatMessage( Win32::GetLastError() ); } Win32::Process::Create($ProcessObj, "C:\\program files\\Mercury\\LoadRunne +r\\bin\\vugen.exe", "E:\\Mibor_timingtest\\Mibor\\mibor.us +r", 0, NORMAL_PRIORITY_CLASS, ".")|| die ErrorReport(); Win32::Process::Open($Obj,$pid=11672,$iflags)|| die ErrorReport(); $ProcessObj->Suspend(); $ProcessObj->Resume(); $ProcessObj->Wait(INFINITE);
    I am trying to figure this out has anyone used before? I get 259 as my exit code what does that mean?
    use Win32::Process; use Win32; sub ErrorReport{ print Win32::FormatMessage( Win32::GetLastError() ); } Win32::Process::Open($Obj,$pid=11672,$iflags)|| die ErrorReport(); print "connected to process $pid"; #$ProcessObj->Suspend(); #$ProcessObj->Resume(); #$ProcessObj->Wait(INFINITE); $Obj->GetExitCode($exitcode); print $exitcode;

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (4)
As of 2024-04-26 01:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found