OpsMgr: Creating a Powershell script based monitor with the MP Author tool

Silect has just released a tool called MP Author targeted at IT Pros and allows them to easily build completely new or even customize existing management packs for OpsMgr - without needing XML skills.

For more information please visit :
Daniel  Savage’s blog post,
Stefan Stranger’s blog post,
Kevin Holman’s blog post.
    
In this post, I would like to demonstrate how a Powershell script based monitor can be configured with MP Author, what are the elements created when the monitor is configured, what to look out for, and how to make it run at a more frequent schedule.    
    
    image
    
   
First, create an empty management pack:

001

003

Then, create a Powershell script monitor using the Create New Script Monitor wizard:

004

Next, on Specify Script Information page, specific the Script name, Script body, and Script Parameters:

Note:
The sample script used for this demo was a script that collects the file size for a particular file and returns this information in a ProprtyBag.
The path and name of the file, the threshold of the file size, were specified as input values for the script parameter.

006

On the Specify monitor states for script monitor page, map the monitor conditions to health states and configure the criteria for the selected monitor state by looking for a particular value from the Propertybag that the Powershell script based monitor outputs to (Property[@Name='State']).

007   008

Configure the target and identity for the monitor and enable the monitor.

Note:
The target used for the demo was the single instance RMS Emulator
009   image

Leave the schedule information at default setting.

Observation 1:
No option to set the schedule to a smaller interval like every few minutes instead of using a daily interval from the UI.

011

Check the Generate alerts for this monitor check box to enable alerting.

Observation 2:
Why is the description field greyed out and read only ?

013

Review summary before creating the Powershell script based monitor:

014

After the monitor is created, the common and state settings can be viewed from the Properties View/Edit page:

Observation 3:
Not able to launch a wizard to edit the Powershell script based monitor setting after the monitor was created.

015

Clicking the Edit XML button will display the following XML definition for the monitor at the unit monitor level:

Observation 4:
Not able to find and edit the Powershell script for the monitor that was just created in the XML definition.

016

Lastly, import the MP Author created management pack into an OpsMgr management group to test the Powershell script based monitor created.

My Test Results:

1. Limited options to modify or fix monitor settings in Operations Console monitor properties:

image

Explanation:

For the new Powershell script based monitor, MP Author creates a new composite data source module that runs the Microsoft.Windows.PowerShellPropertyBagTriggerOnlyProbe Probe action module on a schedule.

The Powershell script that was supplied from the UI is used as the input value for the ScriptBody parameter in Probe action module of the composite data source module, hence will not appear at the unit monitor XML configuration level (Observation 3 and 4).

image
                                              …….

2. Monitor stayed in Uninitialized state and only ran once at 9 am:

image

Explanation and Resolution:

The scheduled interval for the monitor can only be set to run on a daily basis (Observation 1). There is no way to change the scheduled interval to run at an hourly, minute or second interval through overrides or monitor configuration in the Operation Consoles or MP Author (
Observation 3 and 4).
On further investigation, I found out that the Scheduler module of the Powershell script based monitor (from Test Result 1) was automatically configured to run on a daily basis when the monitor was created in MP Author.

image

To allow the monitor to run at a smaller interval, you can replace the XML definition for the Scheduler module within the monitor’s composite data source module as shown above with the following definition. This allows the Powershell script based monitor to run at a 2 minute interval. Feel free to modify the IntervalSeconds value as required:

   image After fixing the scheduled interval, the monitor ran at a more frequent schedule and changes were able to be detected sooner with the new scheduler setting:

018_

Hope this article gives you a better idea on how to configure and make this MP Author feature work for your specific monitoring scenarios and leveraging Operations Manager for application, server or service monitoring using your custom Powershell scripts.

Happy New Year !      
    
    
 

Disclaimer:  

All information on this blog is provided on an as-is basis with no warranties and for informational purposes only. Use at your own risk. The opinions and views expressed in this blog are those of the author and do not necessarily state or reflect those of my employer.