locked
Monitors and rules with alert thresholds RRS feed

  • Question

  • Hi,,

    I need to export Monitors and rules with alert thresholds in SCOM SP1. So please let me know,

    How can i get this via power shell/Operation manager shell script. i am using that given script. But i only get a blank folder in C drive.

    Thanks,

    Gourav

    md C:\Thresholds
    
    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
    }
    $perfMonitors = get-monitor -Criteria:"IsUnitMonitor=1 and Category='PerformanceHealth'"
    $perfMonitors | select-object @{name="ManagementPack";expression={foreach-Object {$_.GetManagementPack().DisplayName}}}, @{name="Target";expression={foreach-object {(Get-MonitoringClass -Id:$_.Target.Id).DisplayName}}},DisplayName, @{name="Threshold";expression={foreach-object {GetThreshold $_.Configuration}}}, @{name="AlertOnState";expression={foreach-object {$_.AlertSettings.AlertOnState}}}, @{name="AutoResolveAlert";expression={foreach-object {$_.AlertSettings.AutoResolve}}}, @{name="AlertSeverity";expression={foreach-object {$_.AlertSettings.AlertSeverity}}} | sort ManagementPack, DisplayName | export-csv "c:\thresholds\monitor_thresholds.csv"
    

    Tuesday, January 10, 2017 9:26 AM

Answers

  • Hi Gourav,

    there is no real way how you can export the thresholds for all monitors/rules with PowerShell as you would need to know the config for each monitor/rule and adjust the script for each one. That all depends on the MonitorTypes and DataSource configurations which are used.

    Even if you use SQL to query some monitor details, you would need to check the Overrides also and the XML information is not reader friendly:

    SELECT MonitorName, ConfigurationXML
    /*count (*)*/
      FROM [OperationsManager].[dbo].[Monitor]
      where isunitmonitor=1 and monitorenabled <>0

    Example output for ConfigurationXML:
    <IntervalSeconds>60</IntervalSeconds><SyncTime/><ConnectionString>$Target/Host/Property[Type="SQL!Microsoft.SQLServer.DBEngine"]/ConnectionString$</ConnectionString><ObjectName>$Target/Host/Property[Type="SQL!Microsoft.SQLServer.DBEngine"]/PerformanceCounterObject$:Database</ObjectName><CounterName>Log Free Space (%)</CounterName><InstanceName>$Data/Property[@Name='Database']$</InstanceName><DatabaseName>$Target/Property[Type="SQL!Microsoft.SQLServer.Database"]/DatabaseName$</DatabaseName><Value>$Data/Property[@Name='TransactionLogPercentFree']$</Value><Threshold1>10</Threshold1><Threshold2>20</Threshold2><AutoGrowSet>$Target/Property[Type="SQL!Microsoft.SQLServer.Database"]/LogAutogrow$</AutoGrowSet><TimeoutSeconds>300</TimeoutSeconds>

    Kind regards,

    Natascia

    https://systemcentertipps.wordpress.com

    • Proposed as answer by ScottMoss Tuesday, January 10, 2017 3:36 PM
    • Marked as answer by GouravIN Friday, July 28, 2017 10:03 AM
    Tuesday, January 10, 2017 2:21 PM

All replies

  • Hi Gourav,

    there is no real way how you can export the thresholds for all monitors/rules with PowerShell as you would need to know the config for each monitor/rule and adjust the script for each one. That all depends on the MonitorTypes and DataSource configurations which are used.

    Even if you use SQL to query some monitor details, you would need to check the Overrides also and the XML information is not reader friendly:

    SELECT MonitorName, ConfigurationXML
    /*count (*)*/
      FROM [OperationsManager].[dbo].[Monitor]
      where isunitmonitor=1 and monitorenabled <>0

    Example output for ConfigurationXML:
    <IntervalSeconds>60</IntervalSeconds><SyncTime/><ConnectionString>$Target/Host/Property[Type="SQL!Microsoft.SQLServer.DBEngine"]/ConnectionString$</ConnectionString><ObjectName>$Target/Host/Property[Type="SQL!Microsoft.SQLServer.DBEngine"]/PerformanceCounterObject$:Database</ObjectName><CounterName>Log Free Space (%)</CounterName><InstanceName>$Data/Property[@Name='Database']$</InstanceName><DatabaseName>$Target/Property[Type="SQL!Microsoft.SQLServer.Database"]/DatabaseName$</DatabaseName><Value>$Data/Property[@Name='TransactionLogPercentFree']$</Value><Threshold1>10</Threshold1><Threshold2>20</Threshold2><AutoGrowSet>$Target/Property[Type="SQL!Microsoft.SQLServer.Database"]/LogAutogrow$</AutoGrowSet><TimeoutSeconds>300</TimeoutSeconds>

    Kind regards,

    Natascia

    https://systemcentertipps.wordpress.com

    • Proposed as answer by ScottMoss Tuesday, January 10, 2017 3:36 PM
    • Marked as answer by GouravIN Friday, July 28, 2017 10:03 AM
    Tuesday, January 10, 2017 2:21 PM
  • Hi Natascia,

    Thanks for reply!

    i am working in an environment, in which i need to export all rules and monitors. So please let me know which is the best way to work on?

    And could you please provide me any script for that?

    i'll be looking from your side!

    Thanks,

    Gourav  

    Wednesday, January 11, 2017 6:15 AM