Automating OpsMgr Part 13: Creating 2-State Performance Monitors

Written by Tao Yang

OpsMgrExntededIntroduction

This is the 13th instalment of the Automating OpsMgr series. Previously on this series:

In the previous post (Part 12), I have demonstrated how to create performance collection rules using the OpsMgrExtended module. In this post, I will demonstrate how to create a 2-State performance monitor.

OpsMgrExtended module provides a function called New-OM2StatePerformanceMonitor. It has been documented in the embedded help within the module. you can access it via the Get-Help cmdlet:

image

Same as the previous posts, I’m going to show a sample runbook which utilise this function.

Runbook New-2StatePerformanceMonitor

As you can see, I have hardcoded the following parameters in the runbook:

  • Frequency – 900 seconds
  • (Unsealed) MP (where the monitor is going to be saved to) – “TYANG.SMA.Automation.Perf.Monitor.Demo”
  • Increase MP Version – true

So, before I can kick off this runbook, I need to firstly create the MP. This can be easily done using a one-liner on a machine where OpsMgrExtended is loaded:

image

After the test MP is created, I can then execute the runbook. This runbook takes the following input parameters:

  • ClassName – The name of the target monitoring class (i.e.Microsoft.Windows.Server.OperatingSystem)
  • CounterName – Name of the perf counter
  • InstanceName (Optional) –The Name of the instance of the counter. if not specified, the monitor will use All Instances.
  • MonitorDisplayName – The Display Name of the monitor.
  • MonitorName – The name of the monitor
  • ObjectName – Name of the object where the counter belongs to (i.e. memory, logical disk, etc.)
  • Threshold – The numeric threshold used by the monitor
  • UnhealthState – The unhealthy state of the monitor (Error or Warning)
  • UnhealthyWhenUnder (Boolean) – Specify if the monitor is unhealthy when the perf counter is under the threshold (or over the threshold).

Runbook Execution Result:

image

Monitor created by the runbook:

image

image

image

image

image

Conclusion

In this post, I have demonstrated a SMA / Azure Automation runbook to create 2-state performance monitors in OpsMgr. Now that I have covered both aspect of the performance  data (perf collection rule and monitor), I will move on to the event data in the next post.

Leave a Reply