0

I have some windows application .exe which are run on my Domain server, i have a problem that if the .exe is stooped how can i get the notification that the .exe has stopped.

is there any solution thru i can manipulate my code with operating system and get notification thru mail or any other resource

Cœur
  • 37,241
  • 25
  • 195
  • 267
Ravi Kant Singh
  • 175
  • 2
  • 17
  • Is the monitoring program to be installed on the very same computer as the program to be monitored? – Alejandro Feb 25 '14 at 04:29
  • You could use a powershell script, c# app, or vb.net app to watch for a ProcessDeletionEvent for the Process that you don't want to be stopped, and subsequently send an e-mail or restart the process. There is also the possibility of this failing. – John Bartels Feb 25 '14 at 04:32
  • John Bartels- sir, can u provide me some links or some more stuff that i can easy understand it. – Ravi Kant Singh Feb 25 '14 at 04:41
  • http://stackoverflow.com/questions/848618/net-events-for-process-executable-start The title of this question seems to indicate the opposite of what you want, but if you look at the accepted answer, there is a WatchForProcessEnd Method that will do what you want. – John Bartels Feb 26 '14 at 00:45

2 Answers2

1

We have critical windows services that must always be running at work and the way we handled this was to write a monitioring program that listens to communication from the critical services and sends out an email if any of them stop "calling in". Here are a few details (although a bit simplified):

1) We use MSMQ messages to have the computers running the services talk to the monitor. Each service writes to a specific queue and the monitor is set to read from those queues. Note that MSMQ has pros and cons--if you choose to use this method, be sure to read up on it a bit.

2) The critical programs write messages to the queue detailing what it is they are doing and if they have had any errors.

3) If it has been more than 20 seconds (adjust accordingly for your situation) and the services haven't had anything to do, they simply write a message to the queue saying that they haven't had anything to do for the last 20 seconds.

4) The monitor reads these messages, keeps track of how long it has been since it has heard from each queue and if any of them haven't sent at least an "I've been idle for 20 seconds" message within 30 seconds (note that this should be longer than the other time period), it sends an alert to our emails saying which service has been idle for too long. Similarly, if any service has had any critical errors, the monitor may report those right away, too.

ALTERNATELY

There are off-the-shelf programs you can buy to do some or all of this for you, but this solution has worked well for us. If you are interested in 3rd party tools, you may consider looking at Splunk, Big Brother, and Tripwire. I don't have much/any experience with these tools, so I'm not sure if they will do what you want or not.

David
  • 4,665
  • 4
  • 34
  • 60
  • 2 things I should have noted: 1) TCP sockets may be a better solution than MSMQ for some people. We use MSMQ so that the monitor can log details as well as just watch for activity. 2) We actually have 2 monitors. One is the "main" monitor and reads all the MSMQ messages and the other is a "buddy" that simply monitors the main monitor. The main monitor also monitors the buddy (they both check in with each other). This way, if either monitor stops, we get notified. Otherwise, if the monitor were to stop and then a critical service stopped, we would have no idea. – David Feb 25 '14 at 18:51
0

You can make use of the OnStop() event in the ServiceBase as given here. Related discussion post is here

Community
  • 1
  • 1
Saravanan
  • 7,637
  • 5
  • 41
  • 72