What is the best way to monitor a windows service?
Creating the monitor with the standard windows service template or Lior Armiev’s template for more services, both targeted to a created group of servers
Creating all with the fragments in MP Studio by first discovering a class and then targeting the monitor to this class. Here is no way to monitor more service with a wildcard.
I’ve personally found the standard windows service template to serve our needs 90% of the time. If I’m bundling the service as part of a new application role or object, I might create a fragment to link with it, but that’s been pretty rare. For wildcard services, I still use the standard template but then manually modify the MP XML for discovery:
<DataSource ID=“DS” TypeID=“Windows!Microsoft.Windows.WmiProviderWithClassSnapshotDataMapper”>
<Query>select * from win32_service where displayname like ‘%wilcardservicestring%’</Query>
We don’t touch any of the templates due to the extra baggage that gets created e.g. classes and performance metrics.
The way we create the monitoring is to separate the application from the infrastructure. So create a class based on local application with a hosting relationship to windows computer but no health roll up.
Then windows service monitors targeted at the application class along the following lines - https://www.f1point2.com/create-a-windows-service-and-scom-service-monitor/
In practice we have created a library for windows service monitoring which would include monitor types of business hours, consecutive occurrences and optional diagnostics and recoveries. E.g. https://raw.githubusercontent.com/f1point2/SCOMMPFragments/master/LibraryMonitorTypeServiceMonitorBusinessHours.txt
Actually I think the good old “Basic Service Monitor” does a good job.- Not much ballast as the template and easy to use.
Try it out ?
We use it often. – Unless there are many services, then I tend to author an MP by foot ?
Before that however we create a computer class so that the monitor can apply only to the computers where required.
I use fragments. For pretty much everything. You can use VSAE or MPStudio
- Create the discovery for the class (https://blogs.technet.microsoft.com/kevinholman/2016/06/04/part-2-use-vsae-fragments-to-dynamically-discover-an-application-based-on-the-existence-of-a-registry-key-or-value/
- Create the Service monitor: https://blogs.technet.microsoft.com/kevinholman/2016/06/04/part-3-use-vsae-fragments-to-monitor-a-service/
- Document Management pack. Sure it's one service but I have a template doc I use for this. It has the name of the requester, the ticket requesting the monitor, the basic structure of the monitor, and the alert. This documentation helps when someone asks two years later why/if a monitor is still needed. I can point to documentation and let them decide.