mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-21 15:19:58 -05:00
Fixed crash on check execution while running in daemon mode
This commit is contained in:
parent
326165e8d8
commit
ee138f0ea4
3 changed files with 17 additions and 4 deletions
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue