SCOM monitor for monitoring services status and system drivers presence

Script for the monitor. Currently looking for Sophos antivirus service and system driver.

'Try with or without after you have tested outside of SCOM
On Error Resume Next
Dim oAPI, oBag
Dim StrMntrStatus
Set oAPI = CreateObject("MOM.ScriptAPI")
Set oBag = oAPI.CreatePropertyBag()
For testing
'strComputer = ""
'Monitor has to be set to receive DNS name as 1st parameter
strComputer = WScript.Arguments(0) 
strrslt = "" ' String for debugging info
strSvcPresent = "No"
strSvcStatus = "None"
strSysDriverPresent = "No"
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_SystemDriver where Name='vsepflt'",,48)
'wscript.echo TypeName(colItems)
if not isempty(colItems) then
 For Each objItem in colItems
 strSysDriverPresent = "Yes" 
 'wscript.echo strrslt
 'wscript.echo "Driver not installed"
end if
set colItems = Nothing
Set colItems = objWMIService.ExecQuery("Select * from Win32_Service where Name='SavService'",,48)
For Each objItem in colItems
 strSvcPresent = "Yes"
 'strSvcStatus = objItem.Status
 strSvcStatus = objItem.State
strrslt = strrslt & vbcrlf & "strComputer: " & strComputer
strrslt = strrslt & vbcrlf & "strSysDriverPresent: " & strSysDriverPresent
strrslt = strrslt & vbcrlf & "strSvcPresent: " & strSvcPresent
strrslt = strrslt & vbcrlf & "strSvcStatus: " & strSvcStatus
Set objWMIService = Nothing
set colItems = Nothing
Call oBag.AddValue("Computer",strComputer)
Call oBag.AddValue("SysDriverPresence",strSysDriverPresent)
Call oBag.AddValue("SvcPresent",strSvcPresent)
Call oBag.AddValue("SvcStatus",strSvcStatus)
 if ((strSvcPresent="Yes" and strSvcStatus="Running") or strSysDriverPresent="Yes") then
 Call oBag.AddValue("Status","OK")
 StrMntrStatus = "OK"
 elseif strSvcPresent="Yes" and strSysDriverPresent="Yes" then
 Call oBag.AddValue("Status","Warning")
 StrMntrStatus = "Warning"
 Call oBag.AddValue("Status","Bad")
 StrMntrStatus = "Bad"
 end if
Call oBag.AddValue("MntrStatus",StrMntrStatus)
strrslt = strrslt & vbcrlf & "StrMntrStatus: " & StrMntrStatus
wscript.echo strrslt
Call oAPI.Return(oBag)

IT professional with wider interest in technology

Tagged with: , , , ,
Posted in Monitoring, SCOM, vbscript, wmi

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: