mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-21 07:10:15 -05:00
Executed checks will now store their value on daemon run within cache
This commit is contained in:
parent
921dd8074b
commit
1c3f7bd73e
1 changed files with 23 additions and 0 deletions
|
|
@ -38,6 +38,27 @@ function New-IcingaCheck()
|
|||
$Check | Add-Member -membertype NoteProperty -name 'completed' -value $FALSE;
|
||||
$Check | Add-Member -membertype NoteProperty -name 'checkcommand' -value '';
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'HandleDaemon' -value {
|
||||
# Only apply this once the checkcommand is set
|
||||
|
||||
if ([string]::IsNullOrEmpty($this.checkcommand) -Or $global:IcingaDaemonData.FrameworkRunningAsDaemon -eq $FALSE) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($global:IcingaDaemonData.BackgroundDaemon.ServiceCheckScheduler.ContainsKey($this.checkcommand)) {
|
||||
if ($global:IcingaDaemonData.BackgroundDaemon.ServiceCheckScheduler[$this.checkcommand]['results'].ContainsKey($this.name) -eq $FALSE) {
|
||||
$global:IcingaDaemonData.BackgroundDaemon.ServiceCheckScheduler[$this.checkcommand]['results'].Add(
|
||||
$this.name,
|
||||
[hashtable]::Synchronized(@{})
|
||||
);
|
||||
}
|
||||
$global:IcingaDaemonData.BackgroundDaemon.ServiceCheckScheduler[$this.checkcommand]['results'][$this.name].Add(
|
||||
(Get-IcingaUnixTime),
|
||||
$this.value
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'AddSpacing' -value {
|
||||
$this.spacing += 1;
|
||||
}
|
||||
|
|
@ -46,6 +67,7 @@ function New-IcingaCheck()
|
|||
param($CheckCommand);
|
||||
|
||||
$this.checkcommand = $CheckCommand;
|
||||
$this.HandleDaemon();
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'WarnOutOfRange' -value {
|
||||
|
|
@ -683,6 +705,7 @@ function New-IcingaCheck()
|
|||
}
|
||||
|
||||
$Check.ValidateUnit();
|
||||
$Check.HandleDaemon();
|
||||
|
||||
return $Check;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue