Alert when the Service Does not exist
I am monitoring all windows for a specific service to make sure it is running, if not it triggers an alert.
How can I get that to apply with the service is actually missing from the device. I would like to have an alert for when it is missing.
Thanks
BillP
12 comments
Cole McDonald
We also have a few that are mission critical production apps that we use dataSources for which are similar to the propertySources we have. We basically use the same code from that but the output is:
Then use that to alert against.
Cole McDonald
I know it’s been answered already, but as a second option, we use powershell and a propertySource to add the presence of our internal toolset as entries in the system.categories property.
get-service returns an object if the service is found… otherwise it’s $null.
In powershell, $true and $false resolve to 1 and 0 respectively… $null is counted as a zero when evaluating the condition for the if (condition) { … } statement, so zero, $null, and $false are all equivalent for evaluating the condition.
Then you can build a dynamic group and any dashboarding/reports using an appliesTo of hasCategory(“AVToolName”).
Mike Moniz
It is...
LM User
IDK. Is it not showing deprecated in yours?
Mike Moniz
Wait... LM is going to remove adding arbitrary services via Other Monitoring? As far as I can tell that is just a wizard to create WinService- instances. I don't see it in the deprecated list...
BillP
OPWorks like a champ! Thanks
Learn something new everyday.
Thanks Again.. Much appreciated!
LM User
Just noticed that the WinService- DS is deprecated, so there's that:
Are you using that one or a different one? (perhaps 6HJZC9 or a different one?) Either way, the deprecated one doesn't discover services, you have to add them manually (unless you've modified it like i'm about to tell you to do). 6HJZC9 does use discovery, but it won't discover a service that isn't present at the time of discovery, so it won't meet your needs either.
So, taking a DS like the deprecated WinService- DS, notice that there is no discovery out of the box. The only way to get those services added into monitoring is to navigate to the device and click "Manage" >> "Add Monitored Instance". You give the name of the service and whatnot and it starts monitoring it.
What I like to do is automate the "Add Monitored Instance" bit. I do this by enabling Active Discovery on the datasource. You might have trouble doing this because of the deprecated status, so just clone the DS and try it there. Once you've enabled Active Discovery, you need to tell LM how to perform active discovery.
Normally, this would involve providing some WMI stuff to the DS telling it to query the device for all the services and include or exclude certain services by name or status. This is what 6HJZC9 does. It provides the Win32_service WMI class and the displayname property. The Collector queries each Windows server the matches the AppliesTo and returns the entire list of all objects in that WMI class, effectively telling LM to monitor every service. In 6HJZC9's case, there is a post discovery filter that causes only a subset of all services to end up as monitored instances.
However, this won't work for you because this would still only discover services that do exist, not the ones that should exist. To get that, we need to change how discovery works. Instead of querying the Windows box for what services do exist, we are going to specify a list of services should exist. We'll feed this list into active discovery and that will create our instances.
So two parts here: 1) the list of services to monitor and 2) the active discovery configuration to turn the list into instances that will be monitored.
1) The list
Ok, so, how do we tell LM what list of services we want to monitor? That's actually pretty easy. All we need to do is put the list as a custom LM property on the Windows device. How exactly we do this doesn't really matter because we'll be building the custom script to parse from a single string of text into the list of instances. So, let's just combine the list of services and separate them with a pipe character:
Windows Firewall|Bonjour Service|Routing and Remote Access
Cool, now we need to set this as a property on our Windows server in LM. We can do that on the server itself, but that doesn't really save us any effort. Instead, let's put it on a group and add the servers into the group. That way the property is inherited by all the devices in that group. Let's call our property "expected.services".
2) The Active Discovery configuration
Now, how do we turn that property into a list of instances to be monitored? That's actually pretty easy. We'll switch the discovery method to "SCRIPT". This allows us to write a Groovy script that will output the list of instances:
And that's it. Now the property causes instances to be created, which are then monitored. If the instances created are on the Windows server, it'll monitor them. If they're not, it'll try to monitor them and fail. This will mean a 'no data' event, which you can alert on.
Something to understand here: The Collector attributes of this DS specify displayname as the index property. This means, the display name is what is used to identify the service. If you want to use name instead, you'll need to change what goes into your property and also change the index Property in the Collector Attributes to 'name' instead of 'displayName'.
BillP
OPI am using winservice DS to discover the service and the State.. "I am not sure how to apply if regardless of whether or not they exist," Where is that option. right now it only applies if the service exists.
LM User
@Stefan W, weren't you and I talking about this last week? @BillP, not easily. There are a few options (custom propertysource probably the cleanest).
I prefer to modify the Winservice DS to have auto discovery based on properties. You would specify a property containing the list of services to discover (regardless of whether or not they exist). This would then kick off monitoring of those services, leading to no data alerts whenever the service doesn't exist. You'd take responsibility of applying the property only to those servers where the services should exist. Opens up lots of customizable options based on group inheritance.
BillP
OPWinservice does not apply the datasource to a device if the service is actually missing from the server.
I tried the auto property Windows Services however that is buggy and does not always run correctly. LM Team is looking into the issue.
I may try the config.
Is there a way to run create a group with the applies to iswindows() and something like datasourceexist("datasourcename") == False.
LM User
If you are using something else, you might consider a ConfigSource. The ConfigSource would run a query you would run against the windows server. The result could have a configcheck ensuring that a particular item is in the result.
Mike Moniz
Are you using WinService- (aka the Windows Service Wizard in LM) and the Raw Data tab is showing "No Data" when it's missing? If so, you can likely modify WinService- to set its Status DataPoint to alert if there is no data for that datapoint.