This is a quick digression from the main set of articles to create a windows service and then a SCOM service monitor to monitor that service.
The solution for this C# windows service is here.
The article “behind” this is here.
And how to install the service is here.
To monitor the service:
1. Right click on Monitoring in the folder structure in Solution Explorer and Add, New Item – Empty Management Pack fragment. Call it Unit_WindowsService_Batura
2. Paste this code into the fragment. Build and deploy the management pack and make sure the App Server in discovered inventory goes green (healthy).
If we stop the service, we see the Application Server goes red (critical):
But the windows computer is still green (healthy):