I had an interesting customer request. The customer has a boundary of responsibility where the OS/Hardware team is responsible for ALL C: drives on all servers. However, the individual application teams are responsible for ALL OTHER disks, which are used for applications.
Therefore, for notification purposes, the customer wanted to create groups of ALL disks, that are NOT the C: disk, but are on a SQL Server, or Exchange Server, etc…
The way we would accomplish this – is to create a group with an expression, where “Device Name” does NOT equal “C:”. That part is easy. But now we want to further restrict this to ONLY those disks that are on SQL Computers, or Exchange Computers…etc.
This cannot be done in the Console/UI at all, nor very easily using the Authoring console. You will have to do a little XML work, in conjunction with the Authoring console.
Lets get started – it will make more sense as we go.
- Open the Authoring Console. (NOT the Authoring pane on the simple Operator Console)
- Create a new Empty Management Pack
- Give the MP an ID (filename). Mine is “Custom.Group.Example”
- Give the MP a Display Name. Mine is “Custom Group Example”
The first thing we will need to do – is add some references to other Management Packs. This is because for this MP – we will be creating a new group (referencing the Microsoft.SystemCenter.InstanceGroup.Library.mp) and then grouping Logical Disks (defined in the Microsoft.Windows.Server.Library.mp) and then filtering based only on disks from computers contained in the “SQL Computers” group, which is defined in the Microsoft.SQLServer.Library.mp. Therefore – we will start by adding those references.
- Select File, Management Pack Properties.
- Select the References tab.
- Select Add Reference, and browse to the Microsoft.SystemCenter.InstanceGroup.Library.mp file, and click Open. (this is located on your RMS install path)
- Add Reference again, and browse to the Microsoft.Windows.Server.Library.mp file, which came with your Base OS MP download.
- Add Reference again, and browse to the Microsoft.SQLServer.Library.mp file, which came with your SQL MP download.
- When complete – they should appear as follows:
- Click OK to save and close the MP Properties.
- Select the Service Model Pane.
- Select Classes.
- In the white space to the right of “Classes”, right click and choose New > Custom Class.
- Give your new group class a meaningful ID, and click OK. In this example, mine will be “Custom.Group.Example.DiskGroupSQLNonSystem”
- On the General tab:
- For the Base Class: Browse, and choose a base class of Microsoft.SystemCenter.InstanceGroup
- For the Display Strings Name, give your new group a meaningful Display Name. Mine will be “Disk Group – SQL – Non System”
- Check the box next to “Singleton”
- Click OK to accept the new class.
- Select the Health Model Pane.
- Select Discoveries.
- In the white space to the right of “Discoveries”, right click and choose New > Custom Discovery
- Give your new discovery a meaningful ID. In this example, mine will be “Custom.Group.Example.PopulateDiskGroupSQLNonSystem”
- On the General Tab:
- Give your new discovery a meaningful Display Strings Name. Mine will be “Discovery to Populate Disk Group – SQL – Non System”
- Choose a target class, which will be the Group class we just created earlier
- Select the “Discovered Classes” tab.
- On the “Discovered relationships and their attributes” – Click “Add” and add Microsoft.SystemCenter.InstanceGroupContainsEntities here.
- Select the Configuration tab.
- Click “Browse for a Type”
- Look for the word “Group” and select Microsoft.SystemCenter.GroupPopulator
- Type in “GP” for the module ID.
- You may get a popup error. Ignore it and hit close.
- On the configuration screen – select “Edit”
- This brings up Notepad and shows you the XML for your group.
From here – it gets a bit more complicated, as you have to be a bit more familiar with using XML and MP variables.
We will be replacing the XML showing in Notepad with an example I have written. Highlight all but the first line and delete it:
Now – here is an example discovery expression that accomplishes our goals:
The GroupInstanceId is simply your custom group ID.
The remainder is a Membership Rule for the group. We are stating:
The MonitoringClass (Instances of what the group will actually contain) is Microsoft.Windows.Server.LogicalDisk (defined in the Microsoft.Windows.Server.Library.mp)
The RelationshipClass simply states that our singleton group class has a containment relationship over the instances in the group.
The remainder is an Expression for the Discovery.
There are two expressions. The first states to add all Logical Devices, where the Name property does not = “C:”
The second expression is a bit more complicated. It states that the Logical Disk MUST BE CONTAINEDby a Windows Computer object that is a member of the “SQL Computers” group.
The expressions are combined with an “And” so both must be met to be included in the group.
- You should be able to paste in this XML into your Notepad Window, then close it.
- Click OK to save the discovery.
- Save your Management Pack to disk for a backup.
- From the Tools menu, choose “Export MP to Management Group”
Now – find your group in the Authoring Pane of the Console/UI.
Right click the group, and choose “View Group Members”
After enough time has passed for the group populator to run (sometimes up to 30 minutes) you will see only Non C: disks from your SQL servers:
You should be able to use this same example – to create groups, which dynamically contain objects of ANY class, that are also only present when hosted by Windows Computers of another group. We can now use these groups for VERY granularly targeted overrides, notifications, and state views.