4

We have several apps that run on a Windows 2003/2008 server. Some of these apps are Java JAR files that are kicked off with a Scheduled Task using a app.cmd file.

Others are "big ones" like SQL Server and IIS.

I'd like to write an app (or service, actually) that simply monitors those programs and sees if they are running or not.

This is a little beyond what I've done before. Oh, this needs to be written in C#.

I was thinking of some type of "heart beat" pattern so that every few minutes, I check if the thread is running (again, new advanced threading) and if so, send out an "All's OK" message (using SMTP or something).

Any tips where to get started?

Thanks for any suggestions.

cbmeeks
  • 10,718
  • 18
  • 79
  • 134

2 Answers2

2

You can use Process.GetProcesses():

Use this method to create an array of new Process components and associate them with all the process resources on the local computer.

Mark Cidade
  • 94,042
  • 31
  • 216
  • 230
2

You should probably handle each application on a case-by-case basis, for exaple although you could just check for the existance of the SQL Server process you would be better off running a query that (for example) checks for the existance of a given database in the server.

Similarly you could run a simple HTTP request against an IIS server to check to make sure that the permissions are set up correctly etc...

Obviously the way that you test your Java processes would depend on what they do, although you could still just check for to see if the process is running (be aware that if they are running as a service they may be running inside one of the svchost.exe processes - this doesn't apply to scheduled tasks though).

Justin
  • 80,106
  • 47
  • 208
  • 350