diff --git a/lib/icinga/plugin/New-IcingaCheck.psm1 b/lib/icinga/plugin/New-IcingaCheck.psm1 index 6134729..2524d77 100644 --- a/lib/icinga/plugin/New-IcingaCheck.psm1 +++ b/lib/icinga/plugin/New-IcingaCheck.psm1 @@ -40,11 +40,18 @@ function New-IcingaCheck() $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.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[$this.checkcommand]['results'].ContainsKey($this.name) -eq $FALSE) { $global:IcingaDaemonData.BackgroundDaemon.ServiceCheckScheduler[$this.checkcommand]['results'].Add( diff --git a/lib/icinga/plugin/Write-IcingaPluginOutput.psm1 b/lib/icinga/plugin/Write-IcingaPluginOutput.psm1 index 78b396c..c9a8746 100644 --- a/lib/icinga/plugin/Write-IcingaPluginOutput.psm1 +++ b/lib/icinga/plugin/Write-IcingaPluginOutput.psm1 @@ -7,6 +7,8 @@ function Write-IcingaPluginOutput() if ($global:IcingaDaemonData.FrameworkRunningAsDaemon -eq $FALSE) { Write-Host $Output; } else { - $IcingaThreadContent['Scheduler']['PluginCache'] += $Output; + if ($global:IcingaDaemonData.IcingaThreadContent.ContainsKey('Scheduler')) { + $global:IcingaDaemonData.IcingaThreadContent['Scheduler']['PluginCache'] += $Output; + } } } diff --git a/lib/icinga/plugin/Write-IcingaPluginPerfData.psm1 b/lib/icinga/plugin/Write-IcingaPluginPerfData.psm1 index bdc474e..dc1221c 100644 --- a/lib/icinga/plugin/Write-IcingaPluginPerfData.psm1 +++ b/lib/icinga/plugin/Write-IcingaPluginPerfData.psm1 @@ -37,7 +37,9 @@ function Get-IcingaPluginPerfDataContent() $cachedresult = (New-IcingaPerformanceDataEntry -PerfDataObject $data -Label $SearchEntry -Value $checkresult.Value); if ($AsObject) { - $global:IcingaThreadContent['Scheduler']['PluginPerfData'] += $cachedresult; + if ($global:IcingaDaemonData.IcingaThreadContent.ContainsKey('Scheduler')) { + $global:IcingaDaemonData.IcingaThreadContent['Scheduler']['PluginPerfData'] += $cachedresult; + } } $PerfDataOutput += $cachedresult; } @@ -46,7 +48,9 @@ function Get-IcingaPluginPerfDataContent() $compiledPerfData = (New-IcingaPerformanceDataEntry $data); if ($AsObject) { - $global:IcingaThreadContent['Scheduler']['PluginPerfData'] += $compiledPerfData; + if ($global:IcingaDaemonData.IcingaThreadContent.ContainsKey('Scheduler')) { + $global:IcingaDaemonData.IcingaThreadContent['Scheduler']['PluginPerfData'] += $compiledPerfData; + } } $PerfDataOutput += $compiledPerfData; }