Fixes UNKNOWN on checks using MoT thresholds if they are newly registered

This commit is contained in:
Lord Hepipud 2025-04-22 11:34:04 +02:00
parent f2f935ff90
commit 38461f755a
2 changed files with 10 additions and 1 deletions

View file

@ -19,6 +19,7 @@ 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`
* [#796](https://github.com/Icinga/icinga-powershell-framework/issues/796) [#798](https://github.com/Icinga/icinga-powershell-framework/issues/798) Fixes an issue with the new check handling, which did not properly convert values from checks to the correct performance data values and base values in some cases
* [#797](https://github.com/Icinga/icinga-powershell-framework/issues/797) Fixes plugins throwing `UNKNOWN` in case `-TresholdInterval` is used for Metrics over Time, when checks are newly registered and checked, before the first MoT is executed and collected
## 1.13.3 (tbd)

View file

@ -21,19 +21,27 @@ function Add-IcingaServiceCheckTask()
[int]$CheckInterval = ConvertTo-Seconds $Interval;
[hashtable]$CheckDataCache = @{ };
[array]$PerfDataEntries = @();
[bool]$ForceExecution = $FALSE;
if (Test-Path -Path $MetricCacheFile) {
$CheckDataCache = [System.Management.Automation.PSSerializer]::Deserialize((Get-Content -Path $MetricCacheFile -Raw -Encoding UTF8));
}
# In case we run this code for the first time for a CheckCommand and no data is available, ensure we run the check immediately
# This will ensure our plugins will always return proper values and not throw unknowns, in case the execution is set to a higher interval
if ($null -eq $CheckDataCache -Or $CheckDataCache.Count -eq 0) {
$ForceExecution = $TRUE;
}
while ($TRUE) {
if ($Global:Icinga.Private.Daemons.ServiceCheck.PassedTime -lt $CheckInterval) {
if ($ForceExecution -eq $FALSE -And $Global:Icinga.Private.Daemons.ServiceCheck.PassedTime -lt $CheckInterval) {
$Global:Icinga.Private.Daemons.ServiceCheck.PassedTime += 1;
Start-Sleep -Seconds 1;
continue;
}
$ForceExecution = $FALSE;
$Global:Icinga.Private.Daemons.ServiceCheck.PassedTime = 0;
# Clear possible previous performance data from the daemon cache