Skip to content

Commit 1ab41f1

Browse files
authored
Merge pull request #268 from Icinga:feature/ensure_output_of_number_is_numeric
Feature: Ensure numbers are printed as numeric with . instead of ','
2 parents 955c2b3 + e840d81 commit 1ab41f1

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

lib/core/tools/Convert-IcingaPluginValueToString.psm1

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,24 @@ function Convert-IcingaPluginValueToString()
1919
}
2020

2121
if ($Unit -eq '%' -Or [string]::IsNullOrEmpty($Unit)) {
22-
return ([string]::Format('{0}{1}', $AdjustedValue, $Unit));
22+
return ([string]::Format('{0}{1}', ([string]$AdjustedValue).Replace(',', '.'), $Unit));
2323
}
2424

2525
switch ($OriginalUnit) {
2626
{ ($_ -eq "Kbit") -or ($_ -eq "Mbit") -or ($_ -eq "Gbit") -or ($_ -eq "Tbit") -or ($_ -eq "Pbit") -or ($_ -eq "Ebit") -or ($_ -eq "Zbit") -or ($_ -eq "Ybit") } {
2727
$TransferSpeed = Get-IcingaNetworkInterfaceUnits -Value $Value;
28-
return ([string]::Format('{0}{1}', $TransferSpeed.LinkSpeed, $TransferSpeed.Unit));
28+
return ([string]::Format('{0}{1}', $TransferSpeed.LinkSpeed, $TransferSpeed.Unit)).Replace(',', '.');
2929
};
3030
{ ($_ -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") } {
31-
return (ConvertTo-BytesNextUnit -Value $Value -Unit $Unit -Units @('B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'));
31+
return (ConvertTo-BytesNextUnit -Value $Value -Unit $Unit -Units @('B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB')).Replace(',', '.');
3232
};
3333
{ ($_ -eq "KB") -or ($_ -eq "MB") -or ($_ -eq "GB") -or ($_ -eq "TB") -or ($_ -eq "PB") -or ($_ -eq "EB") -or ($_ -eq "ZB") -or ($_ -eq "YB") } {
34-
return (ConvertTo-BytesNextUnit -Value $Value -Unit $Unit -Units @('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'));
34+
return (ConvertTo-BytesNextUnit -Value $Value -Unit $Unit -Units @('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB')).Replace(',', '.');
3535
};
3636
's' {
37-
return (ConvertFrom-TimeSpan -Seconds $AdjustedValue)
37+
return (ConvertFrom-TimeSpan -Seconds $AdjustedValue).Replace(',', '.')
3838
};
3939
}
4040

41-
return ([string]::Format('{0}{1}', $AdjustedValue, $Unit));
41+
return ([string]::Format('{0}{1}', ([string]$AdjustedValue).Replace(',', '.'), $Unit));
4242
}

lib/icinga/plugin/Compare-IcingaPluginThresholds.psm1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ function Compare-IcingaPluginThresholds()
402402

403403
if ($UseDynamicPercentage -And $Unit -ne '%') {
404404
$IcingaThresholds.IcingaThreshold = $IcingaThresholds.PercentValue;
405-
$PluginCurrentValue = [string]::Format('{0}% ({1})', ([math]::Round($IcingaThresholds.Value, 2)), (Convert-IcingaPluginValueToString -Unit $Unit -Value $IcingaThresholds.RawValue -OriginalUnit $IcingaThresholds.OriginalUnit));
405+
$PluginCurrentValue = [string]::Format('{0}% ({1})', ([string]([math]::Round($IcingaThresholds.Value, 2))).Replace(',', '.'), (Convert-IcingaPluginValueToString -Unit $Unit -Value $IcingaThresholds.RawValue -OriginalUnit $IcingaThresholds.OriginalUnit));
406406
$PluginThresholdValue = $IcingaThresholds.RawThreshold;
407407
}
408408

@@ -411,11 +411,11 @@ function Compare-IcingaPluginThresholds()
411411

412412
if ([string]::IsNullOrEmpty($IcingaThresholds.Message) -eq $FALSE) {
413413
$PluginOutputMessage.Append(' ') | Out-Null;
414-
$PluginOutputMessage.Append($IcingaThresholds.Message) | Out-Null;
414+
$PluginOutputMessage.Append($IcingaThresholds.Message.Replace(',', '.')) | Out-Null;
415415

416416
if ([string]::IsNullOrEmpty($PluginThresholdValue) -eq $FALSE) {
417417
$PluginOutputMessage.Append(' ') | Out-Null;
418-
$PluginOutputMessage.Append($PluginThresholdValue) | Out-Null;
418+
$PluginOutputMessage.Append(([string]$PluginThresholdValue).Replace(',', '.')) | Out-Null;
419419
}
420420
}
421421

0 commit comments

Comments
 (0)