Fixes MetricsOverTime reporting unknown for checks which do not write performance data (like process plugin)

This commit is contained in:
Lord Hepipud 2025-04-10 16:35:26 +02:00
parent b35f0a77b9
commit f75f873a2c
3 changed files with 15 additions and 2 deletions

View file

@ -15,6 +15,10 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
* [#787](https://github.com/Icinga/icinga-powershell-framework/pull/787) Fixes the return value in case the `Agent` component could not be installed from `$FALSE` to `null`
## 1.13.3 (tbd)
* [#800](https://github.com/Icinga/icinga-powershell-framework/pull/800) Fixes an issue for certain plugins, like `Invoke-IcingaCheckProcess`, which reports unknown if MetricsOverTime is used for checks that do not write performance data
## 1.13.2 (2025-02-03)
[Issues and PRs](https://github.com/Icinga/icinga-powershell-framework/milestone/40)

View file

@ -97,7 +97,8 @@ function Compare-IcingaPluginThresholds()
[switch]$IsBetween = $FALSE,
[switch]$IsLowerEqual = $FALSE,
[switch]$IsGreaterEqual = $FALSE,
[string]$TimeInterval = $null
[string]$TimeInterval = $null,
[switch]$NoPerfData = $FALSE
);
try {
@ -109,6 +110,13 @@ function Compare-IcingaPluginThresholds()
'Interval' = $TimeInterval;
};
# Ensure we do not include our checks for which we do not write any performance data
# Metrics over time will not work for those, as the metrics are not stored.
# There just set the variable to null which means they won't be processed
if ($NoPerfData) {
$MoTData = $null;
}
if ($TestInput.Decimal) {
[decimal]$InputValue = [decimal]$TestInput.Value;
}

View file

@ -39,7 +39,7 @@ function New-IcingaCheck()
$IcingaCheck | Add-Member -MemberType NoteProperty -Name 'ObjectExists' -Value $ObjectExists;
$IcingaCheck | Add-Member -MemberType NoteProperty -Name 'Translation' -Value $Translation;
$IcingaCheck | Add-Member -MemberType NoteProperty -Name 'LabelName' -Value $LabelName;
$IcingaCheck | Add-Member -MemberType NoteProperty -Name 'NoPerfData' -Value $NoPerfData;
$IcingaCheck | Add-Member -MemberType NoteProperty -Name 'NoPerfData' -Value ([bool]$NoPerfData);
$IcingaCheck | Add-Member -MemberType NoteProperty -Name '__WarningValue' -Value $null;
$IcingaCheck | Add-Member -MemberType NoteProperty -Name '__CriticalValue' -Value $null;
$IcingaCheck | Add-Member -MemberType NoteProperty -Name '__LockedState' -Value $FALSE;
@ -490,6 +490,7 @@ function New-IcingaCheck()
'-ThresholdCache' = (Get-IcingaThresholdCache -CheckCommand $this.__CheckCommand);
'-Translation' = $this.Translation;
'-TimeInterval' = $this.__TimeInterval;
'-NoPerfData' = $this.NoPerfData;
};
}