diff --git a/doc/100-General/10-Changelog.md b/doc/100-General/10-Changelog.md index 4b9d8ba..9ebd455 100644 --- a/doc/100-General/10-Changelog.md +++ b/doc/100-General/10-Changelog.md @@ -15,6 +15,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic * [#814](https://github.com/Icinga/icinga-powershell-framework/pull/814) Fixes random chars function to truly generate unpredictable character sequences and to replace `Get-Random` which is not entirely secure * [#815](https://github.com/Icinga/icinga-powershell-framework/pull/815) Fixes a possible crash for `Test-IcingaAddTypeExist`, causing the Icinga for Windows installation to fail when third party components are checked which are malfunctioning +* [#816](https://github.com/Icinga/icinga-powershell-framework/issues/816) Fixes plugin execution error while using any `%IfNotMatch`/`%IfNotLike`/`%IfMatch`/`%IfLike` check function for strings containing special characters like `:` * [#829](https://github.com/Icinga/icinga-powershell-framework/pull/829) Fixes `Set-IcingaCacheData` to properly remove cache files in case `$null` is passed as value * [#833](https://github.com/Icinga/icinga-powershell-framework/issues/833) Fixes registry lookup for Icinga Agent installation to check if the required `DisplayName` attribute is defined before checking * [#834](https://github.com/Icinga/icinga-powershell-framework/issues/834) Fixes security catalog compilation error on non-english Windows versions, while properly skipping checks on system SID's and improves security by always adding the `SeDenyNetworkLogonRight` and `SeDenyInteractiveLogonRight` privilege section for the JEA user SID diff --git a/lib/core/tools/Convert-IcingaPluginThresholds.psm1 b/lib/core/tools/Convert-IcingaPluginThresholds.psm1 index 76fc755..d781611 100644 --- a/lib/core/tools/Convert-IcingaPluginThresholds.psm1 +++ b/lib/core/tools/Convert-IcingaPluginThresholds.psm1 @@ -28,6 +28,12 @@ .FUNCTIONALITY Converts values with units to the lowest unit of this category. Accepts Icinga Thresholds. +.PARAMETER Threshold + The threshold value to convert. Supports Icinga plugin threshold + syntax. +.PARAMETER RawValue + If set, the function will return the raw value without any conversion. + This is required for match/not match checks as example .EXAMPLE PS>Convert-IcingaPluginThresholds -Threshold '20d'; @@ -128,7 +134,8 @@ function Convert-IcingaPluginThresholds() { param ( - [string]$Threshold = $null + [string]$Threshold = $null, + [switch]$RawValue = $false ); [hashtable]$RetValue = @{ @@ -142,7 +149,10 @@ function Convert-IcingaPluginThresholds() 'IsDateTime' = $FALSE; }; - if ([string]::IsNullOrEmpty($Threshold)) { + # Always ensure Value is set, because we just want the raw value + if ([string]::IsNullOrEmpty($Threshold) -or $RawValue) { + $RetValue.Value = $Threshold; + return $RetValue; } diff --git a/lib/icinga/plugin/Compare-IcingaPluginThresholds.psm1 b/lib/icinga/plugin/Compare-IcingaPluginThresholds.psm1 index 998d289..af2a32f 100644 --- a/lib/icinga/plugin/Compare-IcingaPluginThresholds.psm1 +++ b/lib/icinga/plugin/Compare-IcingaPluginThresholds.psm1 @@ -103,13 +103,20 @@ function Compare-IcingaPluginThresholds() try { # Fix possible numeric value comparison issues - $TestInput = Test-IcingaDecimal $InputValue; - $BaseInput = Test-IcingaDecimal $BaseValue; - $MoTData = @{ + [bool]$RawValue = $false; + $TestInput = Test-IcingaDecimal $InputValue; + $BaseInput = Test-IcingaDecimal $BaseValue; + $MoTData = @{ 'Label' = $PerfDataLabel; 'Interval' = $TimeInterval; }; + # Ensure we never do threshold conversions for match/not match checks + # This ensures that string values are properly compared to each other + if ($Matches -or $NotMatches) { + $RawValue = $true; + } + # Ensure we do not include our checks for which we do not write any performance data # Metrics over time will not work for those, as the metrics are not stored. # There just set the variable to null which means they won't be processed @@ -130,9 +137,9 @@ function Compare-IcingaPluginThresholds() $IcingaThresholds | Add-Member -MemberType NoteProperty -Name 'Message' -Value ''; $IcingaThresholds | Add-Member -MemberType NoteProperty -Name 'IsOK' -Value $FALSE; $IcingaThresholds | Add-Member -MemberType NoteProperty -Name 'HasError' -Value $FALSE; - $IcingaThresholds | Add-Member -MemberType NoteProperty -Name 'Threshold' -Value (Convert-IcingaPluginThresholds -Threshold $Threshold); - $IcingaThresholds | Add-Member -MemberType NoteProperty -Name 'Minimum' -Value (Convert-IcingaPluginThresholds -Threshold $Minium); - $IcingaThresholds | Add-Member -MemberType NoteProperty -Name 'Maximum' -Value (Convert-IcingaPluginThresholds -Threshold $Maximum); + $IcingaThresholds | Add-Member -MemberType NoteProperty -Name 'Threshold' -Value (Convert-IcingaPluginThresholds -Threshold $Threshold -RawValue:$RawValue); + $IcingaThresholds | Add-Member -MemberType NoteProperty -Name 'Minimum' -Value (Convert-IcingaPluginThresholds -Threshold $Minium -RawValue:$RawValue); + $IcingaThresholds | Add-Member -MemberType NoteProperty -Name 'Maximum' -Value (Convert-IcingaPluginThresholds -Threshold $Maximum -RawValue:$RawValue); if ($TestInput.Decimal) { $ConvertedValue = Convert-IcingaPluginThresholds -Threshold ([string]::Format('{0}{1}', $InputValue, $Unit));