mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-21 07:10:15 -05:00
Fixes unhandled units might cause exception
This commit is contained in:
parent
72c1495165
commit
6b3f27fae1
1 changed files with 22 additions and 1 deletions
|
|
@ -133,7 +133,28 @@ function Convert-IcingaPluginThresholds()
|
|||
$Value = ([string]$ThresholdValue).Replace(' ', '').Replace('%', '');
|
||||
$RetValue.Unit = $WorkUnit;
|
||||
} else {
|
||||
# Load all other units/values genericly
|
||||
[string]$StrNumeric = '';
|
||||
[bool]$FirstChar = $TRUE;
|
||||
foreach ($entry in ([string]($ThresholdValue)).ToCharArray()) {
|
||||
if (Test-Numeric $entry) {
|
||||
$StrNumeric += $entry;
|
||||
$FirstChar = $FALSE;
|
||||
} else {
|
||||
if ([string]::IsNullOrEmpty($RetValue.Unit) -And $FirstChar -eq $FALSE) {
|
||||
$RetValue.Unit = $entry;
|
||||
} else {
|
||||
$StrNumeric = '';
|
||||
$RetValue.Unit = '';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ([string]::IsNullOrEmpty($StrNumeric)) {
|
||||
$Value = $ThresholdValue;
|
||||
} else {
|
||||
$Value = [decimal]$StrNumeric;
|
||||
}
|
||||
}
|
||||
|
||||
if ($HasTilde) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue