A while ago I wrote a service monitor to watch for service crashes, it wasn’t the greatest as it just checked the service status at a defined interval and restarted it if it wasn’t running.

This was not the best method ans since I lost the source, I decided to find a better way.

Basically if a service is shut down cleanly it will go into a stopping state first.
If it jumped straight to stopped then it crashed.

This allows us to monitor the service and not interfere with things like updates or legitimate reasons for stopping the service.

 

Click here to download the SourceCode