Thursday, July 1, 2010

SCOM: Find those heavy group discoveries

Two days ago on the 'The Operations Manager Support Team Blog' a blog was posted about editing Groups and the slow Operation Manager Console. They advise to consolidate the number of membershiprules and expressions in regular expression.

But how do you know which groups are eligable for a consolidation? Well, for that I created this script.
It retrieves groups that comply with the given user input for the 'DisplayName'. For every group the Discovery information is retrieved. If the Discovery Configuration matches the prededined thresholds for the number of MembershipRules and/or Expressions, the output will be in red. Otherwise it will be in green. The threshold can be changed at will.

Download: ShowGroupDiscoveryDatasourceConfiguration.ps1

#User-input only works from within a script!
$strGroup = Read-Host "Enter a group discovery name (wildcard) string";

$intMembershipRuleThreshold = 3;
$intMembershipRuleExpressionThreshold = 5;
$intMembershipRuleCount = 0;
$intMembershipRuleExpressionCount = 0;

#These Id's are the base Id's which are usually used when creating groups
$strInstanceGroupBaseClassId = "4ce499f1-0298-83fe-7740-7a0fbc8e2449" #Instance group
$strComputerGroupBaseClassId = "0c363342-717b-5471-3aa5-9de3df073f2a" #Computer group

Write-Host "Retrieving class that match:" $strGroup;
$colGroups = Get-MonitoringClass | where {$_.DisplayName -match "$strGroup" -and $_.Base -ne $null} | Sort-Object -Property DisplayName

if ($colGroups -ne $null) {
$colGroups | foreach {
If (($_.Base.Id.ToString() -eq $strInstanceGroupBaseClassId) -Or ($_.Base.Id.ToString() -eq $strComputerGroupBaseClassId)){
Write-Host "Class:" $_.DisplayName;
$colDiscoveries = $_.GetMonitoringDiscoveries();
#check if discoveries exist
If ($colDiscoveries.Count -ne 0) {
$colDiscoveries | foreach {
Write-Host " Discovery:";
$config = [xml] ("" + $_.DataSource.Configuration + "");
#check wether Discovery uses membership rules
$intMembershipRuleCount = $config.GetElementsByTagName("MembershipRule").Count;
If($intMembershipRuleCount -gt 0){
If ($intMembershipRuleCount -ge $intMembershipRuleThreshold){
Write-Host " MembershipRules:" $intMembershipRuleCount -ForeGroundColor red;
} else {
Write-Host " MembershipRules:" $intMembershipRuleCount -ForeGroundColor green;
}
$intIndex = 0;
$config.config.MembershipRules.MembershipRule | %{
$intIndex++;
$intMembershipRuleExpressionCount = $_.GetElementsByTagName("Expression").Count;
If ($intMembershipRuleExpressionCount -gt 0) {
Write-Host " Membership Rule #$intIndex";
If ($intMembershipRuleExpressionCount -ge $intMembershipRuleExpressionThreshold){
Write-Host " Expression count:" $intMembershipRuleExpressionCount -ForeGroundColor red;
} else {
Write-Host " Expression count:" $intMembershipRuleExpressionCount -ForeGroundColor green;
}
}
$intMembershipRuleExpressionCount = 0;
}
}
$config = $null;
$intMembershipRuleCount = 0;
}
}
}
}
}
(ps. Save it as a script to use interactive User Input.)

2 reacties:

OdgeUK said...

This is 10 years old now. Are the thresholds that are considered to impact performance still the same in SCOM 2012 and 2016? Or is SCOM discovery a bit more efficient now?

Michiel Wouters said...

Hi Odge, despite being a decade old this is still applicable. As far as I know, the code base and components under the hood have not changed including SCOM 2019. Group Calculation is still something to think about. The thresholds used in this script is an example. If it returns too much groups, try to increase them. Also read some background information. Search for "SCOM group calculation". The first two hits show nice info.

Post a Comment