mirror of https://github.com/Icinga/icinga2.git
Fix: check_memory tool shows incorrect memory size on windows
On a PC with >4GB of RAM, check_memory utility returns an incorrect amount of RAM: MEMORY OK - 100% free | memory=4096MB;;;0;4096 This patch uses GlobalMemoryStatusEx instead of GlobalMemoryStatus [https://msdn.microsoft.com/en-us/library/windows/desktop/aa366586%28v=vs.85%29.aspx] Following patch output of check_memory is as follows: MEMORY OK - 32.4873% free | memory=5312MB;;;0;16351 fixes #8559 Signed-off-by: Gunnar Beutner <gunnar@beutner.name>
This commit is contained in:
parent
2d65489f3a
commit
7ca3a3c5e9
|
@ -36,7 +36,7 @@ static BOOL debug = FALSE;
|
||||||
struct printInfoStruct
|
struct printInfoStruct
|
||||||
{
|
{
|
||||||
threshold warn, crit;
|
threshold warn, crit;
|
||||||
DWORD tRam, aRam;
|
DWORDLONG tRam, aRam;
|
||||||
Bunit unit = BunitMB;
|
Bunit unit = BunitMB;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -213,16 +213,18 @@ int check_memory(printInfoStruct& printInfo)
|
||||||
if (debug)
|
if (debug)
|
||||||
wcout << L"Accessing memory statistics via MemoryStatus" << endl;
|
wcout << L"Accessing memory statistics via MemoryStatus" << endl;
|
||||||
|
|
||||||
_MEMORYSTATUS *pMemBuf = new _MEMORYSTATUS;
|
_MEMORYSTATUSEX *pMemBuf = new _MEMORYSTATUSEX;
|
||||||
|
|
||||||
GlobalMemoryStatus(pMemBuf);
|
pMemBuf->dwLength = sizeof(*pMemBuf);
|
||||||
|
|
||||||
printInfo.tRam = round(pMemBuf->dwTotalPhys / pow(1024.0, printInfo.unit));
|
GlobalMemoryStatusEx(pMemBuf);
|
||||||
printInfo.aRam = round(pMemBuf->dwAvailPhys / pow(1024.0, printInfo.unit));
|
|
||||||
|
printInfo.tRam = round(pMemBuf->ullTotalPhys / pow(1024.0, printInfo.unit));
|
||||||
|
printInfo.aRam = round(pMemBuf->ullAvailPhys / pow(1024.0, printInfo.unit));
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
wcout << L"Found pMemBuf->dwTotalPhys: " << pMemBuf->dwTotalPhys << endl
|
wcout << L"Found pMemBuf->dwTotalPhys: " << pMemBuf->ullTotalPhys << endl
|
||||||
<< L"Found pMemBuf->dwAvailPhys: " << pMemBuf->dwAvailPhys << endl;
|
<< L"Found pMemBuf->dwAvailPhys: " << pMemBuf->ullAvailPhys << endl;
|
||||||
|
|
||||||
delete pMemBuf;
|
delete pMemBuf;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue