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:
<RuleId>$MPElement$</RuleId> <GroupInstanceId>$MPElement[Name="Custom.Group.Example.DiskGroupSQLNonSystem"]$</GroupInstanceId> <MembershipRules> <MembershipRule> <MonitoringClass>$MPElement[Name="MicrosoftWindowsServerLibrary!Microsoft.Windows.Server.LogicalDisk"]$</MonitoringClass> <RelationshipClass>$MPElement[Name="MicrosoftSystemCenterInstanceGroupLibrary!Microsoft.SystemCenter.InstanceGroupContainsEntities"]$</RelationshipClass> <Expression> <And> <Expression> <SimpleExpression> <ValueExpression> <Property>$MPElement[Name="Windows!Microsoft.Windows.LogicalDevice"]/Name$</Property> </ValueExpression> <Operator>NotEqual</Operator> <ValueExpression> <Value>C:</Value> </ValueExpression> </SimpleExpression> </Expression> <Expression> <Contained> <MonitoringClass>$MPElement[Name="Windows!Microsoft.Windows.Computer"]$</MonitoringClass> <Expression> <Contained> <MonitoringClass>$MPElement[Name="MicrosoftSQLServerLibrary!Microsoft.SQLServer.ComputerGroup"]$</MonitoringClass> </Contained> </Expression> </Contained> </Expression> </And> </Expression> </MembershipRule> </MembershipRules> </Configuration>
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.
Could you do a Contain with a class instead of a group? Example….All Page files (E:) that are on Domain Controllers?
You can, but I’m not sure I understand what you are after? Do you just want a Group, of Logical Disks (Class), with a Property of Drive Letter “E:”, and HOSTED by a Domain Controller Computer?
Yep! I know I could probably use the Active Directory Domain Controllers Group (assuming one exists) but it feels more efficient to use a class if possible.
You can use class. I am not sure if it is more efficient or not. Here is a class example: https://kevinholman.com/2020/07/09/how-to-create-a-scom-group-of-disks-that-are-related-to-an-application-using-contained-and-contains/
I think I picked the idea about efficiency from knowing that nested Groups in SCOM are bad, due to the enumeration of the groups within the groups (we saw terrible performance doing this in our environment many years ago). So when I see a discovery here that says ‘Contained by any servers in THIS group’ then that feels like a similar type of nesting / enumeration required. Thanks for the example, will defo try that.
hello Kevin,
Please wich tool to use to realise this action? I tried with Visual Studio bau didn’t get the same menus as you.
Thanks
This is the old SCOM 2007 R2 authoring tool. Nowadays I just create a group, then use XML editing to change the group expression.
Hi Kevin, just stumbled across this Gem that I really need. Is it possible to do this using MP Author? I tried but could not find Microsoft.SQLServer.(Core)Library.mp using SCOM2019 Template. If not, where can i find SCOM Authoring Console 2007 R2 assuming it still works with SCOM2019 and above?