Forum Discussion

BillP's avatar
3 years ago

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

 

12 Replies

  • 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.

    $target = "##system.sysname##.##system.domain##"

    $rmm = get-service <servicename> -computername $target
    $av  = get-service <servicename> -computername $target

    if ($rmm) { write-output “system.category=RMMToolName” }
    if ($av)   { write-output “system.category=AVToolName”  }

    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”).

  • 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:

    if ($rmm.status -eq "Running") { write-output "1" } else { write-output "0" }

    Then use that to alert against.