mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-21 07:10:15 -05:00
Merge pull request #208 from Icinga:fix/fix_generic_plugin_threshold_conversion
Fix: Plugin threshold conversion and adds % unit handling Fixes `Convert-IcingaPluginThresholds` which sometimes did not return proper numeric usable values for our internal functions, causing issues on plugin calls. In addition the function now also supports the handling for % units.
This commit is contained in:
commit
0893325293
2 changed files with 9 additions and 2 deletions
|
|
@ -23,6 +23,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
|
||||||
### Bugfixes
|
### Bugfixes
|
||||||
|
|
||||||
* [#206](https://github.com/Icinga/icinga-powershell-framework/pull/206) Fixes background service check daemon for collecting metrics over time which will no longer share data between configured checks which might cause higher CPU load and a possible memory leak
|
* [#206](https://github.com/Icinga/icinga-powershell-framework/pull/206) Fixes background service check daemon for collecting metrics over time which will no longer share data between configured checks which might cause higher CPU load and a possible memory leak
|
||||||
|
* [#208](https://github.com/Icinga/icinga-powershell-framework/pull/208) Fixes `Convert-IcingaPluginThresholds` which sometimes did not return proper numeric usable values for our internal functions, causing issues on plugin calls. In addition the function now also supports the handling for % units.
|
||||||
|
|
||||||
## 1.3.1 (2021-02-04)
|
## 1.3.1 (2021-02-04)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -128,6 +128,10 @@ function Convert-IcingaPluginThresholds()
|
||||||
}
|
}
|
||||||
$Value = (ConvertTo-Seconds -Value $ThresholdValue);
|
$Value = (ConvertTo-Seconds -Value $ThresholdValue);
|
||||||
$RetValue.Unit = $WorkUnit;
|
$RetValue.Unit = $WorkUnit;
|
||||||
|
} elseif (($ThresholdValue -Match "(^[\d\.]*) ?(%)")) {
|
||||||
|
$WorkUnit = '%';
|
||||||
|
$Value = ([string]$ThresholdValue).Replace(' ', '').Replace('%', '');
|
||||||
|
$RetValue.Unit = $WorkUnit;
|
||||||
} else {
|
} else {
|
||||||
$Value = $ThresholdValue;
|
$Value = $ThresholdValue;
|
||||||
}
|
}
|
||||||
|
|
@ -145,11 +149,13 @@ function Convert-IcingaPluginThresholds()
|
||||||
|
|
||||||
if ([string]::IsNullOrEmpty($Value) -eq $FALSE -And $Value.Contains(':') -eq $FALSE) {
|
if ([string]::IsNullOrEmpty($Value) -eq $FALSE -And $Value.Contains(':') -eq $FALSE) {
|
||||||
if ((Test-Numeric $Value)) {
|
if ((Test-Numeric $Value)) {
|
||||||
$RetValue.Value = [convert]::ToDecimal($Value);
|
$RetValue.Value = $Value;
|
||||||
return $RetValue;
|
return $RetValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Always ensure we are using correct digits
|
||||||
|
$Value = ([string]$Value).Replace(',', '.');
|
||||||
$RetValue.Value = $Value;
|
$RetValue.Value = $Value;
|
||||||
|
|
||||||
return $RetValue;
|
return $RetValue;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue