Freigeben über


OpsMgr: Creating a PowerShell script based monitor with Silect MP Author SP1

Silect recently announced the availability of the latest version of MP Author – Silect MP Author SP1. This tool is targeted at the IT Pros and allows them to easily build completely new or even customize existing management packs for OpsMgr without needing XML skills.

image

In this post, I would like to briefly demonstrate how a PowerShell script based monitor can be configured with MP Author SP1, and emphasize on the changes to this feature from the older RTM version.
For more in depth information on how to create a PowerShell script based monitor using the older version of MP Author , please visit my previous blog post. The steps to create a PowerShell script based monitor are mostly identical between the 2 versions.

image

To create a PowerShell script based monitor with MP Author SP1:

  1. Select the Create New Script Monitor option to launch the wizard, then specific the Script name, Script body, and Script Parameters on the Specify Script Information page, before specifying the states for the script monitor.

    image
    image

    Note: The sample script used for this demo is a script that collects the file size for a particular file and returns this information in a ProprtyBag.
    Note: On the Specify states for script monitor page, the monitor conditions are mapped to health states based on the selected criteria.

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

    image

  3. IMPORTANT CHANGE: Option to set the schedule to run at a periodic interval like every x minutes has been added to the UI.
    image

  4. IMPORTANT CHANGE: The Description field for the Alert Configuration page is no longer greyed out and strings can be inserted:

    image

    ”Property bag values can be shown in alert description by replacing '«Name»' with the name of a property bag entry. i.e. The value of «Name» is: $Data/Context/«Name»$” – was the prefilled comment in the Description field.

    Hence the following context variables should work accordingly …. right ?

    image

    HOWEVER: The alert generated has the following unconverted strings in the Alert Description:

    image

    Further investigation reviews that the whole description string was popped into the <Description></Description> and <AlertParameter> was not usd to store the context variables.

    image

    image

  5. Review summary before creating the PowerShell script based monitor and import the management pack into an OpsMgr management group to test the PowerShell script based monitor created.

What hasn't changed:
Still not able to launch a wizard to edit the PowerShell script based monitor setting after the monitor is created.
Clicking the Edit XML button will display the following XML definition for the monitor at the unit monitor level, hence not able to find and edit the PowerShell script for the monitor in the XML definition.

image

From the Operations Console:

image

Workarounds:

  1. To enable the context variables to work, go to the properties of the monitor in the Operations Console, remove all characters from the Alert Description field (cut) –> Click the Apply button to apply the changes –> Restore the original strings  (Paste) --> Click the Apply button to apply the changes.

    image

    Test Result:

    The context variables in the Alert Description field worked correctly.

    image

    What happened ?

    The AlertParameters section was used to store the context variables for the monitor definition this time after the workaround was applied, that's what happened !

    image

  2. To see how to modify the script embedded in the management pack of the monitor, please refer to my previous blog post.

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

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.

Comments

  • Anonymous
    August 25, 2014
    Thanks for posting this Wei, helpful stuff!  Must have been fun discovering and working through these quirks : ) This tool looks promising.  It's a bit painful as is.  My main use is script based monitors based on PowerShell.  Somehow you can create vbscript monitors in the standard SCOM console, yet not powershell based.  Moving to MP Author avoids mucking around with XML, but is quite frustrating given the limitations (i.e. remove and recreate a monitor if you need to make a simple edit to the script itself). Would love to see an actual authoring product from Microsoft that doesn't force me to use a paid edition of Visual Studio. Cheers!

  • Anonymous
    October 01, 2014
    Wei, this is now fixed in SP2 version of MPAUthor. Your post is referenced in the list of fixes. Nice going bro! :)

  • Anonymous
    August 25, 2016
    Hi,How can I see or get the powershell script from monitor created using MP author.