Monitoring Windows Services with SQL Diagnostic Manager

by Mar 12, 2019

As we all probably already know, SQL Diagnostic Manager is a powerful performance monitoring and diagnostics solution that proactively alerts administrators to health, performance and availability problems within the SQL Server environment. What some don't realize is that SQL Diagnostic Manager can be used to also monitor Windows services as well through the use of Custom Counters.

What are Custom Counters?

SQL Diagnostic Manager gathers a number of different metrics from your SQL Server environment. However, there may be a few metrics that you as a user are interested in that isn't already gathered by SQL Diagnostic Manager. This is where the use of Custom Counters come into play. Custom Counters provide users with the ability to define a counter that is to be collected by SQL Diagnostic Manager. Custom Counters can be based on perfmon counters, WMI counters, custom T-SQL script (which must return a single numerical value), or a virtual machine counter. 


In my environment, I have SQL Safe Backup installed as my tool of choice for scheduling my backup operations. In order to perform backup and restore operations, SQL Safe Backup requires the SQL Safe Backup Agent to be running. If the service is not running, then my SQL Safe Backup Policies will not run as scheduled. As such, I want to make sure that my service is always running. For this, I'll use Custom Counters in SQL Diagnostic Manager.

Creating the Custom Counter

In SQL Diagnostic Manager, I'll head to the Administration pane then to Custom Counter where I'll be able to create my custom counter.

Upon getting to the Custom Counter screen, I'm presented with some messaging around what custom counters can be used for and a link to the IDERA Community to share any custom counters that you may have created. If you have an existing custom counter, then you'll just see a list of the custom counters that you have already configured. At this point, I just want to add a new custom counter so I'll click the Add button on the ribbon.

When creating my custom counter, I'll use the Windows System Counter option since I'm going to be basing my custom counter on a counter from WMI. My primary concern is that the SQL Safe Backup Service is in a running (started) state. As such, I've configured my custom counter settings as shown below.

Notice above that I'm using the Win32_Service object from WMI. This particular object is limited to administrators on the box so it's very important that the account used by the SQLDM Collection Service does have local admin rights on the server hosting the monitored SQL Server instance.

On the next, I simply accept the default settings and proceed to the screen where I'm asked to provide a name, category, and description for the custom counter.

On the following screen, you'll have to define the threshold settings. It's important here that you understand the possible values that are going to be returned and the meanings of those values. In my case, the particular counter I'm looking at is a boolean counter so the only values that can be returned are 1 (started) and 0 (stopped).

It looks a little odd that I'm using 0 for both Warning and Critical but SQLDM will report the higher severity if the 0 is detected.

Once I've finished creating my custom counter, SQL Diagnostic Manager will ask me if I want to link the counter to any instance. Well of course I do! Once I've linked the instance, the next thing that I'll want to do is test the custom counter to make sure that it's working as I expect it to. To do so, I simply right-click on the custom counter and select the Test option.

Testing with the service stopped.

Testing with the service started.

At this point, I'm satisfied with how the custom counter is configured. I can now rest assured that SQL Diagnostic Manager will alert me whenever the service is started. If I wanted to take it a step further, I could probably make use of the Alert Actions and Responses feature so that SQLDM would try to start the service when the alert is raised. That, however, is another topic for another day. 

I hope you guys find this useful!