SCOM 2016 - How to get thresold details for important monitors

Dhruvika G 6 Reputation points
2021-05-03T12:12:41.09+00:00

Hi Team,

We have SCOM 2016 in our environment. Please let me know how to get the threshold details for basic monitors such as CPU, memory , disk space and other basic monitors at one go.

System Center Operations Manager
System Center Operations Manager
A family of System Center products that provide infrastructure monitoring, help ensure the predictable performance and availability of vital applications, and offer comprehensive monitoring for datacenters and cloud, both private and public.
1,609 questions
Microsoft System Center | Other
0 comments No comments
{count} vote

4 answers

Sort by: Most helpful
  1. AlexZhu-MSFT 6,591 Reputation points Moderator
    2021-05-04T02:03:50.92+00:00

    Hi,

    It seems the following script works for the problem.

    function GetThreshold ([String] $configuration)  
    {  
    	$config = [xml] ("<config>" + $configuration + "</config>")  
    	$threshold = $config.Config.Threshold  
    	if($threshold -eq $null)  
    	{  
    		$threshold = $config.Config.MemoryThreshold  
    	}  
    	if($threshold -eq $null)  
    	{  
    		$threshold = $config.Config.CPUPercentageThreshold  
    	}  
    	if($threshold -eq $null)  
    	{  
    		if($config.Config.Threshold1 -ne $null -and $config.Config.Threshold2 -ne $null)  
    		{  
    			$threshold = "first threshold is: " + $config.Config.Threshold1 + " second threshold is: " + $config.Config.Threshold2  
    		}  
    	}  
    	if($threshold -eq $null)  
    	{  
    		if($config.Config.ThresholdWarnSec -ne $null -and $config.Config.ThresholdErrorSec -ne $null)  
    		{  
    			$threshold = "warning threshold is: " + $config.Config.ThresholdWarnSec + " error threshold is: " + $config.Config.ThresholdErrorSec   
    		}  
    	}  
      
    	if($threshold -eq $null)  
    	{  
    		if($config.Config.LearningAndBaseliningSettings -ne $null)  
    		{  
    			$threshold = "no threshold (baseline monitor)"  
    		}  
    	}  
    	return $threshold  
    }  
      
    Function GetFrequency ([String] $configuration)  
    {  
    	$config = [xml] ("<config>" + $configuration + "</config>")  
    	$Frequency = $config.Config.Frequency  
    	if($Frequency -eq $null)  
    	{  
    		$frequency = $config.Config.Frequency;  
    	}  
    	 return ($frequency)  
    }  
      
    Function GetNumsamples ([String] $configuration)  
    {  
    	$config = [xml] ("<config>" + $configuration + "</config>")  
    	$Samples = $config.Config.Samples  
    	if($Samples -eq $null)  
    	{  
    		$Samples = $config.Config.NumSamples;  
    	}  
    	 return ($Samples)  
    }  
      
    Function GetCounterName ([String] $configuration)  
    {  
    	$config = [xml] ("<config>" + $configuration + "</config>")  
    	$Counter = $config.Config.Counter  
    	if($Counter -eq $null)  
    	{  
    		$Counter = $config.Config.CounterName;  
    	}  
    	 return ($Counter)  
    }  
      
    Function GetObject ([String] $configuration)  
    {  
    	$config = [xml] ("<config>" + $configuration + "</config>")  
    	$Object = $config.Config.Object  
    	if($Object -eq $null)  
    	{  
    		$Object = $config.Config.ObjectName;  
    	}  
    	 return ($Object)  
    }  
      
    $perfMonitors = get-scommonitor   
    $perfMonitors | select-object @{Name="MP";Expression={ foreach-object {$_.GetManagementPack().DisplayName }}},@{name="Target";expression={foreach-object {(Get-SCOMClass -Id:$_.Target.Id).DisplayName}}},DisplayName,enabled,@{name="Threshold";expression={foreach-object {GetThreshold $_.Configuration}}}, @{name="Frequency";expression={foreach-object {GetFrequency $_.Configuration}}}, @{name="Samples";expression={foreach-object {GetNumSamples $_.Configuration}}}, @{name="Counter";expression={foreach-object {GetCounterName $_.Configuration}}}, @{name="Object";expression={foreach-object {GetObject $_.Configuration}}} | sort Target, DisplayName | export-csv "c:\export\PerformanceMonitors.csv"  
    

    the sample output for your reference.

    93436-scom-get-threshold.png

    Alex
    If the response is helpful, please click "Accept Answer" and upvote it.

    1 person found this answer helpful.
    0 comments No comments

  2. Dhruvika G 6 Reputation points
    2021-05-04T14:55:44.223+00:00

    Hi

    93560-image.png

    I get get-scommonitor is not recognized error. Please let me know how to enable it.

    0 comments No comments

  3. Dhruvika G 6 Reputation points
    2021-05-04T19:03:12.45+00:00

    Hi,

    I executed the script and got the output. The threshold details shown in the attachment gives only the default threshold I believe. Could you please let me know how to extract the override threshold set on SCOM,

    Your solution would be of great help to me.

    0 comments No comments

  4. AlexZhu-MSFT 6,591 Reputation points Moderator
    2021-05-05T07:17:45.84+00:00

    Hi,

    Unfortunately, there is no existing solution to combine the overrides and the default threshold together. To get the overrides, we may try the following scripts to see if it works. (I am not an expert of PS, just tested in my lab)
    Note: please substitute the server name "x" with the actual one in your environment, as well as the file location.

    Add-PSSnapin "Microsoft.EnterpriseManagement.OperationsManager.Client"  
    Set-Location "OperationsManagerMonitoring::"  
    $rootMS = "x"  
    new-managementGroupConnection -ConnectionString:$rootMS  
    Set-Location $rootMS  
      
    #define the path you want to export the CSV files to   
      
    $exportpath = "c:\export\"  
      
    #gets all UNSEALED MAnagement PAcks   
    $mps = get-managementpack | where {$_.Sealed -eq $false}  
      
    foreach ($mp in $mps)  
      
    {  
    	$mpname = $mp.name  
    	Write-Host "Exporting Overrides info for Managemetn Pack: $mpname"  
    	#array to hold all overrides for this MP  
    	$MPRows = @()  
    	#Gets the actual override objects  
    	$overrides = $mp | get-override  
    	#loops thru those overrides in order to extract information from them  
    	foreach ($override in $overrides)  
      
    	{  
    		#Prepares an object to hold the result  
    		$obj = new-object System.Management.Automation.PSObject  
    		#clear up variables from previous cycles.  
    		$overrideName = $null  
    		$overrideProperty = $null  
    		$overrideValue = $null  
    		$overrideContext = $null  
    		$overrideContextInstance = $null  
    		$overrideRuleMonitor = $null  
      
    		# give proper values to variables for this cycle. this is what we can then output.  
    		$name = $mp.name  
    		$overrideName = $override.Name  
    		$overrideProperty = $override.Property  
    		$overrideValue = $override.Value  
    		$OverrideTimeAdded = $override.TimeAdded  
    		$overrideLastModified = $override.LastModified  
      
    		trap { $overrideContext = ""; continue }  
    		$overrideContext = $override.Context.GetElement().DisplayName  
    		trap { $overrideContextInstance = ""; continue }  
    		$overrideContextInstance = (Get-MonitoringObject -Id $override.ContextInstance).DisplayName  
      
    		if ($override.Monitor -ne $null)  
    		{  
    			$overrideRuleMonitor = $override.Monitor.GetElement().DisplayName  
    		}  
    		elseif ($override.Discovery -ne $null)  
    		{  
    			$overrideRuleMonitor = $override.Discovery.GetElement().DisplayName  
    		}  
    		else  
    		{  
    			$overrideRuleMonitor = $override.Rule.GetElement().DisplayName  
    		}  
    		#fills the current object with those properties  
    		$obj = $obj | add-member -membertype NoteProperty -name overrideRuleMonitor -value $overrideRuleMonitor -passthru  
    		$obj = $obj | add-member -membertype NoteProperty -name overrideProperty -value $overrideProperty -passthru  
    		$obj = $obj | add-member -membertype NoteProperty -name overrideValue -value $overrideValue -passthru  
    		$obj = $obj | add-member -membertype NoteProperty -name overrideContext -value $overrideContext -passthru  
    		$obj = $obj | add-member -membertype NoteProperty -name overrideContextInstance -value $overrideContextInstance -passthru  
    		$obj = $obj | add-member -membertype NoteProperty -name MPName -value $name -passthru  
    		$obj = $obj | add-member -membertype NoteProperty -name overrideName -value $overrideName -passthru  
    		$obj = $obj | add-member -membertype NoteProperty -name LastModified -value $OverrideTimeAdded -passthru  
    		$obj = $obj | add-member -membertype NoteProperty -name TimeAdded -value $overrideLastModified -passthru  
      
    		#adds this current override to the array  
      
    		$MPRows = $MPRows + $obj  
    }  
      
    		#Store up the overrides for all packs to a single variable  
    		$MPRpt = $MPRpt + $MPRows  
    }  
      
    $Date = (Get-Date).ToString('dd-MM-yyyy')  
    $filename = $exportpath + $date + "overrides.csv"  
    $MPRpt | Export-CSV -path $filename -notypeinfo  
    

    Here's the screenshots for your reference:

    93840-scom-get-overrides.png

    Alex
    If the response is helpful, please click "Accept Answer" and upvote it.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.