mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-20 23:00:35 -05:00
Added support to check if objects exist on icinga checks
This commit is contained in:
parent
521ed5eb09
commit
d3862eccdb
1 changed files with 29 additions and 19 deletions
|
|
@ -9,6 +9,7 @@ function New-IcingaCheck()
|
|||
$Unit = $null,
|
||||
[string]$Minimum = '',
|
||||
[string]$Maximum = '',
|
||||
$ObjectExists = -1,
|
||||
[switch]$NoPerfData
|
||||
);
|
||||
|
||||
|
|
@ -30,6 +31,7 @@ function New-IcingaCheck()
|
|||
$Check | Add-Member -membertype NoteProperty -name 'critical' -value '';
|
||||
$Check | Add-Member -membertype NoteProperty -name 'minimum' -value $Minimum;
|
||||
$Check | Add-Member -membertype NoteProperty -name 'maximum' -value $Maximum;
|
||||
$Check | Add-Member -membertype NoteProperty -name 'objectexists' -value $ObjectExists;
|
||||
$Check | Add-Member -membertype NoteProperty -name 'checks' -value $null;
|
||||
$Check | Add-Member -membertype NoteProperty -name 'completed' -value $FALSE;
|
||||
|
||||
|
|
@ -404,6 +406,14 @@ function New-IcingaCheck()
|
|||
$Check | Add-Member -membertype ScriptMethod -name 'AddInternalCheckMessage' -value {
|
||||
param($state, $value, $type);
|
||||
|
||||
if ($this.objectexists -ne -1 -And $null -eq $this.objectexists) {
|
||||
$this.SetExitCode($IcingaEnums.IcingaExitCode.Unknown);
|
||||
$this.AddMessage([string]::Format(
|
||||
'{0} does not exist', $this.name
|
||||
), $IcingaEnums.IcingaExitCode.Unknown);
|
||||
return;
|
||||
}
|
||||
|
||||
$this.SetExitCode($state);
|
||||
$this.AddMessage([string]::Format(
|
||||
'{0} {1}{4} is {2} {3}{4}', $this.name, $this.value, $type, $value, $this.unit
|
||||
|
|
|
|||
Loading…
Reference in a new issue