Merge pull request #261 from Icinga:fix/perfdata_for_unprocessed_checks_was_not_added

Fix: Performance Data was not written for checks which were not compared to a threshold

Fixes an issue for Performance Data, which mainly occurs for hidden packages and checks, as there was no action taking place to "use" the provided value in someway. This caused the performance data object not being generated and threfor was not added to the check output.
This commit is contained in:
Lord Hepipud 2021-05-29 11:22:38 +02:00 committed by GitHub
commit d78a7a77b8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -80,6 +80,12 @@ function New-IcingaCheck()
)
}
$IcingaCheck | Add-Member -MemberType ScriptMethod -Force -Name '__CreateDefaultThresholdObject' -Value {
[hashtable]$ThresholdArguments = $this.__GetBaseThresholdArguments();
$ThresholdObject = Compare-IcingaPluginThresholds @ThresholdArguments;
$this.__SetCheckState($ThresholdObject, $IcingaEnums.IcingaExitCode.Ok);
}
# Override shared function
$IcingaCheck | Add-Member -MemberType ScriptMethod -Force -Name '__SetCheckOutput' -Value {
param ($PluginOutput);
@ -88,15 +94,13 @@ function New-IcingaCheck()
return;
}
if ($null -eq $this.__ThresholdObject) {
$this.__CreateDefaultThresholdObject();
}
$PluginThresholds = '';
$TimeSpan = '';
if ($null -ne $this.__ThresholdObject) {
$PluginThresholds = $this.__ThresholdObject.FullMessage;
} elseif ($null -ne $this.Value) {
# In case we simply added a value to a check and not did anything with it, output the raw value properly formatted like anything else
$PluginThresholds = (ConvertTo-IcingaPluginOutputTranslation -Translation $this.Translation -Value (Convert-IcingaPluginValueToString -Unit $this.Unit -Value $this.Value));
}
$PluginThresholds = $this.__ThresholdObject.FullMessage;
if ([string]::IsNullOrEmpty($PluginOutput) -eq $FALSE) {
$PluginThresholds = $PluginOutput;