4

I have many Windows Services (written in C# 4.0) that at various intervals connect to a database and do various complex tasks. Some of these tasks only occur every X hour intervals per day. However, the server support team would like to know if the Windows Service is actually running as there can be a big interval between tasks. They would like essentially a heartbeat for each Windows Service. Every 5 minutes the Windows Service would do something that could be monitored by Microsoft System Center Operation Manager (SCOM). Any solution must being easily monitored by SCOM as the server support team rely on it.

What is the best way to achieve this type of funcationality? I thought of using Performance Counters and have SCOM listen for those but not sure if that is that best use of perf counters.

UPDATE (Totally forgot to include): Currently each service writes to a database this action but SCOM is not very good at monitoring databases records and differentiating which service is doing what etc.

Scott Wylie
  • 4,725
  • 2
  • 36
  • 48
  • Operations Manager can [monitor Windows services](http://technet.microsoft.com/en-us/library/bb381240.aspx) as a feature. You shouldn't have to implement anything additional inside your code. – Val Akkapeddi Jan 26 '12 at 04:08
  • http://stackoverflow.com/questions/295348/how-to-monitor-windows-services see if this helps – Devjosh Jan 26 '12 at 04:09
  • @ValAkkapeddi Yes I know Operations Manager and SCOM can see if the service is running, stopped, paused but what if my service is running and not doing its tasks for some reason. I want SCOM to know that my tasks are executing or not. – Scott Wylie Jan 26 '12 at 04:13
  • @ScottWylie I see, then in that context, performance counters don't seem like a bad way to go imho. You could even set up intelligent metrics such as task execution time or what have you to help your support team be more proactive with identifying and resolving issues. – Val Akkapeddi Jan 26 '12 at 04:28

4 Answers4

1

If your case here is limited to service health check, I am pretty sure this can be done by windows tools such as windows performance monitor. Collecting their data should be an easier task than creating heartbeats in a usually disconnected environment.
There are plenty of server and service monitoring tools. Few of them are also open-source, which you can choose as an initial step.

0

You could add either SNMP or WMI instrumentation to your services - this incidentally will allow you to raise more than just heartbeat messages - for example you could also raise events when you encounter transient faults that require an operation to be retried.

There are plenty of SNMP libraries out there and WMI support is built into the .NET framework.

0

Just FYI, I'm researching this question because how I do it is that the Service application logs a hearbeat message every X seconds when it polls the Db for a new job. At midnight, all heartbeat messages over a week old are deleted from the log. I do have an application scheduled at 7 AM that checks when the last heartbeat message was sent, but it looks like I'm going to have to run it constantly to periodically check ... and notify Solar Winds to send an alert if there is a problem.

Miguelito
  • 302
  • 3
  • 11
0

What about simply writing to a DB or event log?

Bob Horn
  • 33,387
  • 34
  • 113
  • 219
  • Sorry see updated question. This is done by DB now and it does not work well with SCOM. – Scott Wylie Jan 26 '12 at 04:17
  • What if this db had a table with two columns : servicename and heartbeattime? Each service would update this every x minutes – Bob Horn Jan 26 '12 at 04:24