mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-20 23:00:35 -05:00
Adds support to set check state by function call
This commit is contained in:
parent
7860818be1
commit
c4179338a1
1 changed files with 42 additions and 10 deletions
|
|
@ -94,6 +94,22 @@ function New-IcingaCheck()
|
|||
return $this.unknownchecks;
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'SetUnknown' -value {
|
||||
$this.AddInternalCheckMessage(
|
||||
$IcingaEnums.IcingaExitCode.Unknown,
|
||||
$null,
|
||||
$null
|
||||
);
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'SetWarning' -value {
|
||||
$this.AddInternalCheckMessage(
|
||||
$IcingaEnums.IcingaExitCode.Warning,
|
||||
$null,
|
||||
$null
|
||||
);
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'WarnOutOfRange' -value {
|
||||
param($warning);
|
||||
|
||||
|
|
@ -296,6 +312,14 @@ function New-IcingaCheck()
|
|||
return $this;
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'SetCritical' -value {
|
||||
$this.AddInternalCheckMessage(
|
||||
$IcingaEnums.IcingaExitCode.Critical,
|
||||
$null,
|
||||
$null
|
||||
);
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'CritOutOfRange' -value {
|
||||
param($critical);
|
||||
|
||||
|
|
@ -534,17 +558,25 @@ function New-IcingaCheck()
|
|||
}
|
||||
|
||||
$this.SetExitCode($state);
|
||||
$this.AddMessage(
|
||||
[string]::Format(
|
||||
'{0}: Value "{1}{4}" is {2} threshold "{3}{4}"',
|
||||
|
||||
if ($null -eq $value -And $null -eq $type) {
|
||||
$this.AddMessage(
|
||||
$this.name,
|
||||
$this.TranslateValue($this.value),
|
||||
$type,
|
||||
$this.TranslateValue($value),
|
||||
$this.unit
|
||||
),
|
||||
$state
|
||||
);
|
||||
$state
|
||||
);
|
||||
} else {
|
||||
$this.AddMessage(
|
||||
[string]::Format(
|
||||
'{0}: Value "{1}{4}" is {2} threshold "{3}{4}"',
|
||||
$this.name,
|
||||
$this.TranslateValue($this.value),
|
||||
$type,
|
||||
$this.TranslateValue($value),
|
||||
$this.unit
|
||||
),
|
||||
$state
|
||||
);
|
||||
}
|
||||
|
||||
switch ($state) {
|
||||
$IcingaEnums.IcingaExitCode.Warning {
|
||||
|
|
|
|||
Loading…
Reference in a new issue