Skip to content

Commit a509b39

Browse files
committed
Fixes invalid perf data for service plugin
1 parent a9c4b90 commit a509b39

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

doc/31-Changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
99

1010
## 1.10.1 (2022-12-20)
1111

12+
### Bugfixes
13+
14+
* [#323](https://github.com/Icinga/icinga-powershell-plugins/issues/323) Fixes `Invoke-IcingaCheckService` to write invalid performance data in case one service is actively checked and returning `UNKNOWN` because it does not exist
15+
1216
### Enhancements
1317

1418
* [#322](https://github.com/Icinga/icinga-powershell-plugins/issues/322) Adds flag `-IgnoreService` for plugin `Invoke-IcingaCheckTimeSync` to ignore the time service being evaluated during check runtime

plugins/Invoke-IcingaCheckService.psm1

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,11 @@ function Invoke-IcingaCheckService()
138138
}
139139
}
140140

141+
# Fix invalid performance data in case only one service was checked and the service does not exist
142+
if ($null -eq $ServiceSummary) {
143+
$ServiceSummary = Add-IcingaServiceSummary;
144+
}
145+
141146
# Check our included services and add an unknown state for each service which was not found on the system
142147
foreach ($ServiceArg in $Service) {
143148
if ($null -eq $FetchedServices -Or $FetchedServices.ContainsKey($ServiceArg) -eq $FALSE) {
@@ -163,7 +168,7 @@ function Invoke-IcingaCheckService()
163168
}
164169

165170
$ServicesPackage.AddCheck(
166-
(New-IcingaCheck -Name ([string]::Format('{0}: Service not found', $ServiceArg))).SetUnknown()
171+
(New-IcingaCheck -Name ([string]::Format('{0}: Service not found', $ServiceArg)) -NoPerfData).SetUnknown()
167172
);
168173
}
169174
}

provider/private/services/Add-IcingaServiceSummary.psm1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function Add-IcingaServiceSummary()
5252
}
5353
}
5454

55-
switch($ServiceStatus) {
55+
switch ($ServiceStatus) {
5656
$ProviderEnums.ServiceStatus.Stopped {
5757
$ServiceData.StoppedCount += 1;
5858
};

0 commit comments

Comments
 (0)