OpsMgr: Using Wizards to create Powershell-based Monitors

In System Center Operations Manager, wizard-based monitoring involves creation of single management pack elements – eg. monitors or rules - using predefined wizards in the Operations Console. This approach is used to extend monitoring for existing classes. The advantage is, working in the Operations Console is fast and easy. A user can create a monitor or a rule in a few minutes without any coding or debugging. The main disadvantage is that there is no way to create custom monitoring logic, and limited to available wizards. As it stands, there are still no wizards available for a user to create PowerShell-based monitors or rules. The user will have to use the Operations Manager 2007 Authoring Console or Visual Studio Authoring Extensions (VSAE) to create Powershell-based monitors or rules and investing a considerable amount of time and effort to author the management pack in the process.


As Powershell becomes more commonly used and widely deployed in the IT industry, it is therefore important for the IT Pro to be able to leverage Operations Manager for application, server or service monitoring using Powershell scripts.

As my first post, I would like to demonstrate how a wizard can be configured and used to create a Powershell-based monitor that finds and alerts on certificates that are about to expire:




First, create a custom module (PSProbe) that will take a Powershell script as its value, and run the script according to a schedule (Scheduler).



Then, select this module as a data source module (Wei.Out.There.TimedPowershell.PropertyBagProvider) in a custom monitor type so that a Powershell script can be tested or used.



Assign the custom monitor type name as the Type Definition ID in a custom UIPageSet element (Wei.Out.There.TimedPowershell.TwoStateMonitorPageSet) where UIPageReferences referencing wizard pages can be defined.





Finally, stick the monitor type into this folder item: “Microsoft.SystemCenter.Authoring. MonitorTypeFolder.Scripting.Generic“ and it will appeared under the Scripting\Generic folder in the “Create a unit monitor” wizard after the management pack containing this configuration is imported, as show in Figure 1.

If the management pack with the datasource, monitor type and UIPageSet elements is sealed, a custom unsealed management pack can be selected to save the custom Powershell-based monitor configurations after completing the monitor wizard, as shown in Figure 1.

                            Figure 1



The remaining steps involve going through all the pages of the wizard and plugging values into the dialog boxes:

                                                                  Figure 2


The following UIPageReference element in the management pack references this wizard page in Figure 2:

<UIPageReference ID="Wei.Out.There.TimedPowershell.TwoStateMonitorPageSet.Reference1" PageID="Health!System.Health.MonitorGeneralPage" Usage="CreationAndUpdate">


                            Figure 3


The following UIPageReference element in the management pack references this wizard page in Figure 3:

<UIPageReference ID="Wei.Out.There.TimedPowershell.TwoStateMonitorPageSet.Reference2C" PageID="System!System.SimpleSchedulerPage" Usage="CreationOnly">



                                                         Figure 4



The following UIPageReference element in the management pack references this wizard page in Figure 4:

<UIPageReference ID="Wei.Out.There.TimedPowershell.TwoStateMonitorPageSet.Reference3" PageID="Windows!Microsoft.Windows.ScriptPage" Usage="CreationAndUpdate">

Additional notes: The Powershell script uses the command to find certificates that are about to expire from the Hey, Scripting Guy ! Blog (http://blogs.technet.com/b/heyscriptingguy/archive/2013/03/05/use-powershell-to-find-certificates-that-are-about-to-expire.aspx), and was modified to return its output in a Propertybag.



                                                                      Figure 5




These following UIPageReference elements in the management pack reference these wizard page in Figure 5:

<UIPageReference ID="Wei.Out.There.TimedPowershell.TwoStateMonitorPageSet.Reference4" PageID="System!System.ExpressionBuilderPage" Usage="CreationAndUpdate"> <UIPageReference ID="Wei.Out.There.TimedPowershell.TwoStateMonitorPageSet.Reference5" PageID="System!System.ExpressionBuilderPage" Usage="CreationAndUpdate"> <UIPageReference ID="Wei.Out.There.TimedPowershell.TwoStateMonitorPageSet.Reference6" PageID="Health!System.Health.OperationalStatesConfigPage" Usage="CreationAndUpdate">

Additional notes: The Expression Builder Pages builds expression that looks for a particular value from the Propertybag that the data source outputs (Property[@Name='State'] ).



                                                                      Figure 6


The following UIPageReference element in the management pack references this wizard page in Figure 6:

<UIPageReference ID="Wei.Out.There.TimedPowershell.TwoStateMonitorPageSet.Reference7" PageID="Health!System.Health.AlertingPage" Usage="CreationAndUpdate">

Additional notes: the name of the value in the Propertybag is specified in the alert context variable: $Data/Context/Property[@Name='Description']$



Click the create button to save the monitor configuration.

To force an alert, set the threshold to a high value like 1000 days ( $thresholdindays = 1000). An example of the active alert generated is as follows:




PLEASE NOTE: The specify script parameters featuredoes not work in this release as the XSLT to transform the input into the correct data type has yet to be configured:




The end product can be a sealed library management pack with a few unsealed management packs with custom Powershell scripts referencing it, or one single unsealed management pack with datasource, monitor type, UIPageSet elements and custom Powershell script(s) (it should have a similar configuration as per documented in http://technet.microsoft.com/en-us/library/ff381420.aspx ).

With this solution, what used to take considerable time and effort to accomplish will now be a relatively fast and straight forward process.

Attached with this post are both the sealed and unsealed versions of the library management packs.

A copy of the certificate expiry monitor management pack that references the sealed library pack is available here.

A sample management pack is also available at the TechNet Gallery.



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.