This is part 7 in a series of posts described here: https://kevinholman.com/2016/06/04/authoring-management-packs-the-fast-and-easy-way-using-visual-studio/
In our next example fragment – we will create custom groups and add them to our MP.
Groups are a critical part of any management pack. We will use them for overrides, to scope monitoring views, and to scope subscriptions.
I like to consider adding one or more of two different types groups to most of my custom application MP’s, depending on how you use SCOM.
First – a group of all instances of my custom class.
I will use this for overrides, and subscriptions, where needed.
Second – a group of all Windows Computer objects that contain an instance of my custom class…. and the respective Health Service Watcher object related to each Computer.
I will use this to scope console views so I can expose more monitoring data about the computers running my app – to app owners. It can also be used for subscriptions and overrides, since these computers host (and therefore contain) my class. We want the Health Service Watcher objects when I need to allow app owners know when their computers are down – so they can see “Heartbeat” and “Computer Down” alerts.
I have created fragments which add groups independently, so you can pick and choose. Don’t just add them all for every MP you make, because if you are a large enterprise, you might end up with too many groups (I’m talking >1000 here), which can cause SCOM to get overloaded.
Step 1: Download and extract the sample MP fragments. These are available here: https://github.com/thekevinholman/FragmentLibrary
I will update these often as I enhance and add new ones, so check back often for new versions.
Step 2: Open your newly created MP solution, and open Solution Explorer. This solution was created in Part 1, and the class was created in Part 2.
Step 3: Create a folder and add the fragment to it.
Create a folder called “Groups” in your MP, if you don’t already have this folder.
Right click Groups, and Add > Existing item.
Find the fragment named “Class.Group.ClassInstances.mpx” and add it.
Select Class.Group.ClassInstances.mpx in solution explorer to display the XML.
Step 4: Find and Replace
Replace ##CompanyID## with our company ID which is “Fab”
Replace ##AppName## with our App ID, which is “DemoApp”
Replace ##ClassID## with the custom class we created in Part 2 of the series. This was “Fab.DemoApp.Server.Class” from our previous class fragment.
That took all of 2 minutes. Take another few minutes to review the XML we have in this fragment. It is a simple class definition for our group, a discovery to populate the group, along with DisplayStrings for displaynames for each.
Step 5: Build the MP. BUILD > Build Solution.
DOH!
Error 92 Cannot resolve identifier MSIL!Microsoft.SystemCenter.InstanceGroup in the context of management pack Fab.DemoApp. Unknown alias: MSIL C:\Program Files (x86)\MSBuild\Microsoft\VSAC\Microsoft.SystemCenter.OperationsManager.targets 255 6 Fab.DemoApp
This is because the group fragment needs a reference to the Instance Group Library.
In Solution Explorer – add a reference by right clicking “References” and choose “Add Reference”
VSAE came with a bunch of common reference files – so browse to C:\Program Files (x86)\System Center Visual Studio Authoring Extensions\References folder. Pick the version of SCOM you want to be able to import this into, and select the “Microsoft.SystemCenter.InstanceGroup.Library.mp”.
Highlight this MP in Solution Explorer under References, and in the properties window you will see the default Alias used, which you can change if necessary. I used the default VSAE reference aliases in all my fragments.
Now Save All, then BUILD again.
Boom!
Step 6: Import or Deploy the management pack.
Step 7: Test the MP.
Open the Authoring pane of the console – and select “Groups”
Find your new DemoApp Instance group:
Right click and View Group Members:
(Note: This may take a few minutes in your environment for Group Population to run, and generate new config)
At this point – you can repeat these same steps for some other group fragments:
Class.Group.WindowsComputers.mpx
Class.Group.WindowsComputersAndHealthServiceWatchers.mpx
Hi Kevin,
Your MP fragments are great and makes our life easier 🙂
But I`m struggling with a problem when creating a group of Windows Computers that contain another class. That is based on Class.Group.WindowsComputers.mpx
I think I do everything by the book. MP Build is successful, I have tried to seal MP. Import works as expected but when a group calculation runs I hit this error:
EventID 31415:
The group membership calculation is exiting on an unrecoverable exception: System.Xml.Schema.XmlSchemaValidationException: A schema error occurred.
And this is full xml of the MP I`m importing.
What am I doing wrong 🙂 ????
Lind.Tech.Group
1.0.0.5
Lind.Tech.Group
Microsoft.SystemCenter.InstanceGroup.Library
7.5.8501.0
31bf3856ad364e35
Microsoft.SystemCenter.Library
7.0.8437.0
31bf3856ad364e35
Microsoft.Windows.Library
7.5.8501.0
31bf3856ad364e35
Microsoft.Windows.Server.AD.2008.Discovery
6.0.8321.0
31bf3856ad364e35
System.Library
7.5.8501.0
31bf3856ad364e35
Discovery
$MPElement$
$MPElement[Name=”Lind.Tech.Computers.Group”]$
$MPElement[Name=”Windows!Microsoft.Windows.Computer”]$
$MPElement[Name=”MSIL!Microsoft.SystemCenter.InstanceGroupContainsEntities”]$
$MPElement[Name=”AD2008Discovery!Microsoft.Windows.Server.2008.AD.DomainControllerRole”]$
CS AD Computers Group
CS AD Computers Group Discovery
This discovery rule populates a group of Windows Computer Objects that contain a Windows Server Domain Controller instance
After adding the fragment Class.Group.WindowsComputer i get many Warnings in event viewer EventID 10457 , Source=Health Service Modules :
“Échec du prochain appel
Espace de noms \\.\ROOT\CIMV2
Requête SELECT Timestamp_PerfTime,Frequency_PerfTime,TimeStamp_Sys100NS,Name,HandleCount FROM Win32_PerfRawData_PerfProc_Process WHERE IDProcess=4632
HRESULT 0x80041017 Détails Demande non valide
Au moins un flux de travail est affecté.
Nom du flux de travail : Microsoft.SystemCenter.NTService.CollectHandleCount
Nom de l’instance : Data Access Service – SCORPOWLSCOM1A.ile.mtl.qc.ca
ID de l’instance : {35791C12-E9FF-E343-8707-B40470C20E2C} ”
We are running on Windows Server 2019 (version 1809, 17763.973)!
Could this be related to this version of Windows Server?
Hi Kevin,
Your fragments sure are helpfull, I’ve been using the fragment ‘Class.Group.PowerShellWindowsComputers.mpx’ quite succesvul the last few days.
But the last group I’m to create with Visual Studio Authoring Extensions has me stumped.
This class doesn’t contain any properties, but it’s base, ‘Microsoft.SQLServer.Core.AvailabilityReplica’, does. Only property UniqueId has Key=true.
I’m trying to create a group for the class ‘Microsoft.SQLServer.Windows.AvailabilityReplica’, for this I have this code in powershell:
$ServerInstance = $DiscoveryData.CreateClassInstance(“$MPElement[Name=’MSWD!Microsoft.SQLServer.Windows.AvailabilityReplica’]$”)
$ServerInstance.AddProperty(“$MPElement[Name=’SqlCoreLib!Microsoft.SQLServer.Core.AvailabilityReplica’]/UniqueId$”, $UniqueId)
$ServerInstance.AddProperty(“$MPElement[Name=’SqlCoreLib!Microsoft.SQLServer.Core.DBEngine’]/MachineName$”, $MachineName)
$ServerInstance.AddProperty(“$MPElement[Name=’SqlCoreLib!Microsoft.SQLServer.Core.DBEngine’]/InstanceName$”, $InstanceName)
$RelationshipInstance = $DiscoveryData.CreateRelationshipInstance(“$MPElement[Name=’Team.SQL.ADBased.TeamSQLReplica.ScriptBased.Group.Contains.AvailabilityReplica’]$”)
$RelationshipInstance.Source = $GroupInstance
$RelationshipInstance.Target = $ServerInstance
$DiscoveryData.AddInstance($RelationshipInstance)
The following classes and relationships should be made
But each time I try to build the MP I get an error.
The configuration specified for Module DS is not valid.
: Cannot find specified MPElement SqlCoreLib!Microsoft.SQLServer.Core.AvailabilityReplica in expression: $MPElement[Name=’SqlCoreLib!Microsoft.SQLServer.Core.AvailabilityReplica’]/UniqueId$
Cannot resolve identifier SqlCoreLib!Microsoft.SQLServer.Core.AvailabilityReplica in the context of management pack Team.SQL.AD.Based.Groups. Unknown alias: SqlCoreLib (Path = Team.SQL.ADBased.TeamSQLReplica.ScriptBased.Group.Discovery/DS)
I have added the MP to the references, it has the same version as MP MSWD ‘Microsoft.SQLServer.Windows.Discovery’. Do you know what I have done wrong?
Hi Kevin,
i create a class that is base class is “Windows!Microsoft.Windows.Computer”. when I’m using this fragment , the servers that was entered successfully to the class, not entered to the group by this fragment.
of course that when I’m create class that is base class is “local application” everything is working