MCPcopy Create free account
hub / github.com/Icinga/icinga2 / check_swap

Function check_swap

plugins/check_swap.cpp:201–223  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

199}
200
201static int check_swap(printInfoStruct& printInfo)
202{
203 // Needs explicit cast: http://msinilo.pl/blog2/post/p1348/
204 PENUM_PAGE_FILE_CALLBACKW pageFileCallback = (PENUM_PAGE_FILE_CALLBACKW)EnumPageFilesProc;
205 std::vector<pageFileInfo> pageFiles;
206
207 if(!EnumPageFilesW(pageFileCallback, &pageFiles)) {
208 printErrorInfo();
209 return 3;
210 }
211
212 for (int i = 0; i < pageFiles.size(); i++) {
213 printInfo.tSwap += round(pageFiles.at(i).totalSwap / pow(1024.0, printInfo.unit));
214 printInfo.aSwap += round(pageFiles.at(i).availableSpwap / pow(1024.0, printInfo.unit));
215 }
216
217 if (printInfo.aSwap > 0 && printInfo.tSwap > 0)
218 printInfo.percentFree = 100.0 * printInfo.aSwap / printInfo.tSwap;
219 else
220 printInfo.percentFree = 0;
221
222 return -1;
223}
224
225int wmain(int argc, WCHAR **argv)
226{

Callers 1

wmainFunction · 0.85

Calls 2

printErrorInfoFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected