Reputation: 4735
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.
Upvotes: 4
Views: 7465
Reputation: 688
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.
Upvotes: 1
Reputation: 332
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.
Upvotes: 0
Reputation: 146
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.
Upvotes: 0