]> granicus.if.org Git - icinga2/commitdiff
Fix Windows check_memory rounding 6239/head
authorMichael Insel <michael@insel.email>
Wed, 18 Apr 2018 19:24:16 +0000 (21:24 +0200)
committerMichael Insel <michael@insel.email>
Wed, 18 Apr 2018 19:42:43 +0000 (21:42 +0200)
This fixes a rounding problem within the Windows check_memory plugin.

refs #6161

plugins/check_memory.cpp

index f3ba8ec29bde1ec6817f574ad3e74241d124170b..46c65649ec808d15fdbabe0e75a0ecc74573e18f 100644 (file)
@@ -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)