Merge pull request #296 from Icinga:fix/service_daemon_check_args

Fix: Service check background daemon not working with arguments
This commit is contained in:
Lord Hepipud 2021-07-01 15:41:34 +02:00 committed by GitHub
commit 1c540e55e3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 6 deletions

View file

@ -22,6 +22,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
* [#284](https://github.com/Icinga/icinga-powershell-framework/issues/284) Fixes exception while creating default threshold objects * [#284](https://github.com/Icinga/icinga-powershell-framework/issues/284) Fixes exception while creating default threshold objects
* [#285](https://github.com/Icinga/icinga-powershell-framework/issues/285) Fixes plain Icinga 2 conf generation for commands, which was caused by a new exception output for additional output * [#285](https://github.com/Icinga/icinga-powershell-framework/issues/285) Fixes plain Icinga 2 conf generation for commands, which was caused by a new exception output for additional output
* [#293](https://github.com/Icinga/icinga-powershell-framework/pull/293) Fixes crash on REST-Api for NULL values while parsing the REST message * [#293](https://github.com/Icinga/icinga-powershell-framework/pull/293) Fixes crash on REST-Api for NULL values while parsing the REST message
* [#295](https://github.com/Icinga/icinga-powershell-framework/issues/295) Fixes background service check daemon not working with arguments for plugins
## 1.5.0 (2021-06-02) ## 1.5.0 (2021-06-02)

View file

@ -39,7 +39,19 @@ function Start-IcingaServiceCheckDaemon()
continue; continue;
} }
Start-IcingaServiceCheckTask -CheckId $service -CheckCommand $RegisteredServices[$service].CheckCommand -Arguments $RegisteredServices[$service].Arguments -Interval $RegisteredServices[$service].Interval -TimeIndexes $RegisteredServices[$service].TimeIndexes; [hashtable]$ServiceArgs = @{ };
if ($null -ne $RegisteredServices[$service].Arguments) {
foreach ($property in $RegisteredServices[$service].Arguments.PSObject.Properties) {
if ($ServiceArgs.ContainsKey($property.Name)) {
continue;
}
$ServiceArgs.Add($property.Name, $property.Value)
}
}
Start-IcingaServiceCheckTask -CheckId $service -CheckCommand $RegisteredServices[$service].CheckCommand -Arguments $ServiceArgs -Interval $RegisteredServices[$service].Interval -TimeIndexes $RegisteredServices[$service].TimeIndexes;
} }
Start-Sleep -Seconds 1; Start-Sleep -Seconds 1;
} }

View file

@ -25,6 +25,10 @@ function New-IcingaCheckBaseObject()
} }
} }
if ([string]::IsNullOrEmpty($this.__CheckCommand)) {
return;
}
if ($null -eq $Global:Icinga) { if ($null -eq $Global:Icinga) {
$Global:Icinga = @{ }; $Global:Icinga = @{ };
} }
@ -33,14 +37,15 @@ function New-IcingaCheckBaseObject()
$Global:Icinga.Add('ThresholdCache', @{ }); $Global:Icinga.Add('ThresholdCache', @{ });
} }
if ($Global:Icinga.ThresholdCache.ContainsKey($this.__CheckCommand)) { if ($Global:Icinga.ThresholdCache.ContainsKey($this.__CheckCommand) -eq $FALSE) {
$Global:Icinga.ThresholdCache.Add($this.__CheckCommand, $null);
}
if ($null -ne $Global:Icinga.ThresholdCache[$this.__CheckCommand]) {
return; return;
} }
$Global:Icinga.ThresholdCache.Add( $Global:Icinga.ThresholdCache[$this.__CheckCommand] = (Get-IcingaCacheData -Space 'sc_daemon' -CacheStore 'checkresult' -KeyName $this.__CheckCommand);
$this.__CheckCommand,
(Get-IcingaCacheData -Space 'sc_daemon' -CacheStore 'checkresult' -KeyName $this.__CheckCommand)
);
} }
$IcingaCheckBaseObject | Add-Member -MemberType ScriptMethod -Name '__SetParent' -Value { $IcingaCheckBaseObject | Add-Member -MemberType ScriptMethod -Name '__SetParent' -Value {