Ensure numbers are printed as numeric with .

This commit is contained in:
Lord Hepipud 2021-05-31 15:58:42 +02:00
parent 955c2b31f5
commit e840d81148
2 changed files with 9 additions and 9 deletions

View file

@ -19,24 +19,24 @@ function Convert-IcingaPluginValueToString()
} }
if ($Unit -eq '%' -Or [string]::IsNullOrEmpty($Unit)) { if ($Unit -eq '%' -Or [string]::IsNullOrEmpty($Unit)) {
return ([string]::Format('{0}{1}', $AdjustedValue, $Unit)); return ([string]::Format('{0}{1}', ([string]$AdjustedValue).Replace(',', '.'), $Unit));
} }
switch ($OriginalUnit) { switch ($OriginalUnit) {
{ ($_ -eq "Kbit") -or ($_ -eq "Mbit") -or ($_ -eq "Gbit") -or ($_ -eq "Tbit") -or ($_ -eq "Pbit") -or ($_ -eq "Ebit") -or ($_ -eq "Zbit") -or ($_ -eq "Ybit") } { { ($_ -eq "Kbit") -or ($_ -eq "Mbit") -or ($_ -eq "Gbit") -or ($_ -eq "Tbit") -or ($_ -eq "Pbit") -or ($_ -eq "Ebit") -or ($_ -eq "Zbit") -or ($_ -eq "Ybit") } {
$TransferSpeed = Get-IcingaNetworkInterfaceUnits -Value $Value; $TransferSpeed = Get-IcingaNetworkInterfaceUnits -Value $Value;
return ([string]::Format('{0}{1}', $TransferSpeed.LinkSpeed, $TransferSpeed.Unit)); return ([string]::Format('{0}{1}', $TransferSpeed.LinkSpeed, $TransferSpeed.Unit)).Replace(',', '.');
}; };
{ ($_ -eq "B") -or ($_ -eq "KiB") -or ($_ -eq "MiB") -or ($_ -eq "GiB") -or ($_ -eq "TiB") -or ($_ -eq "PiB") -or ($_ -eq "EiB") -or ($_ -eq "ZiB") -or ($_ -eq "YiB") } { { ($_ -eq "B") -or ($_ -eq "KiB") -or ($_ -eq "MiB") -or ($_ -eq "GiB") -or ($_ -eq "TiB") -or ($_ -eq "PiB") -or ($_ -eq "EiB") -or ($_ -eq "ZiB") -or ($_ -eq "YiB") } {
return (ConvertTo-BytesNextUnit -Value $Value -Unit $Unit -Units @('B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB')); return (ConvertTo-BytesNextUnit -Value $Value -Unit $Unit -Units @('B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB')).Replace(',', '.');
}; };
{ ($_ -eq "KB") -or ($_ -eq "MB") -or ($_ -eq "GB") -or ($_ -eq "TB") -or ($_ -eq "PB") -or ($_ -eq "EB") -or ($_ -eq "ZB") -or ($_ -eq "YB") } { { ($_ -eq "KB") -or ($_ -eq "MB") -or ($_ -eq "GB") -or ($_ -eq "TB") -or ($_ -eq "PB") -or ($_ -eq "EB") -or ($_ -eq "ZB") -or ($_ -eq "YB") } {
return (ConvertTo-BytesNextUnit -Value $Value -Unit $Unit -Units @('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB')); return (ConvertTo-BytesNextUnit -Value $Value -Unit $Unit -Units @('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB')).Replace(',', '.');
}; };
's' { 's' {
return (ConvertFrom-TimeSpan -Seconds $AdjustedValue) return (ConvertFrom-TimeSpan -Seconds $AdjustedValue).Replace(',', '.')
}; };
} }
return ([string]::Format('{0}{1}', $AdjustedValue, $Unit)); return ([string]::Format('{0}{1}', ([string]$AdjustedValue).Replace(',', '.'), $Unit));
} }

View file

@ -402,7 +402,7 @@ function Compare-IcingaPluginThresholds()
if ($UseDynamicPercentage -And $Unit -ne '%') { if ($UseDynamicPercentage -And $Unit -ne '%') {
$IcingaThresholds.IcingaThreshold = $IcingaThresholds.PercentValue; $IcingaThresholds.IcingaThreshold = $IcingaThresholds.PercentValue;
$PluginCurrentValue = [string]::Format('{0}% ({1})', ([math]::Round($IcingaThresholds.Value, 2)), (Convert-IcingaPluginValueToString -Unit $Unit -Value $IcingaThresholds.RawValue -OriginalUnit $IcingaThresholds.OriginalUnit)); $PluginCurrentValue = [string]::Format('{0}% ({1})', ([string]([math]::Round($IcingaThresholds.Value, 2))).Replace(',', '.'), (Convert-IcingaPluginValueToString -Unit $Unit -Value $IcingaThresholds.RawValue -OriginalUnit $IcingaThresholds.OriginalUnit));
$PluginThresholdValue = $IcingaThresholds.RawThreshold; $PluginThresholdValue = $IcingaThresholds.RawThreshold;
} }
@ -411,11 +411,11 @@ function Compare-IcingaPluginThresholds()
if ([string]::IsNullOrEmpty($IcingaThresholds.Message) -eq $FALSE) { if ([string]::IsNullOrEmpty($IcingaThresholds.Message) -eq $FALSE) {
$PluginOutputMessage.Append(' ') | Out-Null; $PluginOutputMessage.Append(' ') | Out-Null;
$PluginOutputMessage.Append($IcingaThresholds.Message) | Out-Null; $PluginOutputMessage.Append($IcingaThresholds.Message.Replace(',', '.')) | Out-Null;
if ([string]::IsNullOrEmpty($PluginThresholdValue) -eq $FALSE) { if ([string]::IsNullOrEmpty($PluginThresholdValue) -eq $FALSE) {
$PluginOutputMessage.Append(' ') | Out-Null; $PluginOutputMessage.Append(' ') | Out-Null;
$PluginOutputMessage.Append($PluginThresholdValue) | Out-Null; $PluginOutputMessage.Append(([string]$PluginThresholdValue).Replace(',', '.')) | Out-Null;
} }
} }