Fixes notice packages to not return unknown and properly report if no entries were found

This commit is contained in:
Lord Hepipud 2025-12-29 11:24:24 +01:00
parent 83cc134c47
commit 3bf61237f1

View file

@ -181,13 +181,17 @@ function New-IcingaCheckPackage()
$NotOkChecks = 0; $NotOkChecks = 0;
$OkChecks = 0; $OkChecks = 0;
if ($this.__Checks.Count -eq 0 -And $this.IgnoreEmptyPackage -eq $FALSE) { if ($this.__Checks.Count -eq 0 -and ($this.IgnoreEmptyPackage -eq $FALSE -and $this.IsNoticePackage -eq $FALSE)) {
$this.__ErrorMessage = 'No checks added to this package'; $this.__ErrorMessage = 'No checks added to this package';
$this.__SetCheckState($IcingaEnums.IcingaExitCode.Unknown); $this.__SetCheckState($IcingaEnums.IcingaExitCode.Unknown);
$this.__SetCheckOutput(); $this.__SetCheckOutput();
return; return;
} }
if ($this.__Checks.Count -eq 0 -and $this.IsNoticePackage) {
$this.__ErrorMessage = 'Nothing to report';
}
[array]$this.__Checks = ($this.__Checks | Sort-Object -Property Name); [array]$this.__Checks = ($this.__Checks | Sort-Object -Property Name);
# Loop all checks to understand the content of result # Loop all checks to understand the content of result