Monitoring a process
-
There is a critical service in my machine which crashes once in a month. I want to write an application which monitors that process and if that crashes sends email, or SMS or if possible restarts the service. I am trying with Enumerating Process . But that doesn't seem to be the solution. thanx in advance
-
There is a critical service in my machine which crashes once in a month. I want to write an application which monitors that process and if that crashes sends email, or SMS or if possible restarts the service. I am trying with Enumerating Process . But that doesn't seem to be the solution. thanx in advance
Create a watchdog app. Find the handle to the process you need to monitor. Then go into a WaitForSingleObject state. Set a time limit and let the watchdog app time out and process messages occasionally in case you want to shut it down manually. WaitForSingleObject returns a code that indicates the condition under which the function exits. If it timed out, the process is still running, so you clear the message queue and go back into WaitForSingleObject. If WaitForSingleObject exits because the process ended you send the e-mail, do whatever. Robert
-
Create a watchdog app. Find the handle to the process you need to monitor. Then go into a WaitForSingleObject state. Set a time limit and let the watchdog app time out and process messages occasionally in case you want to shut it down manually. WaitForSingleObject returns a code that indicates the condition under which the function exits. If it timed out, the process is still running, so you clear the message queue and go back into WaitForSingleObject. If WaitForSingleObject exits because the process ended you send the e-mail, do whatever. Robert
Assuming the 'crash' means that the process being monitored has termianted. This will not detect if it has locked up or not - it is still 'running' but uselessly deadlocked or stuck in a loop. If the monitored process is running as a service, you can periodically query the service control manager to get the service status, too.