mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-21 07:10:15 -05:00
Check Packages will now return Unknown if no check is assigned
This commit is contained in:
parent
5840e0ca05
commit
9b46d63fd0
1 changed files with 47 additions and 26 deletions
|
|
@ -70,6 +70,7 @@ function New-IcingaCheckPackage()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this.checks.Count -ne 0) {
|
||||||
if ($this.opand) {
|
if ($this.opand) {
|
||||||
if ($this.CheckAllOk() -eq $FALSE) {
|
if ($this.CheckAllOk() -eq $FALSE) {
|
||||||
$this.GetWorstExitCode();
|
$this.GetWorstExitCode();
|
||||||
|
|
@ -98,6 +99,9 @@ function New-IcingaCheckPackage()
|
||||||
$this.exitcode = $IcingaEnums.IcingaExitCode.Ok;
|
$this.exitcode = $IcingaEnums.IcingaExitCode.Ok;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$this.exitcode = $IcingaEnums.IcingaExitCode.Unknown;
|
||||||
|
}
|
||||||
|
|
||||||
if ([int]$this.exitcode -eq -1) {
|
if ([int]$this.exitcode -eq -1) {
|
||||||
$this.exitcode = $IcingaEnums.IcingaExitCode.Ok;
|
$this.exitcode = $IcingaEnums.IcingaExitCode.Ok;
|
||||||
|
|
@ -219,6 +223,20 @@ function New-IcingaCheckPackage()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$Check | Add-Member -membertype ScriptMethod -name 'PrintNoChecksConfigured' -value {
|
||||||
|
if ($this.checks.Count -eq 0) {
|
||||||
|
Write-Host (
|
||||||
|
[string]::Format(
|
||||||
|
'{0}{1}: No checks configured for package "{2}"',
|
||||||
|
(New-StringTree ($this.spacing + 1)),
|
||||||
|
$IcingaEnums.IcingaExitCodeText.($this.exitcode),
|
||||||
|
$this.name
|
||||||
|
)
|
||||||
|
)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$Check | Add-Member -membertype ScriptMethod -name 'WritePackageOutputStatus' -value {
|
$Check | Add-Member -membertype ScriptMethod -name 'WritePackageOutputStatus' -value {
|
||||||
[string]$outputMessage = '{0}{1}: Check package "{2}" is {1}';
|
[string]$outputMessage = '{0}{1}: Check package "{2}" is {1}';
|
||||||
if ($this.verbose -ne 0) {
|
if ($this.verbose -ne 0) {
|
||||||
|
|
@ -252,14 +270,17 @@ function New-IcingaCheckPackage()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this.WritePackageOutputStatus();
|
$this.WritePackageOutputStatus();
|
||||||
|
|
||||||
if ($printAll) {
|
if ($printAll) {
|
||||||
$this.WriteAllOutput();
|
$this.WriteAllOutput();
|
||||||
|
$this.PrintNoChecksConfigured();
|
||||||
} elseif ($printDetails) {
|
} elseif ($printDetails) {
|
||||||
# Now print Non-Ok Check outputs in case our package is not Ok
|
# Now print Non-Ok Check outputs in case our package is not Ok
|
||||||
if ([int]$this.exitcode -ne $IcingaEnums.IcingaExitCode.Ok) {
|
if ([int]$this.exitcode -ne $IcingaEnums.IcingaExitCode.Ok) {
|
||||||
$this.WriteCheckErrors();
|
$this.WriteCheckErrors();
|
||||||
|
$this.PrintNoChecksConfigured();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue