Wednesday 27 August 2014

SCOM - Two State Monitor - Check if Files Exists

This is an example how to use a timed script two state monitor to monitor a file exists. If the file exists the monitor is healthy.

A] Under Authoring > Monitors, create a new Timed Two State Monitor. Give it a name, schedule, target and description

B] Copy this script into the 'Script Window':

Dim oAPI, oBag
Set oAPI = CreateObject("MOM.ScriptAPI")
Set oBag = oAPI.CreatePropertyBag()
Set objFSO = CreateObject("Scripting.FileSystemObject")
strFile = "C:\Test.txt"
If objFSO.FileExists(strFile) Then
Call oBag.AddValue("Status","Ok")
Call oAPI.Return(oBag)
Else
Call oBag.AddValue("Status","Error")
Call oAPI.Return(oBag)
End If


Check that the quote marks are correct - i.e. straight down ones rather than the curly sort!

C] Configure the Healthy/Unhealthy experssions as needed. Use the Parameter name:

Property[@Name='Status']

then enter the Value depenging on which way round you need things

 
 
D] Configure the alerting bit of the Monitor and you're all done

No comments:

Post a Comment