Skip to content

Commit

Permalink
Fixes null exception on GetBaseThresholdArguments
Browse files Browse the repository at this point in the history
  • Loading branch information
LordHepipud committed Jul 5, 2021
1 parent 7a2e8af commit 0e3e84c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions doc/31-Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
* [#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
* [#295](https://github.com/Icinga/icinga-powershell-framework/issues/295) Fixes background service check daemon not working with arguments for plugins
* [#297](https://github.com/Icinga/icinga-powershell-framework/pull/297) Fixes null exception error which can occur in certain edge cases, caused by testing `New-IcingaCheck` directly without function wrapper

## 1.5.0 (2021-06-02)

Expand Down
24 changes: 24 additions & 0 deletions lib/icinga/plugin/Get-IcingaThresholdCache.psm1
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
function Get-IcingaThresholdCache()
{
param (
[string]$CheckCommand = $null
);

if ([string]::IsNullOrEmpty($CheckCommand)) {
return $null;
}

if ($null -eq $Global:Icinga) {
return $null;
}

if ($Global:Icinga.ContainsKey('ThresholdCache') -eq $FALSE) {
return $null;
}

if ($Global:Icinga.ThresholdCache.ContainsKey($CheckCommand) -eq $FALSE) {
return $null;
}

return $Global:Icinga.ThresholdCache[$CheckCommand];
}
2 changes: 1 addition & 1 deletion lib/icinga/plugin/New-IcingaCheck.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ function New-IcingaCheck()
'-BaseValue' = $this.BaseValue;
'-Unit' = $this.Unit;
'-CheckName' = $this.__GetName();
'-ThresholdCache' = $Global:Icinga.ThresholdCache[$this.__CheckCommand];
'-ThresholdCache' = (Get-IcingaThresholdCache -CheckCommand $this.__CheckCommand);
'-Translation' = $this.Translation;
'-TimeInterval' = $this.__TimeInterval;
};
Expand Down

0 comments on commit 0e3e84c

Please sign in to comment.