mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-20 23:00:35 -05:00
Fixed crash on check execution while running in daemon mode
This commit is contained in:
parent
0e1940325a
commit
7e23ea76df
3 changed files with 17 additions and 4 deletions
|
|
@ -40,11 +40,18 @@ function New-IcingaCheck()
|
||||||
|
|
||||||
$Check | Add-Member -membertype ScriptMethod -name 'HandleDaemon' -value {
|
$Check | Add-Member -membertype ScriptMethod -name 'HandleDaemon' -value {
|
||||||
# Only apply this once the checkcommand is set
|
# Only apply this once the checkcommand is set
|
||||||
|
|
||||||
if ([string]::IsNullOrEmpty($this.checkcommand) -Or $global:IcingaDaemonData.FrameworkRunningAsDaemon -eq $FALSE) {
|
if ([string]::IsNullOrEmpty($this.checkcommand) -Or $global:IcingaDaemonData.FrameworkRunningAsDaemon -eq $FALSE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($global:IcingaDaemonData.ContainsKey('BackgroundDaemon') -eq $FALSE) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($global:IcingaDaemonData.BackgroundDaemon.ContainsKey('ServiceCheckScheduler') -eq $FALSE) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ($global:IcingaDaemonData.BackgroundDaemon.ServiceCheckScheduler.ContainsKey($this.checkcommand)) {
|
if ($global:IcingaDaemonData.BackgroundDaemon.ServiceCheckScheduler.ContainsKey($this.checkcommand)) {
|
||||||
if ($global:IcingaDaemonData.BackgroundDaemon.ServiceCheckScheduler[$this.checkcommand]['results'].ContainsKey($this.name) -eq $FALSE) {
|
if ($global:IcingaDaemonData.BackgroundDaemon.ServiceCheckScheduler[$this.checkcommand]['results'].ContainsKey($this.name) -eq $FALSE) {
|
||||||
$global:IcingaDaemonData.BackgroundDaemon.ServiceCheckScheduler[$this.checkcommand]['results'].Add(
|
$global:IcingaDaemonData.BackgroundDaemon.ServiceCheckScheduler[$this.checkcommand]['results'].Add(
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,8 @@ function Write-IcingaPluginOutput()
|
||||||
if ($global:IcingaDaemonData.FrameworkRunningAsDaemon -eq $FALSE) {
|
if ($global:IcingaDaemonData.FrameworkRunningAsDaemon -eq $FALSE) {
|
||||||
Write-Host $Output;
|
Write-Host $Output;
|
||||||
} else {
|
} else {
|
||||||
$IcingaThreadContent['Scheduler']['PluginCache'] += $Output;
|
if ($global:IcingaDaemonData.IcingaThreadContent.ContainsKey('Scheduler')) {
|
||||||
|
$global:IcingaDaemonData.IcingaThreadContent['Scheduler']['PluginCache'] += $Output;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,9 @@ function Get-IcingaPluginPerfDataContent()
|
||||||
$cachedresult = (New-IcingaPerformanceDataEntry -PerfDataObject $data -Label $SearchEntry -Value $checkresult.Value);
|
$cachedresult = (New-IcingaPerformanceDataEntry -PerfDataObject $data -Label $SearchEntry -Value $checkresult.Value);
|
||||||
|
|
||||||
if ($AsObject) {
|
if ($AsObject) {
|
||||||
$global:IcingaThreadContent['Scheduler']['PluginPerfData'] += $cachedresult;
|
if ($global:IcingaDaemonData.IcingaThreadContent.ContainsKey('Scheduler')) {
|
||||||
|
$global:IcingaDaemonData.IcingaThreadContent['Scheduler']['PluginPerfData'] += $cachedresult;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$PerfDataOutput += $cachedresult;
|
$PerfDataOutput += $cachedresult;
|
||||||
}
|
}
|
||||||
|
|
@ -46,7 +48,9 @@ function Get-IcingaPluginPerfDataContent()
|
||||||
$compiledPerfData = (New-IcingaPerformanceDataEntry $data);
|
$compiledPerfData = (New-IcingaPerformanceDataEntry $data);
|
||||||
|
|
||||||
if ($AsObject) {
|
if ($AsObject) {
|
||||||
$global:IcingaThreadContent['Scheduler']['PluginPerfData'] += $compiledPerfData;
|
if ($global:IcingaDaemonData.IcingaThreadContent.ContainsKey('Scheduler')) {
|
||||||
|
$global:IcingaDaemonData.IcingaThreadContent['Scheduler']['PluginPerfData'] += $compiledPerfData;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$PerfDataOutput += $compiledPerfData;
|
$PerfDataOutput += $compiledPerfData;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue