From: Michael Insel Date: Wed, 18 Apr 2018 19:24:16 +0000 (+0200) Subject: Fix Windows check_memory rounding X-Git-Tag: v2.9.0~65^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=refs%2Fpull%2F6239%2Fhead;p=icinga2 Fix Windows check_memory rounding This fixes a rounding problem within the Windows check_memory plugin. refs #6161 --- diff --git a/plugins/check_memory.cpp b/plugins/check_memory.cpp index f3ba8ec29..46c65649e 100644 --- a/plugins/check_memory.cpp +++ b/plugins/check_memory.cpp @@ -203,8 +203,8 @@ static int check_memory(printInfoStruct& printInfo) memBuf.dwLength = sizeof(memBuf); GlobalMemoryStatusEx(&memBuf); - printInfo.tRam = round(memBuf.ullTotalPhys / pow(1024.0, printInfo.unit)); - printInfo.aRam = round(memBuf.ullAvailPhys / pow(1024.0, printInfo.unit)); + printInfo.tRam = round((memBuf.ullTotalPhys / pow(1024.0, printInfo.unit) * pow(10.0, printInfo.unit))) / pow(10.0, printInfo.unit); + printInfo.aRam = round((memBuf.ullAvailPhys / pow(1024.0, printInfo.unit) * pow(10.0, printInfo.unit))) / pow(10.0, printInfo.unit); printInfo.percentFree = 100.0 * memBuf.ullAvailPhys / memBuf.ullTotalPhys; if (l_Debug)