Executed checks will now store their value on daemon run within cache

This commit is contained in:
Lord Hepipud 2019-10-05 22:08:19 +02:00
parent 921dd8074b
commit 1c3f7bd73e

View file

@ -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;
}