Skip to content

Commit 5d3a24d

Browse files
authored
Merge pull request #440 from Icinga:fix/perf_counter_check_writing_wrong_perfdata_for_instance_checks
Fix: Invoke-IcingaCheckPerfCounter to always write proper assigned perf data Fixes `Invoke-IcingaCheckPerfCounter` to write correct performance data in case only certain instances are checked to ensure perf data are assigned to checks accordingly
2 parents 648b973 + 10b93c5 commit 5d3a24d

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

doc/31-Changelog.md

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
1919

2020
### Bugfixes
2121

22+
* [#377](https://github.com/Icinga/icinga-powershell-plugins/issues/377) Fixes `Invoke-IcingaCheckPerfCounter` to write correct performance data in case only certain instances are checked to ensure perf data are assigned to checks accordingly
2223
* [#436](https://github.com/Icinga/icinga-powershell-plugins/issues/436) Fixes performance data for ScheduledTask plugin for Last and Next RunTime
2324

2425
### Enhancements

plugins/Invoke-IcingaCheckPerfcounter.psm1

+8-2
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,14 @@ function Invoke-IcingaCheckPerfCounter()
107107
$CounterFailed = $FALSE;
108108

109109
if ($instance -IsNot [hashtable]) {
110-
$CounterInfo = Get-IcingaPerformanceCounterDetails -Counter $counter;
111-
$IcingaCheck = New-IcingaCheck -Name $counter -Value $Counters[$counter].Value -MetricIndex $CounterInfo.Category -MetricName $CounterInfo.Counter;
110+
$CounterInfo = Get-IcingaPerformanceCounterDetails -Counter $counter;
111+
[string]$MetricName = $CounterInfo.Counter;
112+
113+
if ([string]::IsNullOrEmpty($CounterInfo.CounterInstance) -eq $FALSE) {
114+
$MetricName = $CounterInfo.CounterInstance;
115+
}
116+
117+
$IcingaCheck = New-IcingaCheck -Name $counter -Value $Counters[$counter].Value -MetricIndex $CounterInfo.Category -MetricName $MetricName;
112118
$IcingaCheck.WarnOutOfRange($Warning).CritOutOfRange($Critical) | Out-Null;
113119
$CounterPackage.AddCheck($IcingaCheck);
114120
break;

0 commit comments

Comments
 (0)