mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-23 13:45:04 +02:00
Merge pull request #6811 from Icinga/bugfix/win-check-memory-state-condition
Fix state conditions in check_memory and check_swap
This commit is contained in:
commit
7b39591c6b
@ -164,7 +164,7 @@ static int printOutput(printInfoStruct& printInfo)
|
|||||||
if (l_Debug)
|
if (l_Debug)
|
||||||
std::wcout << L"Constructing output string" << '\n';
|
std::wcout << L"Constructing output string" << '\n';
|
||||||
|
|
||||||
state state;
|
state state = OK;
|
||||||
|
|
||||||
std::wcout << L"MEMORY ";
|
std::wcout << L"MEMORY ";
|
||||||
|
|
||||||
@ -175,16 +175,13 @@ static int printOutput(printInfoStruct& printInfo)
|
|||||||
else
|
else
|
||||||
currentValue = printInfo.tRam - printInfo.aRam;
|
currentValue = printInfo.tRam - printInfo.aRam;
|
||||||
|
|
||||||
if (printInfo.warn.rend(currentValue, printInfo.tRam)) {
|
if (printInfo.warn.rend(currentValue, printInfo.tRam))
|
||||||
state = WARNING;
|
state = WARNING;
|
||||||
std::wcout << L"WARNING";
|
|
||||||
} else if (printInfo.crit.rend(currentValue, printInfo.tRam)) {
|
if (printInfo.crit.rend(currentValue, printInfo.tRam))
|
||||||
state = CRITICAL;
|
state = CRITICAL;
|
||||||
std::wcout << L"CRITICAL";
|
|
||||||
} else {
|
std::wcout << stateToString(state);
|
||||||
state = OK;
|
|
||||||
std::wcout << L"OK";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!printInfo.showUsed)
|
if (!printInfo.showUsed)
|
||||||
std::wcout << " - " << printInfo.percentFree << L"% free";
|
std::wcout << " - " << printInfo.percentFree << L"% free";
|
||||||
|
@ -194,16 +194,13 @@ static int printOutput(printInfoStruct& printInfo)
|
|||||||
else
|
else
|
||||||
currentValue = printInfo.tSwap - printInfo.aSwap;
|
currentValue = printInfo.tSwap - printInfo.aSwap;
|
||||||
|
|
||||||
if (printInfo.warn.rend(currentValue, printInfo.tSwap)) {
|
if (printInfo.warn.rend(currentValue, printInfo.tSwap))
|
||||||
state = WARNING;
|
state = WARNING;
|
||||||
std::wcout << L"WARNING - ";
|
|
||||||
} else if (printInfo.crit.rend(currentValue, printInfo.tSwap)) {
|
if (printInfo.crit.rend(currentValue, printInfo.tSwap))
|
||||||
state = CRITICAL;
|
state = CRITICAL;
|
||||||
std::wcout << L"CRITICAL - ";
|
|
||||||
} else {
|
std::wcout << stateToString(state) << " ";
|
||||||
state = OK;
|
|
||||||
std::wcout << L"OK - ";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!printInfo.showUsed)
|
if (!printInfo.showUsed)
|
||||||
std::wcout << printInfo.percentFree << L"% free ";
|
std::wcout << printInfo.percentFree << L"% free ";
|
||||||
|
@ -281,4 +281,13 @@ std::wstring formatErrorInfo(unsigned long err) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return out.str();
|
return out.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::wstring stateToString(const state& state) {
|
||||||
|
switch (state) {
|
||||||
|
case OK: return L"OK";
|
||||||
|
case WARNING: return L"WARNING";
|
||||||
|
case CRITICAL: return L"CRITICAL";
|
||||||
|
default: return L"UNKNOWN";
|
||||||
|
}
|
||||||
}
|
}
|
@ -76,4 +76,6 @@ std::wstring TunitStr(const Tunit&);
|
|||||||
void printErrorInfo(unsigned long err = 0);
|
void printErrorInfo(unsigned long err = 0);
|
||||||
std::wstring formatErrorInfo(unsigned long err);
|
std::wstring formatErrorInfo(unsigned long err);
|
||||||
|
|
||||||
|
std::wstring stateToString(const state&);
|
||||||
|
|
||||||
#endif /* THRESHOLDS_H */
|
#endif /* THRESHOLDS_H */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user