Two-state script monitor not auto-resolving in SCOM
- by DeliriumTremens
This script runs, and if it returns 'erro' an alert is generated in SCOM. The alert is set to resolve when the monitor returns to healthy state. I have tested the script with cscript and it returns the correct values in each state. I'm baffled as to why it generates an alert on 'erro' but will not auto-resolve on 'ok':
Option Explicit
On Error Resume Next
Dim objFSO
Dim TargetFile
Dim objFile
Dim oAPI, oBag
Dim StateDataType
Dim FileSize
Set oAPI = CreateObject("MOM.ScriptAPI")
Set oBag = oAPI.CreatePropertyBag()
TargetFile = "\\server\share\file.zip"
Set objFSO = CreateObject("scripting.filesystemobject")
Set objFile = objFSO.GetFile(TargetFile)
FileSize = objFile.Size / 1024
If FileSize < 140000 Then
Call oBag.AddValue("State", "erro")
Else
Call oBag.AddValue("State", "ok")
End If
Call oAPI.AddItem(oBag)
Call oAPI.Return(oBag)
Unhealthy expression: Property[@Name='State'] Equals erro
Health expression: Property[@Name='State'] Equals ok
If anyone can shed some light onto what I might be missing, that would be great!