Creating a xplat script monitor from the console, System Center 2012 Operations Manager

Announced in the Technet forum last week was the new ability to create a UNIX/Linux Shell Command Monitor. Download the file from here, run it and after importing the file called Microsoft.Unix.ShellCommand.Library.mpb you will be able to create a two and/or three state UNIX/Linux script monitor from within the Operations Manager console.

image

To create a monitor simply start the Create a Unit monitor wizard.

Make your choices:

image

Give the monitor a Name select Monitor target and choose if it will be enabled.

Select how often your script will run on the agent.

In the Shell Command details you need to provide your command or path to binary/script without line breaks. So my little script that checks if a file exists.

#!/bin/bash
if ! [ -f /tmp/OPSMGR.SE ];
then
echo “Error”
else
echo “OK”
fi

Needs to be put in a file on the agent or as a one-liner. Otherwise it wont be possible to continue the wizard and a red exclamation will show, like in this picture

image

Putting the script in one line makes it look like this, I removed #!/bin/bash so the line wont be marked as a comment..

if ! [ -f /tmp/OPSMGR.SE ]; then echo “Error”; else echo “OK”; fi

image

Specifying the Error Expression

image

Specifying the Healthy Expression

image

Finish the wizard and your monitor is now running.

image

Written on November 23, 2011