Check For Not Running Services In Automatic Mode
Ever needed to get alerts on all services that are set to Automatic but not running?
Use the following SCOM monitor to do just that:
1. Create a Unit Monitor of type “Timed script two state monitor”, call it “Check For Not Running Services In Automatic Mode” or name it whatever you want
2. Check of “Monitor is enabled” (we will enable it to run only on specific servers later with overrides)
3. Monitor target – Agent
4. Put the following script:
Call Main ()
Sub Main()
‘ Monitor if automatic process is not running
Dim oAPI, oBag, wshShell
Set oAPI = CreateObject("MOM.ScriptAPI")Set wshShell = WScript.CreateObject( "WScript.Shell" )
strComputer = wshShell.ExpandEnvironmentStrings( "%COMPUTERNAME%" )‘strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")Set colListOfServices = objWMIService.ExecQuery _
("Select * from Win32_Service Where StartMode = ‘Auto’")For Each objService in colListOfServices
Set oBag = oAPI.CreatePropertyBag()
If Not objService.Started = True Then
strDesc = "Service " & objService.Caption & " is not running on " & strComputer
Call oBag.AddValue("Description", strDesc)
Call oBag.AddValue("State", "BAD")
Else
Call oBag.AddValue("State", "GOOD")
End IfoAPI.Additem(oBag)
Next
oAPI.ReturnItems
End Sub
5. As Unhealthy expression put
Property[@Name='State'] Contains BAD
6. As Healthy expression put
Property[@Name='State'] Contains GOOD
7. Turn on Alerting
8. As Alert Description put
$Data/Context/Property[@Name='Description']$
9. Turn on Override for specified servers and change option Enabled to TRUE
Enjoy!

Recent Comments