Two-state script monitor not auto-resolving in SCOM

Posted by DeliriumTremens on Server Fault See other posts from Server Fault or by DeliriumTremens
Published on 2011-04-07T20:55:33Z Indexed on 2014/05/29 3:32 UTC
Read the original article Hit count: 469

Filed under:
|

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!

© Server Fault or respective owner

Related posts about system-center

Related posts about scom