Skip to content

Commit 75eeac7

Browse files
authored
Merge pull request #360 from Icinga:fix/plain_check_execution
Fix: Plain Plugin Cmdlet execution on shell Fixes plain execution of plugin Cmdlets on the PowerShell, which caused an exception of being thrown before, as no check command was assigned.
2 parents bbbc6ee + d59bed6 commit 75eeac7

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

doc/31-Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
2525
* [#343](https://github.com/Icinga/icinga-powershell-framework/pull/343) Fixes freeze within Icinga Management Console, in case commands which previously existed were removed/renamed or the user applied an invalid configuration with unknown commands as install file or install command
2626
* [#345](https://github.com/Icinga/icinga-powershell-framework/pull/345) Fixes Framework environment variables like `$IcingaEnums` not working with v1.6.0
2727
* [#351](https://github.com/Icinga/icinga-powershell-framework/pull/351) Fixes file writer which could cause corruption on parallel read/write events on the same file
28+
* [#359](https://github.com/Icinga/icinga-powershell-framework/issues/359) Fixes Plain Plugin Cmdlet execution on shell
2829

2930
### Enhancements
3031

lib/icinga/plugin/New-IcingaCheckResult.psm1

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,12 @@ function New-IcingaCheckResult()
2525
}
2626

2727
# Ensure we reset our internal cache once the plugin was executed
28-
$Global:Icinga.ThresholdCache[$this.Check.__GetCheckCommand()] = $null;
28+
$CheckCommand = $this.Check.__GetCheckCommand();
29+
if ([string]::IsNullOrEmpty($CheckCommand) -eq $FALSE -And $Global:Icinga.ThresholdCache.ContainsKey($CheckCommand)) {
30+
$Global:Icinga.ThresholdCache[$CheckCommand] = $null;
31+
}
2932
# Reset the current execution date
30-
$Global:Icinga.CurrentDate = $null;
33+
$Global:Icinga.CurrentDate = $null;
3134

3235
$ExitCode = $this.Check.__GetCheckState();
3336

lib/icinga/plugin/Write-IcingaPluginPerfData.psm1

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ function Write-IcingaPluginPerfData()
1919
$PerformanceData = $PerformanceData.perfdata;
2020
}
2121

22-
$CheckResultCache = $Global:Icinga.ThresholdCache[$CheckCommand];
22+
if ([string]::IsNullOrEmpty($CheckCommand) -eq $FALSE -And $Global:Icinga.ThresholdCache.ContainsKey($CheckCommand)) {
23+
$CheckResultCache = $Global:Icinga.ThresholdCache[$CheckCommand];
24+
} else {
25+
$CheckResultCache = New-Object PSCustomObject;
26+
}
2327

2428
if ($global:IcingaDaemonData.FrameworkRunningAsDaemon -eq $FALSE -And $global:IcingaDaemonData.JEAContext -eq $FALSE) {
2529
[string]$PerfDataOutput = (Get-IcingaPluginPerfDataContent -PerfData $PerformanceData -CheckResultCache $CheckResultCache -IcingaCheck $IcingaCheck);

0 commit comments

Comments
 (0)