mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-21 07:10:15 -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;
|
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 {
|
$Check | Add-Member -membertype ScriptMethod -name 'WarnOutOfRange' -value {
|
||||||
param($warning);
|
param($warning);
|
||||||
|
|
||||||
|
|
@ -296,6 +312,14 @@ function New-IcingaCheck()
|
||||||
return $this;
|
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 {
|
$Check | Add-Member -membertype ScriptMethod -name 'CritOutOfRange' -value {
|
||||||
param($critical);
|
param($critical);
|
||||||
|
|
||||||
|
|
@ -534,17 +558,25 @@ function New-IcingaCheck()
|
||||||
}
|
}
|
||||||
|
|
||||||
$this.SetExitCode($state);
|
$this.SetExitCode($state);
|
||||||
$this.AddMessage(
|
|
||||||
[string]::Format(
|
if ($null -eq $value -And $null -eq $type) {
|
||||||
'{0}: Value "{1}{4}" is {2} threshold "{3}{4}"',
|
$this.AddMessage(
|
||||||
$this.name,
|
$this.name,
|
||||||
$this.TranslateValue($this.value),
|
$state
|
||||||
$type,
|
);
|
||||||
$this.TranslateValue($value),
|
} else {
|
||||||
$this.unit
|
$this.AddMessage(
|
||||||
),
|
[string]::Format(
|
||||||
$state
|
'{0}: Value "{1}{4}" is {2} threshold "{3}{4}"',
|
||||||
);
|
$this.name,
|
||||||
|
$this.TranslateValue($this.value),
|
||||||
|
$type,
|
||||||
|
$this.TranslateValue($value),
|
||||||
|
$this.unit
|
||||||
|
),
|
||||||
|
$state
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
switch ($state) {
|
switch ($state) {
|
||||||
$IcingaEnums.IcingaExitCode.Warning {
|
$IcingaEnums.IcingaExitCode.Warning {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue