Monthly Archives: October 2015

Automating OpsMgr Part 19: Creating Any Types of Generic Rules

Written by Tao Yang

OpsMgrExntededIntroduction

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

Although I have written number of functions in the current version of the OpsMgrExtended module that allows you to  create some popular types of rules in OpsMgr (i.e. perf collection rules and event collection rules). Sometimes, you still need to create other types of rules, such as WMI event collection rules, or rules based on module types written by yourself. In this post, I will demonstrate how to create any types of rules using the New-OMRule function.

Additionally, since the OpsMgrExtended module can be used on both your on-prem SMA infrastructure as well as on your Azure Automation account (with the help of Hybrid Workers), and pretty much all the previous runbooks and posts are based on SMA, I will use Azure Automation in this post (and maybe in the future posts too). I will demonstrate 2 sample runbooks in this post. Since Azure Automation now supports PowerShell runbooks on both Azure runbook workers as well as on hybrid workers, with the 2 sample runbooks I’m going to demonstrate, one is based on PowerShell workflow and the other one is a PowerShell runbook.

What Components are OpsMgr Rules Made Up?

Before we diving into the sample runbooks, please let me explain how are the OpsMgr rules made up. In OpsMgr, a rule is essentially a workflow that contains the following components:

  1. One or more Data Source modules
  2. Zero or one Condition Detection Modules
  3. One or more Write Action modules

To explain in plain English, a rule can have multiple data source modules and write action modules, but condition detection module is optional, and you can only use up to 1 condition detection module in your rule. The order of execution is Data Source Modules –> Condition Detection Module –> Write Action Modules. Additionally, some modules requires mandatory and/or optional configuration parameters (i.e. System.SimpleScheduler), some modules do not require any configuration parameters (i.e. Microsoft.SystemCenter.CollectPerformanceData).

OM-Rule Design Consideration

When I was writing the New-OMRule function, I have realised in order to capture all required information for each member module, the following information is required:

  • Module Type Name (Mandatory)
  • Configuration (Optional)
  • Member Module Name (Mandatory)
  • RunAs Profile Name (Optional)

i.e. in the example below, I have high lighted the information required in a member module of a rule.

image

Other than the information listed above, if we are writing an alert-generating rule, we would also need the following information for the alert configuration:

  • String Resource
  • Language Pack ID
  • Alert Name
  • Alert Description

I needed to figure out a way to enforce users to supply all required information listed above. In order to do that, I think the best way is to define a class for member module configurations and another class for alert configurations. However, since class definition is a new concept only been introduced in PowerShell version 5 (which still in preview other than Windows 10 machines at the time of this writing), I could not do this natively in PowerShell. In order to work around this limitation, I have defined these two classes in OpsMgrExtended.Types.dll using C#. This DLL is shipped as part of the OpsMgrExtended module.

image

The OM-Rule is expecting instances of these classes defined in OpsMgrExtended.Types.dll as input parameters. You will see how I used these classes in the sample runbooks.

Sample PowerShell Runbook: New-WMIPerfCollectionRule

OK, let’s start with a “simpler” one first. The New-WMIPerfCollectionRule runbook is a PowerShell runbook that can be used to create perf collection rules based on WMI queries. I think it’s simpler than the other one because it’s a PowerShell runbook (as opposed to PowerShell workflow) and we don’t have to worry about configuring alerts for the rules created by this runbook. The source code for this runbook is listed below:

As you can see, this runbook requires the following input parameters:

  • RuleName – the internal name of the rule
  • RuleDisplayName – the display name of the rule. this is what people will see in OpsMgr console
  • ClassName – The internal name of the target class (i.e. “Microsoft.Windows.OperatingSystem”)
  • WMINameSpace – the WMI name space of where the WMI class you are going to query resides. This is optional. if not specified, the default value of “Root\CIMV2” will be used
  • WMIQuery – the WMI query to retrieve the performance counter value
  • IntervalSeconds – the rule execution interval in seconds. this is optional, if not specified, the default value of 900 (15 minutes) will be used.
  • ObjectName – The object name for the performance data (i.e. Process, or LogicalDisk)
  • CounterName – the counter name for the performance data (i.e. ProcessCount, or FreeSpaceMB)
  • InstanceNameWMIProperty – the property returned from the WMI query which represent the performance data instance value (i.e. if you are collecting logical disk counters, the result of WMI query may contain a property that represent the drive letter, which can be used to identify the instance in perf data). This is optional, if not specified, the perf data instance name would be “_Total”.
  • ValueWMIProperty – the property returned from the WMI query that represent the perf value.

The first step of this runbook is to retrieve a connection object named “OpsMgrSDK_Home” from my Azure Automation account (or SMA). This connection object is pre-configured, which contains the computer name of one of my OpsMgr management servers, and the credential of a service account which has OpsMgr admin privilege in my management group.

SNAGHTMLddea7c

The runbook also needs to explicitly import the OpsMgrExtended module. During the test, I found for this PowerShell runbook, I must manually import the module using Import-Module cmdlet in order to load the assemblies defined in the OpsMgrExtended.Types.dll. Since we are going to be using hybrid workers, you must manually deploy this module to your hybrid workers because at the time of this writing, Azure Automation is not able to automatically deploy required modules to hybrid workers.

Next, we must define the module configurations for each member module used by the WMI perf collection rules that this runbook creates. I have determined this type of rules should be configured using the following modules

  • One Data Source Module
    • Microsoft.Windows.WmiProvider
  • One Condition Detection Module
    • System.Performance.DataGenericMapper
  • Three Write Action Modules
    • Microsoft.SystemCenter.CollectPerformanceData
    • Microsoft.SystemCenter.DataWarehouse.PUblishPerformanceData
    • Microsoft.SystemCenter.CollectCloudPerformanceData

To explain in English, the rules created by this runbook would periodically execute a WMI query (Data source module), then map the result from WMI query to OpsMgr performance data (Condition detection module), finally store the performance data in OpsMgr operational DB, data warehouse DB and also OMS workspace (3 write action modules).

So we will need to use the New-OMModuleConfiguration function from the OpsMgrExtended PS module to create an instance of the “OpsMgrExtended.ModuleConfiguration” class. As explained earlier, the “OpsMgrExtended.ModuleConfiguration” class is defined in the OpsMgrExtended.Types.dll. Take the data source member module as an example:

I have placed the module type name, module configuration and the member module name into separate variables and passed them to the New-OMModuleConfiguration function and created a module configuration object for the data source module.

Note:

You can use Get-Help New-OMModuleConfiguration to access the help file for this function. If you need to use an alternative OpsMgr RunAs profile to for any member modules, you can also specify the name of the RunAs profile you are going to use with the –RunAsMPName and the –RunAsName parameter. The RunAsMPName parameter is used to specify the internal name of the management pack that defined the RunAs profile, and the RunAsName parameter is used to specify the internal name of the RunAs profile (i.e. if you are creating rules for SQL related classes, you might need to use the default SQL RunAs Profile, in this case, the –RunAsMPName would be “Microsoft.SQLServer.Library” and –RunAsName would be “Microsoft.SQLServer.SQLDefaultAccount”.)

Since a rule can have multiple data source modules and multiple write action modules, the New-OMRule function is expecting the array type of input for data source modules and write action modules. This is why even there is only going to be one data source member module or write action member module, we still need to place them into separate arrays before passing into the OM-Rule function:

image

image

On the other hand, since the condition detection member module is optional, and you can only have maximum one condition detection member module, you do not need to place the module configuration object for the condition detection module into an array.

Lastly, I have hardcoded the management pack name to be “Test.OpsMgrExtended” in this sample runbook. this MP must be created prior to running this runbook otherwise it would fail. However, if you have a look at the sample runbooks in previous posts, you can easily figure out a way to firstly detect the existence of this MP and use this runbook to create the MP if it does not exist in your management group.

Now, it’s time to take this runbook for a test run. I’m using the following parameters during the test run:

  • RuleName: “Test.WMIPerfCollection.Process.Count.WMI.Performance.Collection.Rule”
  • RuleDisplayName: “Windows Server Process Count Performance Collection Rule”
  • ClassName: “Microsoft.Windows.OperatingSystem”
  • WMIQuery: “select Processes from Win32_PerfRawData_PerfOS_Objects”
  • ObjectName: “Process”
  • CounterName: “ProcessCount”
  • ValueWMIProperty: “Processes” –verbose

And I have specified to run on a hybrid worker group:

SNAGHTMLd3df42

The hybrid worker will pick up this job very soon, and during this test run, the job was completed around 2 minutes. after the job finishes, I’m able to find this rule in OpsMgr console:

image

image

Sample PowerShell Workflow Runbook: New-WindowsEventAlertRule

Now, let’s take a look at the second sample runbook. This runbook is designed to create rules that detects certain event log entries and generates alerts upon detection. I think it’s more complicated than the first sample because this is a traditional PowerShell workflow runbook (which works on both SMA and Azure Automation), and we also need to configure alert settings for this rule. The source code for this runbook is listed below:

This runbook takes the following input parameters:

  • RuleName – the internal name of the rule that you are creating
  • RuleDisplayName – the display name of the rule
  • ClassName – The internal name of the target class (i.e. “Microsoft.Windows.OperatingSystem”)
  • EventLog – the name of the event log (i.e. “System”)
  • EventID – the ID of the event that you are detecting
  • EventSource – is what you see as “source” in Windows event log
  • EventLevel – can be one of the following value:
    • Success
    • Error
    • Warning
    • Information
    • Audit Failure
    • Audit Success
  • AlertName – the alert name / title
  • AlertSeverity – can be one of the following value:
    • Critical
    • Warning
    • Information
  • AlertProirity – can be one of the following value:
    • Low
    • Medium
    • High

As you can see, firstly, other than the standard process of retrieving the connection object for my OpsMgr management group, I have used several “Switch” statements with inline scripts to translate the event level, alert priority and alert severity from English words (string) to numbers (integer), because when configuring member modules for OpsMgr rules, we must use the number (instead of names). Note I’ve also used “ValidateSet” to validate the input of these parameters, so only valid inputs are allowed.

I am not going to explain the member module configurations again, because I’ve already covered it in the first sample. But please note because the rules created by this runbook will be generating alerts, we must configure alert settings. In OpsMgr, when a workflow is configured to generate alerts (either rules or monitors), other than the rule / monitor itself, we must also define a String Resource for the alert message ID, as well as defining the alert name and description in a preferred language pack (by default, ENU). Therefore, we are going to use another class defined in OpsMgrExtended.Types.dll for alert configuration. The class for alert configuration is called OpsMgrExtended.AlertConfiguration, and you can use New-OMAlertConfiguration function to create an instance of this class. Same as all other functions in the OpsMgrExtended PS module, you can use Get-Help cmdlet to access the help file for New-OMAlertConfiguration. You will need to specify the following input parameters for New-OMAlertConfiguration:

  • AlertName – the name / title of the alert
  • AlertDescription – the alert description / detail
  • LanguagePackID – the 3-letter language pack code for the language pack that you wish to create the alert message under. this is an optional parameter, if not specified, the default value of “ENU’’ will be used.
  • StringResource – the ID for the alert string resource

As you can see, since the write action member module for the rules created by this runbook would be “System.Health.GenerateAlert”, and we are defining <AlertMessageId> and <AlertParameters> in the write action member module configuration:

image

The String Resource must match the AlertMessageId:

image

And if you have previously authored OpsMgr management packs, you’d probably already know how to define the <AlertParameters> section for the alert description. Basically, any variables you are using in the alert description must be defined in the <AlertParameters> section, then in the alert description, you’d reference them using “{}” and a number inside. <AlertParameter1> becomes {0}, <AlertParameter2> becomes {1}, and so on. You can up to define 10 alert parameters:

image

Since you can define multiple alert messages (for multiple language packs), when you are creating alert generating rules, the New-OMRule function would expect you to pass in an array that contains OpsMgrExtended.AlertConfiguration objects. So, even if you are only defining the alert in one language pack, please still place it into an array before passing to the New-OMRule function:

image

OK, now, let’s give this runbook a test run with the following parameters:

  • RuleName: “Test.Disk.Controller.Event.Alert.Rule”
  • RuleDisplayName: “Disk Controller Error Event Alert Rule”
  • ClassName: “Microsoft.Windows.OperatingSystem”
  • EventLog: “System”
  • EventID: 11
  • EventSource: “Disk”
  • EventLevel: Error
  • AlertName: “Windows Disk Controller Error”
  • AlertSeverity: Critical
  • AlertPriority: High

SNAGHTML1055790

After the hybrid worker in my lab executed the runbook, I am able to see the rule created in OpsMgr console:

image

image

and the raw XML (once I’ve exported the MP):

image

Hybrid Worker Configuration

Since the samples in this post are all based on Azure Automation and Hybrid worker, I just want to point out this article if you need help setting it up: https://azure.microsoft.com/en-us/documentation/articles/automation-hybrid-runbook-worker/

Also as I mentioned earlier, you will need to deploy OpsMgrExtended module manually on to the hybrid workers by yourself. When copying the OpsMgrExtended module to your hybrid workers, make sure you copy to a folder that’s listed in the PSModulePath environment variable. During my testing with a PowerShell runbook, I initially placed it under “C:\Program Files\WindowsPowerShell\Modules” folder, as it was listed in the PSModulePath environment variable when I checked in a PowerShell console on the hybrid worker. However, I got error messages telling me the runbook could not find commands defined in the OpsMgrExtended module. To troubleshoot, I wrote a simple PowerShell runbook:

image

and based on the output, the folder in “C:\Program Files” is not listed!

image

Therefore, I had to move the module to another location (C:\Windows\System32\WindowsPowerShell\v1.0\Modules). after the move, the runbook started working.

Summary

In this post, I have demonstrated how to use the New-OMRule function from OpsMgrExtended PS module to create any types of rules in OpsMgr. Although OpsMgrExtended module has already shipped two other functions to create event collection and performance collection rules, the New-OMRule fills the gap that allows users to specify each individual member module and its configurations. This is probably the most technically in-depth post in the Automating OpsMgr series. I have tried my best to explain and demonstrate how to use the New-OMRule function. But if you are still unclear, have questions or issues, please feel free to contact me.

I haven’t figured out what I will cover in the next post, but I still have a lot to cover in this series. Since I am attending few conferences in the coming weeks in November, I probably won’t have time to work on part 20 until end of November. Until next time, happy automating!

A Sneak Peek at Squared Up’s Upcoming OMS Plugin

Written by Tao Yang

plugin-thumbnailIntroduction

If you are an existing Squared Up customer, or have previously evaluated Squared Up’s product, you’d probably already know that currently, other than the existing SQL Plugin, Squared Up dashboards retrieve data via either OpsMgr Data Warehouse (DW) DB, or via OpsMgr SDK.

With the recent launch of Microsoft Operations Management Suite (OMS), over the last few months, folks at Squared Up have been busy developing a plug-in within Squared Up to display data within OMS. Although Squared Up has not set a release date for this plugin yet, I would like to give you a high level preview on what the OMS plug-in looks like so you know what you are expecting Smile.

Squared Up OMS Plug-in

Squared Up’s OMS Plug-in is designed to enable customers display the data collected by OMS on the Squared Up dashboards. It leverages the OMS Search API and allows users to specify the OMS search query within the plugin, and the search result returned from OMS will be displayed on the dashboard.

image

SNAGHTML2477479a

As you can see, you can simply use the exact same query you’ve used in OMS and copy/paste to the OMS plug-in configuration. You can also use “|” (pipe) followed by the “Select” command to specify the fields that you are interested in displaying on the dashboard.

Since OMS is collecting data that is not natively available in OpsMgr (such as Change Tracking data, Wired Data, etc.) , you can really extend your existing Squared Up investment with this plugin. For example, I have produced a dashboard using the OMS plug-in in my lab (as shown below):

image

In this dashboard, I have configured the following sections:

  • Windows Services Changes For the Last 6 Hours
    • Data type: ConfigurationChange
    • OMS Solution: Change Tracking
  • Software Changes For the Last 1 Day
    • Data type: ConfigurationChange
    • OMS Solution: Change Tracking
  • Top Offenders in OpsMgr (Nosiest monitoring objects)
    • Data type: Alert
    • OMS Solution: Alert Management
  • Hyper-V Host Available Memory
    • Data type: PerfHoulry
    • OMS Solution: Capacity Planning
  • Wired Data Traffic by Process
    • Data type: WiredData
    • OMS Solution: Wired Data

Without the OMS plugin, some of above listed data will not be available in Squared Up dashboards (such as change tracking data and wired data), some could be retrieved only via complex SQL queries (such as top OpsMgr offenders). Take Top OpsMgr offenders as example again, it is super easy to find out who are the OpsMgr top offenders in OMS, by using a very simple query: “Type=Alert AlertState=New TimeGenerated>NOW-24HOURS | measure count() by SourceFullName”.

image

Interested in the OMS Plug-in?

Currently the version running in my lab environment is the “limited release technical preview”. This plug-in will also be demonstrated in the upcoming events such as MMS.

Are you also interested in trying the Squared Up Plug-in yourself? Although Squared Up has not confirmed the release date for this plug-in, they have asked me to let everyone know that if you’d like to test and provide feedback, please contact Squared Up directly. You can find their contact details from their website: https://squaredup.com/contact/

Accessing OpsMgr Data on Your Mobile Devices through OMS Mobile Apps

Written by Tao Yang

image

Last year, my friends Cameron Fuller and Blake Wilson from Catapult Systems have written number of posts on “Taking my OpsMgr with me” (Part 1, Part 2, Part 3, Part 4, Part 5). In their blog post series, Cameron and Blake have demonstrated multiple ways of accessing your OpsMgr data from mobile devices via number of 3rd party applications such as Xian Wings, Squared Up, Savision Live Maps, etc.

With the recent release of Microsoft Operations Management Suite (OMS) Android and iOS apps, the OMS mobile apps would be another good option when you need to access your OpsMgr data on your mobile devices.

As we know, we normally categorise OpsMgr data into the following areas:

  • Alert Data
  • Event Data
  • Performance Data
  • State Data
  • Managed Entity Data

Once you have connected your OpsMgr management groups to your OMS workspace, with some additional configuration (i.e. configuring collections for log and Near Real-Time Perf data, enabling Alert Management and Capacity Planning solutions, etc.), we can easily access Alert data, Event data and Performance data from OMS. Unlike OpsMgr, since OMS does not implement object health model (monitoring classes and relationships), the State data and Managed Entity data has become irrelevant in this case.

In this post, I will show you some sample search queries and dashboards I have developed in my lab, and what these dashboards look like in the OMS Android app (from my Samsung Note 3 mobile phone).

First of all, OMS already comes with some useful built-in dashboards:

imageimageimage

These built-in dashboards covered top level overview of alert data, perf data, event data, configuration changes data ,etc. Which are good starting point for you to drill down by tapping (or clicking) the dashboard tiles. i.e. the drill down from the “Alert raised during the past 1 day grouped by severity” tile:

image

I also managed to produced the following Saved Searches and then pined them on the dashboard:

OpsMgr Management Server Heartbeat Event For the Last 15 Minutes

Using the OMS Add-On MP from version 2.5 of the OpsMgr Self Maintenance MP, I configured management servers to send heartbeat events to OMS every 5 minutes. The search query for this dashboard tile is:

Type=Event Source=OMSHeartbeat Computer=OMMS01 TimeGenerated>NOW-15MINUTE | measure count() by TimeGenerated

I also configured a threshold that would hightlight when the value is under 3:

image

As you can see, this dashboard tile has also changed colour in the OMS Android app just like the full blown web console:

SNAGHTMLa66124b

Top 3 OpsMgr Offenders for the Last 24 Hours

In OpsMgr, we would often interested in finding out which monitoring objects has generated the most of the alerts. This can be easily achieved using a very simple search query in OMS:

Type=Alert AlertState=New TimeGenerated>NOW-24HOURS | measure count() by SourceFullName | Top 3

SNAGHTMLa690c51

From this tile, I can see that most of the alerts generated in my management groups are Office 365 related.

Error Events from the “Operations Manager” Event Log for the Last 24 Hours

If I want to see how many error events have been generated in the “Operations Manager” log on all the computers managed by OMS, I can use a query like this one:

Type=Event EventLevelName=error EventLog=”Operations Manager” TimeGenerated>NOW-24HOURS

SNAGHTMLa6db2bf

From this tile, I can then drill down by tapping the dashboard tile

imageimage

Note:

from this tile, you may have noticed there are only few bars for the recent time frames. this is because I have specified the query only return the events generated from the last 24 hours and the default time range for the OMS app is the last 7 days:

image

Hyper-V Hosts Available Memory

Once you have configured the pre-requisites and enabled the Capacity Planning solution in OMS, this solution will start collecting various performance counters from your VMM managed Hyper-V hosts. The performance data collected by this solution is stored as hourly aggregated perf data (Type=PerfHourly). Therefore, we are able to get some common perf counters such as Memory Availability MBytes using a simple query like this:

Type=PerfHourly CounterName=”Available MBytes” |Measure Avg(SampleValue) AS AVGMemory by Computer | sort AVGMemory

SNAGHTMLa6ffb09

And you can drill down from this tile:

image

From here, I can see in my lab, a Hyper-V host running on an Intel NUC has the least amount of available memory.

In my opinion, using the OMS mobile app has the following advantages comparing to the various mobile apps for OpsMgr:

Support for multiple management groups and stand alone agents

Since you can connect multiple OpsMgr management groups into a single OMS workspace, and you are also able to connect standalone computers directly to OMS, the data returned from your search queries are consolidated among all data sources, not just one single management group.

Cloud Based Solution

Since OpsMgr is primarily designed to monitor your on-prem infrastructure, generally your OpsMgr infrastructure would be place somewhere in you on-prem data centre. Therefore in order to access your OpsMgr data via a mobile app remotely, you’d either need to connect to your corporate network via VPN, or your network team would need to create some kind of reverse proxy tunnel for you to access your OpsMgr web based portal (such as Squared Up) from the internet. This adds additional complexity in your solution. By using the OMS mobile apps, since the data is hosted on Azure, you do not need any kind of connectivity between your mobile device and your on-prem data centres.

My fellow CDM MVP Steve Buchanan has also written an awesome overview for the Android app few days ago, you can read Steve’s post here: http://www.buchatech.com/2015/10/unpacking-the-operations-management-suite-android-app/

Cameron has also just posted his experience with the iOS app on iPad on his blog: http://blogs.catapultsystems.com/cfuller/archive/2015/10/21/the-microsoft-oms-experience-on-an-ipad/

Lastly, I recommend you to give the OMS mobile apps a try, they are currently available on all 3 platforms (Windows Phone, Android and iOS). If you do have your OpsMgr management groups connected to OMS, this app could come very handy Smile.

Top Community Resources for SCOM and OMS Webinar

Written by Tao Yang

Few weeks ago, I presented a session on Top Community Resources for SCOM and OMS for Squared Up’s UK community workshop (http://blog.tyang.org/2015/10/05/top-community-resources-for-scom-and-oms/). Squared Up has asked me to present this again for the broader community since it was well received by the audiences from the workshop.

So I’m going to present this session few more times. They are free to register and attend. You can find the details from Squared Up’s website: https://squaredup.com/tao-yang-presents-top-community-resources-for-scom-and-oms/

Additionally, after the initial presentation, I notice I forgot to include some awesome resources, I will add them in this time.

Automating OpsMgr Part 18: Second Update to the OpsMgrExtended Module (v1.2)

Written by Tao Yang

OpsMgrExntededIntroduction

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

Before I diving into the topic of creating generic rules using the New-OMRule function from the OpsMgrExtended module, I have updated this module again. It is now on version 1.2.

I was working on another project and I needed to use the New-OMRule function to create rules and I realised this function did not support specifying optional RunAs accounts for member modules. As I needed to create rules that use a RunAs account in the data source module, I had to update this function to accommodate it.

Additionally, as I mentioned in the previous post (Part 17), there is a bug in the New-WindowsServiceTemplateInstance function, where the description field is not populated. I have also fixed it in this release.

What’s New?

So, in summary, here’s what’s changed:

  • Updated OM-Rule function to allow specifying optional RunAs profile for each member module.
  • Fixed the issue in New-WindowsServiceTemplateInstance function where the description field is not populated.

Where to Download V1.2?

I have updated the original link, so you can download this updated version at TY Consulting’s web site: http://www.tyconsulting.com.au/portfolio/opsmgrextended-powershell-and-sma-module/

Conclusion

Now that I’ve updated and enhanced the New-OMRule function I will demonstrate how to create rules using this function as planned in the next module.

Top Community Resources for SCOM and OMS

Written by Tao Yang

Last Friday, as part of the Squared Up UK community workshop, I have presented my recommended resources for SCOM and OMS. I have covered may blogs, sites, management packs and other utilities for SCOM and OMS.

CQTGK3-WoAA7IzF.jpg large

I know that many friends have mentioned my work and myself in many occasions in the past, but I have never really “returned” any favours. So after the presentation on Friday, I’ve decided to share my slide deck here, hopefully, you’ll find something useful from it.

You can download it from the link below:

Displaying OpsMgr Events Data in Squared Up Dashboards

Written by Tao Yang

For those who’s been using Squared Up dashboards for your OpsMgr environments, you’d probably know that currently Squared Up does not have a plug-in for OpsMgr event data, thus you cannot display event data collected by OpsMgr on a Squared Up dashboard natively.

However, since Squared Up does have a SQL plugin and the OpsMgr event data is stored in OpsMgr databases, I’d like to show you a way of displaying event data using the SQL Plugin today.

When developing event collection rules for an OpsMgr management pack, MP developers generally would configure the collection rule to store the collected event in both operational DB (OperationsManager) and the Data Warehouse DB (OperationsManagerDW).

So why storing the data in 2 different databases? As you may know, in the native OpsMgr console, all the event views are accessing the event data from the operational DB, but when you are using reports to retrieve event data, most likely you are accessing the data from the DW DB. Another difference is, the retention period in Operational DB is a lot shorter than the Data Warehouse DB. For example the data retention period for event data is 7 days in Operational DB and 100 days in the DW DB.

With the Squared Up SQL Plugin, there’s a variable you can use for referencing the Data Warehouse DB (global:dw). I have developed couple of similar SQL query that you can run against the DW DB to retrieve event data:

Get the 30 most recent events logged with a specific source (publisher):

Get all events with a specific Event Number:

Note: For these 2 queries, you will need to place the event publisher name and event ID into the queries accordingly.

As an example, I have created a Squared Up dashboard for Forefront Endpoint Protection (FEP) MP, where I used the SQL plugin to retrieve the recent 30 security events logged by the MP:

image

The result displayed by the SQL query matches the Event view shipped with the FEP MP:

SNAGHTML87024d3

SNAGHTML8711770

and I have used the Data Warehouse DB variable in the SQL plugin configuration:

image

You can download this dashboard from Squared Up’s community site: https://community.squaredup.com/browse/download-info/forefront-endpoint-protection-2/

Lastly, please always test and tweak to query to need your requirements in SQL Management Studio first.

Automating OpsMgr Part 17: Creating Windows Service Management Pack Template Instance

Written by Tao Yang

OpsMgrExntededThis is the 17th instalment of the Automating OpsMgr series. Previously on this series:

Now that I have demonstrated how to create basic Windows service monitors using New-OMServiceMonitor, in this post, I’ll demonstrate how to use the OpsMgrExtended module to create an instance of the “Windows Service” management pack template:

image

The OpsMgrExtedned module comes with a function called New-OMWindowsServiceTemplateInstance. Same as all other functions in this module, it is fully documented, you can access the help document using Get-Help cmdlet:

Get-Help New-OMWindowsServiceTemplateInstance –Full

SNAGHTML2e5dc32

Sample Runbook New-WindowsServiceTemplateInstance

I have hardcoded the following parameters in the runbook:

  • SMA OpsMgr connection object name (which you will need to change to suit your environment)
  • (Unsealed) MP (where the rule  is going to be saved to) – “TYANG.Test.Windows.Monitoring”

Additionally, this runbook will firstly try to retrieve the management pack from the management group, if the MP deosn’t exist, it will create it first.

This runbook takes the following input parameters:

  • InstanceDisplayName– The Display name of the template instance.
  • InstanceDescription– This is an optional parameter. The description of the template instance.
  • TargetGroupName– The name of the target group
  • ServiceName–The name of the Windows service (i.e. w32time)
  • LocaleId– The 3-letter MP language pack locale ID. This is an optional parameter, if not specified, it will be set to “ENU”.
  • CheckStartupType– Set this Boolean parameter to True if you only want to monitor automatic service. More details about this parameter can be found from Kevin Holman’s blog post Monitoring Windows Services – Automatic, Manual, and Disabled, using CheckStartupType
  • CPUPercent– Specify the threshold for CPU Usage Percentage. This is an optional parameter, if not specifiied, the CPU Usage will not be monitored or collected.
  • MemoryUsageMB– Specify the threshold for Memory Usage (MB). This is an optional parameter, if not specifiied, the Memory Usage will not be monitored or collected.
  • ConsecutiveSampleCount– Specify the the number of (consecutive) samples for the CPU and Memory counters, This is an optional parameter. if not specified, the value is set to 2 (which is the default value when using the wizard in the OpsMgr console).
  • PollingIntervalInSeconds- Specify sample polling interval (in seconds). This is an optional parameter, if not specifiied, the value is set to 300 (which is the default value when using the wizard in the OpsMgr console).

To help you visualise what are these parameters mean, I’ve mapped them to the fields in the GUI wizard:

image

image

image

Runbook Execution Result:

image

A Known Issue

When I was writing the sample runbook, I found a small bug in the OpsMgrExtended module. You may noticed from the screenshots above, that the description field is not populated. I have found the cause of this issue and fixed it in my lab. This fix will be shipped with the next release. So please just be aware of this issue, I don’t think it’s too critical.

Conclusion

In this post, I have demonstrated how to create Windows Service MP template instances using the OpsMgrExtended module. This concludes the topics of monitoring Windows services. In the next module, I will demonstrate how to create any types of generic rules by specifying the configuration of each member module (Data Source, Condition Detection and Write Action) using the New-OMRule function. Until next time, happy automating!

Automating OpsMgr Part 16: Creating Windows Service Monitors

Written by Tao Yang

OpsMgrExntededIntroduction

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

I will dedicate this post and the next post to creating monitoring solutions for Windows services. In this post, I will demonstrate how to create a basic Windows service monitor using the New-OMServiceMonitor function from the OpsMgrExtended module.

You can access the help document for this function using the Get-Help cmdlet:

Get-Help New-OMServiceMonitor –Full

SNAGHTMLb42d9c

Sample Runbook: New-ServiceMonitor

I have hardcoded the following parameters in the runbook:

  • SMA OpsMgr connection object name (which you will need to change to suit your environment)
  • (Unsealed) MP (where the rule  is going to be saved to) – “TYANG.Test.Windows.Monitoring”

Additionally, this runbook will firstly try to retrieve the management pack from the management group, if the MP deosn’t exist, it will create it first.

This runbook takes the following input parameters:

  • ClassName – The name of the target monitoring class (i.e.Microsoft.Windows.Server.OperatingSystem)
  • UnhealthyState– The unhealthy state of the monitor (either warning or error).
  • ServiceName–The name of the Windows service (i.e. w32time)
  • IgnoreStartupType– Set this Boolean parameter to True if you want the monitor to become unhealthy and generate alerts even when the service startup type is not set to “Automatic”. More details about this parameter can be found from Kevin Holman’s blog post Monitoring Windows Services – Automatic, Manual, and Disabled, using CheckStartupType
  • UnhealthyWhenRunning – Set this Boolean parameter to True when you want the monitor to become unhealthy and generate alert when the service is running (instead of stopped)
  • MonitorDisabled– Boolean, whether the event monitor should be disabled by default
  • MonitorDisplayName– Display name of the unit monitor
  • MonitorName – The name of the unit monitor
  • ParentMonitor – The parent dependency monitor for the event unit monitor

Runbook Execution Result:

image

Monitor Properties from OpsMgr Console:

image

image

image

image

Conclusion

In this post, I have shown how to create a basic windows service monitor using a simple SMA / Azure Automation runbook with New-OMServiceMonitor function in the OpsMgrExtended module. In the next post, I will show you how to create an instance of the Windows Service management pack template using the OpsMgrExtended module.

Squared Up Dashboards Community

Written by Tao Yang

2015-10-01_16-58-17

Squared Up has recently established a brand new web site: https://community.squaredup.com. This is where everyone in the community is able to share Squared Up dashboards. So, it’s pretty similar to TechNet Gallery, but only for Squared Up dashboards.

So far, I have produced dashboards for all products in the System Center 2012 (R2)suite. I am planning to share few more dashboards via this site, but for now, I’d like to show you what I have shared so far, and what other awesome dashboards a currently available for download.

My System Center 2012 R2 Suite Dashboards

ConfigMgr 2012 (R2)

Download from: https://community.squaredup.com/browse/download-info/configmgr-2012/

SCVMM 2012 R2

Download from: https://community.squaredup.com/browse/download-info/scvmm-2012-r2/

SCSM 2012 R2

Download from: https://community.squaredup.com/browse/download-info/service-manager-2012-r2/

Orchestrator 2012 R2 (Microsoft Official MP Only)

Download from: https://community.squaredup.com/browse/download-info/orchestrator-2012-r2/

Orchestrator 2012 R2 (Official MP + MPAuthor’s Orchestrator MP)

Download from: https://community.squaredup.com/browse/download-info/scorch-2012-r2-combined/

Note:

This dashboard requires the modified version of MPAuthor’s Orchestrator MP, which can be found from this blog: http://blog.tyang.org/2015/09/14/updated-mp-authors-system-center-2012-orchestrator-management-pack/

SMA 2012 R2

Download from: https://community.squaredup.com/browse/download-info/sma-2012-r2/

Windows Azure Pack (Microsoft Official MP)

Download from: https://community.squaredup.com/browse/download-info/windows-azure-pack-msft/

Windows Azure Pack (Based on Oskar Landman’s WAP MP V2)

Download from: https://community.squaredup.com/browse/download-info/wap-community/

Note:

The screenshot provided does not contain any subscription perf data because I do not have any subscriptions created in my lab environment. However, the author of this MP, Oskar Landman has verified this dashboard against his environment, and confirmed the performance plugin is configured correctly.

OpsMgr Self Maintenance (Based on OpsMgr Self Maintenance MP 2.5.0.1)

Download from: https://community.squaredup.com/browse/download-info/opsmgr-self-maintenance/

Other Awesome Dashboards

In addition to the dashboards I’ve created for the System Center 2012 R2 suite, there are also other awesome dashboards that I think you should take a look:

Office 365 (Created by myself)

Download from: https://community.squaredup.com/browse/download-info/office-365/

Veeam Hyper-V (Created by Steve Turnbull)

Download from: https://community.squaredup.com/browse/download-info/veeam-hyper-v/

OpsLogix Oracle (Created by Arjan Vroege)

Download from: https://community.squaredup.com/browse/download-info/opslogix-oracle-dashboard/

Capacity Usage (Created by Dieter Wijckmans)

Download from: https://community.squaredup.com/browse/download-info/capacity-usage-8/

SharePoint 2013 (Created by myself)

Download from: https://community.squaredup.com/browse/download-info/sharepoint-2013/

OpsMgr Community Dashboard (Created by Martin Nygaard Ehrnst)

Download from: https://community.squaredup.com/browse/download-info/opsmgr/

About Squared Up Community Dashboards

Please visit https://squaredup.com/community/ If you’d like to learn more about Squared Up’s Community Dashboards initiative. It is really easy to export your dashboards and share with the community. We will sanity check all dashboards submission before publishing it to the public, this is to ensure no sensitive information about your environment is shared with the public.