Skip to content

Commit f8aab34

Browse files
committed
Fixes broken percent calculation for possible float values
1 parent d660067 commit f8aab34

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

plugins/Invoke-IcingaCheckMemory.psm1

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,17 @@ function Invoke-IcingaCheckMemory()
106106

107107
If ($null -ne $CriticalPercent) {
108108
if ([string]::IsNullOrEmpty($Critical)) {
109-
$CriticalConverted = (Convert-Bytes ([string]::Format('{0}B', $MemoryData['Memory Total Bytes'] / 100 * $CriticalPercent)) -Unit $CalcUnit).Value;
109+
[string]$Value = ([string]::Format('{0}B', ($MemoryData['Memory Total Bytes'] / 100 * $CriticalPercent)));
110+
$Value = $Value.Replace(',', '.');
111+
$CriticalConverted = (Convert-Bytes $Value -Unit $CalcUnit).Value;
110112
}
111113
}
112114

113115
If ($null -ne $WarningPercent) {
114116
if ([string]::IsNullOrEmpty($Warning)) {
115-
$WarningConverted = (Convert-Bytes ([string]::Format('{0}B', $MemoryData['Memory Total Bytes'] / 100 * $WarningPercent)) -Unit $CalcUnit).Value;
117+
[string]$Value = ([string]::Format('{0}B', ($MemoryData['Memory Total Bytes'] / 100 * $WarningPercent)));
118+
$Value = $Value.Replace(',', '.');
119+
$WarningConverted = (Convert-Bytes $Value -Unit $CalcUnit).Value;
116120
}
117121
}
118122

0 commit comments

Comments
 (0)