Check folder with custom script Monitor

In this example I will use a VB script to run the file/folder check against a server. If there are files that are older than 15 minutes the monitor will become unhealthy and generate an alarm.

You can create this monitor either in the Authoring console under Health Model or using the Authoring pane in the SCOM Console.

Select a Timed Script Two State Monitor. Do not save it in the Default Management Pack, as in the picture.

Set a Name for the Monitor and optionally a description. Choose under which class the monitor should be. This is mostly relevant to where health will roll-up. Then select the parent aggregated monitor and leave the enabled checkbox unchecked.

In Schedule, set how often the script should run.

In the Script windows, you have to set a name for the script ending with .vbs.  Set a timeout and paste the script code in “script box”.

Click the Parameter button and set the arguments. In this case the folder to check for old files. If you are going to use more than one parameter, separate them with a whitespace.

In Unhealthy Expression, set the value for which the monitor should be unhealthy. In the script I called the propertybag parameter Files. Hence, the Parameter Name will be Property[@Name=’Files’]. If the parameter does not equal 0 there are files older than 15 minutes.

In the same way we set the Healthy event to when Files equal 0.

I set the severity of the health state to Warning when unhealthy.

Next, it is time to map the monitor conditions to health states. In this example I map Unhealty to Warning.

Mark the check box Generate alerts for this monitor. Match Generate and alert when with the previous set Health conditions. Set an Alert Name and Alert desciption. It is possible to use variables pasted from the Propertybag.

To activate the monitor for a specific server, create an override and enable it for that server. Alerts will auto-close and are only used for statistics.

The script in this example: FolderCheckForFile.vbs

Custom monitor, SCOM 2007 R2

6 responses to Check folder with custom script Monitor

Leave a Reply

Your email address will not be published. Required fields are marked *