Unless you enjoy creating SCOM 2012 management packs by hand, you will want a tool to ease the creation of rules and monitors that target Windows Azure PaaS applications. Well you’re in luck with the new System Center 2012 Visual Studio Authoring Extensions (VSAE) for Visual Studio 2010 Professional, which you can download here. This blog will walk you through creating rules leveraging the new authoring tool. It takes some getting used to, but I believe you will appreciate how much more powerful the tool is in Visual Studio than the previous Authoring Console for SCOM 2007 R2. A huge shout out goes to my Microsoft Consulting Services colleague and SCOM “go to” guy, Ian Smith. If your organization needs a SCOM consultant extraordinaire, Ian is your man.
This will be a long post with all of the steps detailed. Once you get the hang of it, though, you’ll be ready to create management packs on your own with this powerful new authoring tool in no time. So let’s get going. Go ahead and launch Visual Studio 2010. Create a new project and verify that you have the Management Pack templates installed as seen below. If you do, then select the first template titled Operations Manager 2012 Add-on Management Pack, and select OK. The reason you must select this one is because this template corresponds to the SCOM 2012 schema, while the Operations Manager Core template corresponds to the SCOM 2007 schema. If you select Operations Manager Core, you won’t be able to reference the new Management Pack bundle (.MPB) files that are only compatible with SCOM 2012.
Important Note: Before moving ahead, please verify that the Azure deployment you are monitoring with SCOM 2012 is writing out the performance counters that correspond to the rules you will be creating here. You don’t have to create the same rules as I do. Create the rules for the performance counters that you write. We will do a total of four for training and testing purposes, and then you can go back to the project and add more as needed.
Expand the References node, which should look as seen below.
In order for us to create our new rule(s) for Windows Azure subscriptions, we will need references to existing management pack libraries. In my case, I installed Visual Studio 2010 on the management server, so all of the management pack references will be on the server. If you didn’t install VSAE on your Management Server, then you will want to install any references not already included with VSAE into the Program Files (x86)\System Center 2012 Visual Studio Authoring Extensions\References\OM2012 folder. For more info on reference “do’s and don’ts”, see the TechNet article titled “System Center - Visual Studio Authoring Extensions,” which can be found here. For the purposes of this walkthrough, however, the only management pack we will reference that is not already included with VSAE is the Windows Azure management pack for System Center 2012. So if you are not working on a Management Server, go ahead and download the System Center 2012 Management Pack for Windows Azure from here, and then install it on your workstation. It will place the .mpb files in the Program Files (x86)\System Center Management Packs\System Center 2012 Management Pack for Windows Azure folder.
We will need to reference the Windows Azure management pack for SCOM 2012. Right-click the References node and select the Add References from Management Pack Bundle… from the popup menu, as seen below.
Navigate to the Program Files (x86)\System Center Management Packs\System Center 2012 Management Pack for Windows Azure folder, and find the Microsoft.SystemCenter.WindowsAzure.mpb management pack bundle file. Select the Open button.
Select OK when you see the acknowledgement dialog, as seen below.
You should now see the reference to the Windows Azure management pack in the list of references.
Next, we need to add a reference to the Data Warehouse management pack library. Right-click the References node again, and this time select just the Add Reference… item from the popup menu. Navigate to Program Files (x86)\System Center 2012 Visual Studio Authoring Extensions\References\OM2012.
Select the Microsoft.SystemCenter.DataWarehouse.Library.mp, and then select OK.
Now add another reference from the same location to System.Performance.Library.mp, as seen below.
When you’re done, your Solution Explorer should look as seen below.
Now we’re ready to add our first rule. Right-click on the project and select Add | New Item… from the popup menu. In the Add New Item dialog, select the Code node, and then select the Empty Management Pack Fragment template. Provide a name, such as Rules, then, select the Add button.
Your Visual Studio IDE should now look as seen below. Note in the Rules.mpx file that your management pack “fragment” uses schema version 2.0. Note that the reason this file is called a fragment is because it is only a part of the final management pack. The authoring tool will package up all the fragments and crank out a final management pack for you when you perform a build.
Now what we want is to not reinvent the wheel, so we will grab some XML from an existing management pack in order to create our new rule. Select the View menu, and then select the Management Pack Browser item, as seen below.
Once the browser opens, navigate in the left-hand side of the browser pane, expand the Microsoft.SystemCenter.WindowsAzure [126.96.36.199] node, and then select the Rules node. In the middle pane below select an existing rule (e.g., I have selected the Available Megabytes Performance Counter rule). We are going to grab the XML from an existing rule to create our new rule, which makes our job a lot easier.
Select and copy all of the XML text in the lower middle pane, as seen below.
Now let’s head back to our Rules.mpx file and prepare it for the rule XML we just grabbed. Add the lines as seen below in preparation for the pasting of our rule XML.
Now drop in your rule, as seen below, which we will modify for our own custom rule not included in the out-of-the-box Windows Azure management pack.
Now it is time to setup our aliases so our management pack code matches up with our references. Select the Microsoft.SystemCenter.WindowsAzure reference in the Solution Explorer, and then show the Properties page. As seen below, the default is MSW. We’re going to change this alias to Azure.
Go ahead and change the Alias property in the property page of Microsoft.SystemCenter.WindowsAzure to Azure. In the Rules.mpx file, prepend the TypeID attribute consisting of Microsoft.SystemCenter.WindowsAzure.RoleInstance.PerformanceCounter.CollectionData.DS with Azure followed by the delimiter !, exactly as seen below on Line 7. Don’t forget the delimiter!
Now scroll to the right on Line 4 and do the same with the Target attribute, as seen below.
Now select the Microsoft.SystemCenter.DataWarehouse reference, whose default alias is MSDL, as seen below.
Change the Alias property to SCDW, which will match up with what’s already in the Windows Azure management pack that we copied from.
Select the Microsoft.SystemCenter.Library reference, and verify that its Alias property matches up with the existing alias in our Rules file, as seen below.
Now let’s go ahead and change the existing rule to a different performance counter. As seen below, I’m changing the performance counter to Memory\Committed Bytes. Feel free to use whatever valid performance counter you would like that is being written by your Azure deployment(s).
Let’s now perform our first build. Resolve any issues and don’t move forward until you can successfully build. If you have followed all of the instructions to the letter, your build should be successful.
Build success, as seen below!
Now we need to create the display strings that we will see as the name in the Authoring view of the SCOM Operations Console. Go ahead and add a LanguagePacks (plural) element as seen below, after the Monitoring element.
Now head over to the Management Pack Browser and navigate to the Windows Azure management pack library LanguagePacks node, as seen below. Copy the first line with the LanguagePack (singular) opening element.
Now add the opening LanguagePack element and then add the closing element. Then add the DisplayStrings element, exactly as seen below.
Now head back over to the Management Pack Browser, and copy all of the LanguagePacks element of the Windows Azure management pack library, as seen below.
Open Notepad and copy the text into Notepad. Perform a a search in Notepad on “roleinstance.memory”, which should take you to the display string for the Available Memory performance counter. Copy the entire element, as seen below.
Now paste the display string into your rule as seen below. Note the three values you need to change to the Committed Bytes performance counter.
Next, make the three replacements, as seen below.
Go ahead and perform a build before proceeding.
We can always add more rules to our Rules.mpx file, but there is a better way. Now we will pursue a more automated way to crank out new rules using a template. Right-click on the project and add a new item. Select the Code node under the Management Pack templates, and then select the Snippet Template, as seen below, which has a templatesnippet file extension. Give it a name such as AzureRules and select the Add button.
Now, you will see that it has created a rule template for you, but this isn’t useful to you since it doesn’t use the Windows Azure data sources.
Go ahead and delete the rule in the template snippet, substituting it with the rule you created earlier in the Rules.mpx file, which is seen below.
Now remove the entire existing DisplayString element in the template snippet, and replace it with the DisplayString element from the rule you created earlier, which is seen below.
Your rule template should now look as seen below after grabbing the rule and its display string from the Rules.mpx file.
Now we will insert the variables needed for when we apply the template to create multiple rules from a wizard page (which we will see later, so be patient). Delete the object name in the rule ID attribute as seen below. Place your cursor where you deleted the object name and type Ctrl-<Space>. You will be presented with a popup with substitution options. Select the #text item from the popup menu.
The text variable won’t have a variable value in it, so you will have to provide that value. Type in ObjectName, as seen below.
Now do the same for the short counter name, substituting the text variable with CounterShortName, as seen below.
Within the DataSource element, navigate to the <CounterName> element, and delete the value. Use Ctrl-<Space> to substitute this with a #text variable as well. In this case, substitute with the variable CounterLongName.
Next, substitute the <ObjectName> element value immediately below with a #text variable named ObjectName.
Now scroll the windows over until you see the Target attribute of the rule. Highlight the “Azure” value, as seen below.
Use Ctrl-<Space> to substitute the “Azure” value with a #alias variable as seen below. Insert the value Microsoft.SystemCenter.WindowsAzure, as seen below.
Now find the <DataSource> element, and find the “Azure” value of the TypeID attribute, as seen below.
Substitute the “Azure” value with the value Microsoft.SystemCenter.WindowsAzure, as seen below.
In the <DisplayString> element, find the object and counter values and substitute just as you did for the rule above. You can see the two substitutions below.
Now in the <Name> element, make the necessary substitutions as seen below, and also make the substitutions for the <Description> element as well. You can see the substitutions below.
Go ahead and perform a build. Do not continue until you have a successful build.
Now we’re ready for the wizard page that leverages the template snippet and allows us to crank out rules by simply putting in the desired values. Right-click on the project and add a new item. This time select the Templates node in the Management Pack templates, and then select the Snippet item, as seen below. Provide a name such as AzureRuleGenerator, and then select the Add button.
You will now see a page that asks you to select a snippet type. Click on the button, as seen below.
Go ahead and choose the template snippet you just created, as seen below.
Now enter the values for the new performance counter rules you would like, as seen below. Unfortunately, you will have to enter the values for each time you created a variable, but it will autocomplete so you won’t have to type them again. My understanding is that this will be fixed in a future version so you only have to type a variable once.
When you’re done, just save the page, and the rules will be generated. You can always go back and make changes as well as add new rules. You can even import from a .csv file.
Now locate the rule generator in the Solution Explorer, which has a .mpsd extension. Expand it to find the generated file that has a .mpx extension (which is the same fragment extension as the rule you created manually earlier), and go ahead and open up the .mpx file. You can see below that it has written out all of the rules for you in the file with text and aliases appropriately substituted! When the final management pack is generated, your project will put all of these pieces together into a nice, neat management pack.
Let’s now scroll over and verify that the <Rule> element alias has been successfully substituted as well.
Scroll down to the <LanguagePacks> section, and you will see the display strings are generated as well. Very cool.
Perform a build now, and do not proceed until you have a successful build. We’re getting close to being done, but there is still a bit more work to do.
Now we’re going to create a display name and description for the entire management pack. Right-click on the project and open the properties page, as seen below. Select the link at the bottom titled Find or Create the Management Pack Display Name and Description. It will create a ManagementPack.mpx file and will open the file.
Below is the file Visual Studio just opened with the display strings for the management pack itself, which you can modify.
Below, I have modified the management pack display strings with more descriptive values.
Below, I added two additional elements. The <Presentation> element creates a folder in the SCOM Operations Console Monitoring view for you to use as a container for your management pack objects (such as performance views). We will create a performance view later using the rules we have created. The <DisplayString> element actually adds the text that will be the displayed name of the folder created above in the fragment file.
Below shows the file scrolled over showing what the ParentFolder attribute should look like. After you have finished, go ahead and build your project. Don’t proceed until you have a successful build.
We’re now all done and ready to test drive the management pack! Navigate to the bin\Debug folder of your project, as seen below. You will import the XML file as we’re not taking advantage of the features of the management pack bundle that was generated.
Go ahead and import the management pack into SCOM 2012, as seen below.
After a few minutes, verify that the management pack now shows up in the management pack list in the Administration view.
Next, head over to the Authoring view and navigate to the Rules node. In the right-hand pane, navigate to the Windows Azure Role Instance item as seen below.
By default, your rules will not be enabled, so right-click on each rule and select Enable from the popup menu.
Now we need to create a performance view to see the results of our new rules. Go to the Monitoring view, and select the folder we created in the authoring tool.
Right-click on the management pack folder. Select New | Performance View, as seen below.
Since in this blog we created Memory and TCPv4 performance objects, enter one of these headings in the name. Then select the button with the ellipsis (“…”) next to the Show data related to: field. In the Select Items to Target dialog, select the View all targets radio button, and then enter a search field such as “role instance”, as seen below. Find the Windows Azure Role Instance item in the list below, and then select the OK button.
Now select the collected by specific rules item in the Select conditions: listbox, as seen below. Next, select the specific link at the bottom of the dialog.
Find the desired rule(s), as seen below that match up with your heading (note that I’m selecting one of the Memory rules that I created). Once you have selected the desired rule(s), select the OK button.
You will now see your rule(s) at the bottom of the dialog. Accept the dialog.
It may take a while, but you should eventually see the list of performance counters that correspond to your rule(s). It is important to note that your deployment must be actually writing these performance counters, so if you don’t see anything after a few minutes, verify that the counters are being written.
Whew! We’re now done! See you again soon for some other System Center 2012 coolness we will be blogging about.