diff --git a/lib/core/perfcounter/Show-IcingaPerformanceCounterInstances.psm1 b/lib/core/perfcounter/Show-IcingaPerformanceCounterInstances.psm1 index 9b2da75..131cb31 100644 --- a/lib/core/perfcounter/Show-IcingaPerformanceCounterInstances.psm1 +++ b/lib/core/perfcounter/Show-IcingaPerformanceCounterInstances.psm1 @@ -1,12 +1,14 @@ <# .SYNOPSIS - Displays all available instances for a provided Performance Counter + Displays all available instances for a provided Performance Counter .DESCRIPTION - Displays all available instances for a provided Performance Counter + Displays all available instances for a provided Performance Counter .FUNCTIONALITY - Displays all available instances for a provided Performance Counter + Displays all available instances for a provided Performance Counter .PARAMETER Counter - The name of the Performance Counter to fetch data for + The name of the Performance Counter to fetch data for +.PARAMETER NoNoticeOnMissingInstances + If specified, no notice will be displayed if no instances are found for the provided counter .EXAMPLE PS>Show-IcingaPerformanceCounterInstances -Counter '\Processor(*)\% processor time'; @@ -25,7 +27,8 @@ function Show-IcingaPerformanceCounterInstances() { param ( - [string]$Counter + [string]$Counter, + [switch]$NoNoticeOnMissingInstances = $FALSE ); [hashtable]$Instances = @{ }; @@ -45,9 +48,11 @@ function Show-IcingaPerformanceCounterInstances() } if ($Instances.Count -eq 0) { - Write-IcingaConsoleNotice ` - -Message 'No instances were found for Performance Counter "{0}". Please ensure the provided counter has instances and you are using "*" for the instance name.' ` - -Objects $Counter; + if ($NoNoticeOnMissingInstances -eq $FALSE) { + Write-IcingaConsoleNotice ` + -Message 'No instances were found for Performance Counter "{0}". Please ensure the provided counter has instances and you are using "*" for the instance name.' ` + -Objects $Counter; + } return; } @@ -55,4 +60,4 @@ function Show-IcingaPerformanceCounterInstances() return ( $Instances.GetEnumerator() | Sort-Object Name ); -} +}e diff --git a/lib/core/perfcounter/Update-IcingaPerformanceCounterCache.psm1 b/lib/core/perfcounter/Update-IcingaPerformanceCounterCache.psm1 index e5d7940..4c0b564 100644 --- a/lib/core/perfcounter/Update-IcingaPerformanceCounterCache.psm1 +++ b/lib/core/perfcounter/Update-IcingaPerformanceCounterCache.psm1 @@ -37,7 +37,7 @@ function Update-IcingaPerformanceCounterCache() # First we need to prepare some data by fetching the current instances of the counter # and the cached instances. We will then compare them and update the cache accordingly - [array]$CounterInstances = Show-IcingaPerformanceCounterInstances -Counter $Counter; + [array]$CounterInstances = Show-IcingaPerformanceCounterInstances -Counter $Counter -NoNoticeOnMissingInstances; [array]$CachedInstances = $Global:Icinga.Private.PerformanceCounter.Cache[$Counter]; [array]$UpdatedInstances = @(); [array]$CachedInstanceNames = $CachedInstances.FullName;