We have a scenario where we have a windows service installed on two different servers but want it to only run on one server at a time.
Is it possible for an aggregate monitor to sum the health across two servers? I created a reverse monitor where its unhealthy if the service is running. Was planning on having an aggregate sum the best of health. If this worked it would alert when all (both) servers had the service running.
Create an unhosted object that will be the “business service” (I will often use System.LocalApplication or System.Service as parent).
Have a containment relationship between that business service account and the NT Service.
Use the generic NT Service monitor which doesn’t fire any alerts on the actual agents. Or maybe best to create another monitor and find a way so its health does not roll up within the server (otherwise you’ll always have a red server)
Create a dependency monitor on the “business service” class which can then return the alert
Other tips
Use a registry discovery to discover the base role of the servers (check if HKLM:\SYSTEM\CurrentControlSet\Services\yourservicename exists)
Use a PoSH discovery targeted to the base role that discovers the NT Service, the “business service” and builds the relationship with the “business service”