Change some things up in the windows-plugins

refs #7886 #7778 #8060 #8115
This commit is contained in:
Jean Flach 2014-12-19 10:21:38 +01:00
parent 7be19a2134
commit 2e9944f4bd
10 changed files with 92 additions and 124 deletions

View File

@ -59,7 +59,7 @@ static bool getFreeAndCap(drive&, const Bunit&);
int wmain(int argc, wchar_t **argv) int wmain(int argc, wchar_t **argv)
{ {
vector<drive> vDrives; vector<drive> vDrives;
printInfoStruct printInfo{ false, false}; printInfoStruct printInfo{ };
po::variables_map vm; po::variables_map vm;
int ret; int ret;
@ -68,6 +68,9 @@ int wmain(int argc, wchar_t **argv)
if (ret != -1) if (ret != -1)
return ret; return ret;
printInfo.warn.legal = !printInfo.warn.legal;
printInfo.crit.legal = !printInfo.crit.legal;
if (printInfo.drives.empty()) if (printInfo.drives.empty())
ret = check_drives(vDrives); ret = check_drives(vDrives);
else else
@ -77,8 +80,10 @@ int wmain(int argc, wchar_t **argv)
return ret; return ret;
for (vector<drive>::iterator it = vDrives.begin(); it != vDrives.end(); ++it) { for (vector<drive>::iterator it = vDrives.begin(); it != vDrives.end(); ++it) {
if (!getFreeAndCap(*it, printInfo.unit)) if (!getFreeAndCap(*it, printInfo.unit)) {
wcout << L"Failed to access drive at " << it->name << endl;
return 3; return 3;
}
} }
return printOutput(printInfo, vDrives); return printOutput(printInfo, vDrives);
@ -93,9 +98,8 @@ int parseArguments(int ac, wchar_t **av, po::variables_map& vm, printInfoStruct&
po::options_description desc("Options"); po::options_description desc("Options");
desc.add_options() desc.add_options()
(",h", "print usage message and exit") ("help,h", "print usage message and exit")
("help", "print help message and exit") ("version,V", "print version and exit")
("version,v", "print version and exit")
("warning,w", po::wvalue<wstring>(), "warning threshold") ("warning,w", po::wvalue<wstring>(), "warning threshold")
("critical,c", po::wvalue<wstring>(), "critical threshold") ("critical,c", po::wvalue<wstring>(), "critical threshold")
("path,p", po::wvalue<vector<std::wstring>>()->multitoken(), "declare explicitly which drives to check (default checks all)") ("path,p", po::wvalue<vector<std::wstring>>()->multitoken(), "declare explicitly which drives to check (default checks all)")
@ -132,8 +136,7 @@ int parseArguments(int ac, wchar_t **av, po::variables_map& vm, printInfoStruct&
L"and \"23.8304%%\" is the returned value.\n" L"and \"23.8304%%\" is the returned value.\n"
L"The performance data is found behind the \"|\", in order:\n" L"The performance data is found behind the \"|\", in order:\n"
L"returned value, warning threshold, critical threshold, minimal value and,\n" L"returned value, warning threshold, critical threshold, minimal value and,\n"
L"if applicable, the maximal value. Performance data will only be displayed when\n" L"if applicable, the maximal value.\n"
L"you set at least one threshold\n"
L"This program will also print out additional performance data disk by disk\n\n" L"This program will also print out additional performance data disk by disk\n\n"
L"%s' exit codes denote the following:\n\n" L"%s' exit codes denote the following:\n\n"
L" 0\tOK,\n\tNo Thresholds were broken or the programs check part was not executed\n" L" 0\tOK,\n\tNo Thresholds were broken or the programs check part was not executed\n"
@ -142,10 +145,9 @@ int parseArguments(int ac, wchar_t **av, po::variables_map& vm, printInfoStruct&
L" 3\tUNKNOWN, \n\tThe program experienced an internal or input error\n\n" L" 3\tUNKNOWN, \n\tThe program experienced an internal or input error\n\n"
L"Threshold syntax:\n\n" L"Threshold syntax:\n\n"
L"-w THRESHOLD\n" L"-w THRESHOLD\n"
L"warn if threshold is broken, which means VALUE > THRESHOLD\n" L"warn if threshold is broken, which means VALUE < THRESHOLD\n\n"
L"(unless stated differently)\n\n"
L"-w !THRESHOLD\n" L"-w !THRESHOLD\n"
L"inverts threshold check, VALUE < THRESHOLD (analogous to above)\n\n" L"inverts threshold check, VALUE > THRESHOLD (analogous to above)\n\n"
L"-w [THR1-THR2]\n" L"-w [THR1-THR2]\n"
L"warn is VALUE is inside the range spanned by THR1 and THR2\n\n" L"warn is VALUE is inside the range spanned by THR1 and THR2\n\n"
L"-w ![THR1-THR2]\n" L"-w ![THR1-THR2]\n"
@ -161,11 +163,6 @@ int parseArguments(int ac, wchar_t **av, po::variables_map& vm, printInfoStruct&
return 0; return 0;
} }
if (vm.count("h")) {
cout << desc << endl;
return 0;
}
if (vm.count("version")) if (vm.count("version"))
cout << "Version: " << VERSION << endl; cout << "Version: " << VERSION << endl;
@ -211,11 +208,12 @@ int printOutput(printInfoStruct& printInfo, vector<drive>& vDrives)
for (vector<drive>::iterator it = vDrives.begin(); it != vDrives.end(); ++it) { for (vector<drive>::iterator it = vDrives.begin(); it != vDrives.end(); ++it) {
tCap += it->cap; tFree += it->free; tCap += it->cap; tFree += it->free;
perf << L" drive=\"" << it->name << L"\";cap=" << it->cap << unit << L";free=" << it->free << unit; perf << std::fixed << L" " << it->name << L"=" << removeZero(it->free) << unit << L";"
<< printInfo.warn.pString() << L";" << printInfo.crit.pString() << L";0;" << removeZero(tCap);
} }
prePerf << L"|disk=" << tFree << unit << L";" << printInfo.warn.pString() << L";" prePerf << L" | disk=" << removeZero(tFree) << unit << L";" << printInfo.warn.pString() << L";"
<< printInfo.crit.pString() << L";0;" << tCap; << printInfo.crit.pString() << L";0;" << removeZero(tCap);
if (printInfo.warn.perc) { if (printInfo.warn.perc) {
if (printInfo.warn.rend((tFree / tCap) * 100.0)) if (printInfo.warn.rend((tFree / tCap) * 100.0))
@ -313,6 +311,10 @@ int check_drives(vector<drive>& vDrives, printInfoStruct& printInfo)
if (it->at(it->length() - 1) != *slash) if (it->at(it->length() - 1) != *slash)
it->append(slash); it->append(slash);
if (std::wstring::npos == it->find(L":\\")) {
wcout << "A \":\" is required after the drive name of " << *it << endl;
return 3;
}
vDrives.push_back(drive(*it)); vDrives.push_back(drive(*it));
} }
return -1; return -1;
@ -325,8 +327,8 @@ bool getFreeAndCap(drive& drive, const Bunit& unit)
return FALSE; return FALSE;
} }
drive.cap = (tempTotal.QuadPart / pow(1024.0, unit)); drive.cap = round((tempTotal.QuadPart / pow(1024.0, unit)));
drive.free = (tempFree.QuadPart / pow(1024.0, unit)); drive.free = round((tempFree.QuadPart / pow(1024.0, unit)));
return TRUE; return TRUE;
} }

View File

@ -67,9 +67,8 @@ int parseArguments(int ac, wchar_t **av, po::variables_map& vm, printInfoStruct&
po::options_description desc; po::options_description desc;
desc.add_options() desc.add_options()
(",h", "print usage message and exit") ("help,h", "print usage message and exit")
("help", "print help message and exit") ("version,V", "print version and exit")
("version,v", "print version and exit")
("warning,w", po::wvalue<wstring>(), "warning value (in percent)") ("warning,w", po::wvalue<wstring>(), "warning value (in percent)")
("critical,c", po::wvalue<wstring>(), "critical value (in percent)") ("critical,c", po::wvalue<wstring>(), "critical value (in percent)")
; ;
@ -91,11 +90,6 @@ int parseArguments(int ac, wchar_t **av, po::variables_map& vm, printInfoStruct&
return 3; return 3;
} }
if (vm.count("h")) {
cout << desc << endl;
return 0;
}
if (vm.count("help")) { if (vm.count("help")) {
wcout << progName << " Help\n\tVersion: " << VERSION << endl; wcout << progName << " Help\n\tVersion: " << VERSION << endl;
wprintf( wprintf(
@ -176,7 +170,7 @@ int printOutput(printInfoStruct& printInfo)
state = CRITICAL; state = CRITICAL;
std::wstringstream perf; std::wstringstream perf;
perf << L"%|load=" << printInfo.load << L"%;" << printInfo.warn.pString() << L";" perf << L"% | load=" << printInfo.load << L"%;" << printInfo.warn.pString() << L";"
<< printInfo.crit.pString() << L";0;100" << endl; << printInfo.crit.pString() << L";0;100" << endl;
switch (state) { switch (state) {

View File

@ -75,9 +75,8 @@ int parseArguments(int ac, wchar_t **av, po::variables_map& vm, printInfoStruct&
po::options_description desc("Options"); po::options_description desc("Options");
desc.add_options() desc.add_options()
(",h", "print usage and exit") ("help,h", "print usage and exit")
("help", "print help message and exit") ("version,V", "print version and exit")
("version,v", "print version and exit")
("warning,w", po::wvalue<wstring>(), "warning value") ("warning,w", po::wvalue<wstring>(), "warning value")
("critical,c", po::wvalue<wstring>(), "critical value") ("critical,c", po::wvalue<wstring>(), "critical value")
; ;
@ -99,11 +98,6 @@ int parseArguments(int ac, wchar_t **av, po::variables_map& vm, printInfoStruct&
return 3; return 3;
} }
if (vm.count("h")) {
cout << desc << endl;
return 0;
}
if (vm.count("help")) { if (vm.count("help")) {
wcout << progName << " Help\n\tVersion: " << VERSION << endl; wcout << progName << " Help\n\tVersion: " << VERSION << endl;
wprintf( wprintf(
@ -187,17 +181,17 @@ int printOutput(printInfoStruct& printInfo, const vector<nInterface>& vInterface
if (printInfo.crit.rend(tIn + tOut)) if (printInfo.crit.rend(tIn + tOut))
state = CRITICAL; state = CRITICAL;
perfDataFirst << L"network=" << tIn + tOut << L"B/s;" << printInfo.warn.pString() << L";" << printInfo.crit.pString() << L";" << L"0 "; perfDataFirst << L"network=" << tIn + tOut << L"B/s;" << printInfo.warn.pString() << L";" << printInfo.crit.pString() << L";" << L"0; ";
switch (state) { switch (state) {
case OK: case OK:
wcout << L"NETWORK OK " << tIn + tOut << L"B/s|" << perfDataFirst.str() << tss.str() << endl; wcout << L"NETWORK OK " << tIn + tOut << L"B/s | " << perfDataFirst.str() << tss.str() << endl;
break; break;
case WARNING: case WARNING:
wcout << L"NETWORK WARNING " << tIn + tOut << L"B/s|" << perfDataFirst.str() << tss.str() << endl; wcout << L"NETWORK WARNING " << tIn + tOut << L"B/s | " << perfDataFirst.str() << tss.str() << endl;
break; break;
case CRITICAL: case CRITICAL:
wcout << L"NETWORK CRITICAL " << tIn + tOut << L"B/s|" << perfDataFirst.str() << tss.str() << endl; wcout << L"NETWORK CRITICAL " << tIn + tOut << L"B/s | " << perfDataFirst.str() << tss.str() << endl;
break; break;
} }

View File

@ -125,11 +125,6 @@ int parseArguments(int ac, wchar_t **av, po::variables_map& vm, printInfoStruct&
return 3; return 3;
} }
if (vm.count("-4") && vm.count("-6")) {
cout << "Conflicting options \"4\" and \"6\"" << endl;
return 3;
}
if (vm.count("help")) { if (vm.count("help")) {
wcout << progName << " Help\n\tVersion: " << VERSION << endl; wcout << progName << " Help\n\tVersion: " << VERSION << endl;
wprintf( wprintf(
@ -176,6 +171,11 @@ int parseArguments(int ac, wchar_t **av, po::variables_map& vm, printInfoStruct&
return 0; return 0;
} }
if (vm.count("-4") && vm.count("-6")) {
cout << "Conflicting options \"4\" and \"6\"" << endl;
return 3;
}
if (vm.count("warning")) { if (vm.count("warning")) {
std::vector<wstring> sVec = splitMultiOptions(vm["warning"].as<wstring>()); std::vector<wstring> sVec = splitMultiOptions(vm["warning"].as<wstring>());
if (sVec.size() != 2) { if (sVec.size() != 2) {
@ -278,6 +278,11 @@ int check_ping4(const printInfoStruct& pi, response& response)
return 3; return 3;
} }
if (*term != L'\0') {
std::wcout << pi.host << " is not a valid ip address" << std::endl;
return 3;
}
if ((hIcmp = IcmpCreateFile()) == INVALID_HANDLE_VALUE) if ((hIcmp = IcmpCreateFile()) == INVALID_HANDLE_VALUE)
goto die; goto die;

View File

@ -69,18 +69,22 @@ int printOutput(const int numProcs, printInfoStruct& printInfo)
if (printInfo.crit.rend(numProcs)) if (printInfo.crit.rend(numProcs))
state = CRITICAL; state = CRITICAL;
wstring user = L"";
if (!printInfo.user.empty())
user.append(L" processes of user ").append(printInfo.user);
switch (state) { switch (state) {
case OK: case OK:
wcout << L"PROCS OK " << numProcs << L"|procs=" << numProcs << L";" wcout << L"PROCS OK " << numProcs << user << L" | procs=" << numProcs << L";"
<< printInfo.warn.pString() << L";" << printInfo.crit.pString() << L";0" << endl; << printInfo.warn.pString() << L";" << printInfo.crit.pString() << L";0;" << endl;
break; break;
case WARNING: case WARNING:
wcout << L"PROCS WARNING " << numProcs << L"|procs=" << numProcs << L";" wcout << L"PROCS WARNING " << numProcs << user << L" | procs=" << numProcs << L";"
<< printInfo.warn.pString() << L";" << printInfo.crit.pString() << L";0" << endl; << printInfo.warn.pString() << L";" << printInfo.crit.pString() << L";0;" << endl;
break; break;
case CRITICAL: case CRITICAL:
wcout << L"PROCS CRITICAL " << numProcs << L"|procs=" << numProcs << L";" wcout << L"PROCS CRITICAL " << numProcs << user << L" | procs=" << numProcs << L";"
<< printInfo.warn.pString() << L";" << printInfo.crit.pString() << L";0" << endl; << printInfo.warn.pString() << L";" << printInfo.crit.pString() << L";0;" << endl;
break; break;
} }
@ -96,9 +100,8 @@ int parseArguments(int ac, wchar_t **av, po::variables_map& vm, printInfoStruct&
po::options_description desc; po::options_description desc;
desc.add_options() desc.add_options()
("h", "print help message and exit") ("help,h", "print help message and exit")
("help", "print verbose help and exit") ("version,V", "print version and exit")
("version,v", "print version and exit")
("warning,w", po::wvalue<wstring>(), "warning threshold") ("warning,w", po::wvalue<wstring>(), "warning threshold")
("critical,c", po::wvalue<wstring>(), "critical threshold") ("critical,c", po::wvalue<wstring>(), "critical threshold")
("user,u", po::wvalue<wstring>(), "count only processes by user [arg]") ("user,u", po::wvalue<wstring>(), "count only processes by user [arg]")
@ -120,11 +123,6 @@ int parseArguments(int ac, wchar_t **av, po::variables_map& vm, printInfoStruct&
std::cout << e.what() << endl << desc << endl; std::cout << e.what() << endl << desc << endl;
return 3; return 3;
} }
if (vm.count("h")) {
std::cout << desc << endl;
return 0;
}
if (vm.count("help")) { if (vm.count("help")) {
wcout << progName << " Help\n\tVersion: " << VERSION << endl; wcout << progName << " Help\n\tVersion: " << VERSION << endl;

View File

@ -67,9 +67,8 @@ int parseArguments(int ac, wchar_t **av, po::variables_map& vm, printInfoStruct&
po::options_description desc; po::options_description desc;
desc.add_options() desc.add_options()
(",h", "print help message and exit") ("help,h", "print help message and exit")
("help", "print verbose help and exit") ("version,V", "print version and exit")
("version,v", "print version and exit")
("service,s", po::wvalue<wstring>(), "service to check (required)") ("service,s", po::wvalue<wstring>(), "service to check (required)")
("warn,w", "return warning (1) instead of critical (2),\n when service is not running") ("warn,w", "return warning (1) instead of critical (2),\n when service is not running")
; ;
@ -90,12 +89,7 @@ int parseArguments(int ac, wchar_t **av, po::variables_map& vm, printInfoStruct&
cout << e.what() << endl << desc << endl; cout << e.what() << endl << desc << endl;
return 3; return 3;
} }
if (vm.count("h")) {
cout << desc << endl;
return 0;
}
if (vm.count("help")) { if (vm.count("help")) {
wcout << progName << " Help\n\tVersion: " << VERSION << endl; wcout << progName << " Help\n\tVersion: " << VERSION << endl;
wprintf( wprintf(
@ -145,18 +139,23 @@ int printOutput(const printInfoStruct& printInfo)
wstring perf; wstring perf;
state state = OK; state state = OK;
if (!printInfo.ServiceState) {
wcout << L"SERVICE CRITICAL NOT_FOUND | service=" << printInfo.ServiceState << ";!4;!4;1;7" << endl;
return 3;
}
if (printInfo.ServiceState != 0x04) if (printInfo.ServiceState != 0x04)
printInfo.warn ? state = WARNING : state = CRITICAL; printInfo.warn ? state = WARNING : state = CRITICAL;
switch (state) { switch (state) {
case OK: case OK:
wcout << L"SERVICE OK RUNNING|service=4;!4;!4;1;7" << endl; wcout << L"SERVICE OK RUNNING | service=4;!4;!4;1;7" << endl;
break; break;
case WARNING: case WARNING:
wcout << L"SERVICE WARNING NOT_RUNNING|service=" << printInfo.ServiceState << ";!4;!4;1;7" << endl; wcout << L"SERVICE WARNING NOT_RUNNING | service=" << printInfo.ServiceState << ";!4;!4;1;7" << endl;
break; break;
case CRITICAL: case CRITICAL:
wcout << L"SERVICE CRITICAL NOT_RUNNING|service=" << printInfo.ServiceState << ";!4;!4;1;7" << endl; wcout << L"SERVICE CRITICAL NOT_RUNNING | service=" << printInfo.ServiceState << ";!4;!4;1;7" << endl;
break; break;
} }
@ -194,7 +193,7 @@ int ServiceStatus(const printInfoStruct& printInfo)
return state; return state;
} }
} }
wcout << L"Service " << printInfo.service << L" could not be found\n"; return 0;
delete[] reinterpret_cast<LPBYTE>(lpServices); delete[] reinterpret_cast<LPBYTE>(lpServices);
return -1; return -1;

View File

@ -66,9 +66,8 @@ int parseArguments(int ac, wchar_t **av, po::variables_map& vm, printInfoStruct&
po::options_description desc; po::options_description desc;
desc.add_options() desc.add_options()
(",h", "print help message and exit") ("help,h", "print help message and exit")
("help", "print verbose help and exit") ("version,V", "print version and exit")
("version,v", "print version and exit")
("warning,w", po::wvalue<wstring>(), "warning threshold") ("warning,w", po::wvalue<wstring>(), "warning threshold")
("critical,c", po::wvalue<wstring>(), "critical threshold") ("critical,c", po::wvalue<wstring>(), "critical threshold")
; ;
@ -90,11 +89,6 @@ int parseArguments(int ac, wchar_t **av, po::variables_map& vm, printInfoStruct&
return 3; return 3;
} }
if (vm.count("h")) {
cout << desc << endl;
return 0;
}
if (vm.count("help")) { if (vm.count("help")) {
wcout << progName << " Help\n\tVersion: " << VERSION << endl; wcout << progName << " Help\n\tVersion: " << VERSION << endl;
wprintf( wprintf(
@ -171,15 +165,15 @@ int printOutput(printInfoStruct& printInfo)
switch (state) { switch (state) {
case OK: case OK:
wcout << L"SWAP OK " << printInfo.swap << L"%|swap=" << printInfo.swap << L"%;" wcout << L"SWAP OK " << printInfo.swap << L"% | swap=" << printInfo.swap << L"%;"
<< printInfo.warn.pString() << L";" << printInfo.crit.pString() << L";0;100" << endl; << printInfo.warn.pString() << L";" << printInfo.crit.pString() << L";0;100" << endl;
break; break;
case WARNING: case WARNING:
wcout << L"SWAP WARNING " << printInfo.swap << L"%|swap=" << printInfo.swap << L"%;" wcout << L"SWAP WARNING " << printInfo.swap << L"% | swap=" << printInfo.swap << L"%;"
<< printInfo.warn.pString() << L";" << printInfo.crit.pString() << L";0;100" << endl; << printInfo.warn.pString() << L";" << printInfo.crit.pString() << L";0;100" << endl;
break; break;
case CRITICAL: case CRITICAL:
wcout << L"SWAP CRITICAL " << printInfo.swap << L"%|swap=" << printInfo.swap << L"%;" wcout << L"SWAP CRITICAL " << printInfo.swap << L"% | swap=" << printInfo.swap << L"%;"
<< printInfo.warn.pString() << L";" << printInfo.crit.pString() << L";0;100" << endl; << printInfo.warn.pString() << L";" << printInfo.crit.pString() << L";0;100" << endl;
break; break;
} }

View File

@ -85,8 +85,8 @@ int printOutput(const printInfoStruct& printInfo)
break; break;
} }
wcout << output << printInfo.numUpdates << L"|update=" << printInfo.numUpdates << L";" wcout << output << printInfo.numUpdates << L" | update=" << printInfo.numUpdates << L";"
<< printInfo.warn << L";" << printInfo.crit << L";0" << endl; << printInfo.warn << L";" << printInfo.crit << L";0;" << endl;
return state; return state;
} }
@ -100,9 +100,8 @@ int parseArguments(int ac, wchar_t **av, po::variables_map& vm, printInfoStruct&
po::options_description desc; po::options_description desc;
desc.add_options() desc.add_options()
(",h", "print help message and exit") ("help,h", "print help message and exit")
("help", "print verbose help and exit") ("version,V", "print version and exit")
("version,v", "print version and exit")
("warning,w", "warn if there are important updates available") ("warning,w", "warn if there are important updates available")
("critical,c", "critical if there are important updates that require a reboot") ("critical,c", "critical if there are important updates that require a reboot")
("possible-reboot", "treat \"update may need to reboot\" as \"update needs to reboot\"") ("possible-reboot", "treat \"update may need to reboot\" as \"update needs to reboot\"")
@ -124,11 +123,6 @@ int parseArguments(int ac, wchar_t **av, po::variables_map& vm, printInfoStruct&
cout << e.what() << endl << desc << endl; cout << e.what() << endl << desc << endl;
return 3; return 3;
} }
if (vm.count("h")) {
cout << desc << endl;
return 0;
}
if (vm.count("help")) { if (vm.count("help")) {
wcout << progName << " Help\n\tVersion: " << VERSION << endl; wcout << progName << " Help\n\tVersion: " << VERSION << endl;

View File

@ -44,7 +44,7 @@ static int parseArguments(int, wchar_t **, po::variables_map&, printInfoStruct&)
static int printOutput(printInfoStruct&); static int printOutput(printInfoStruct&);
static void getUptime(printInfoStruct&); static void getUptime(printInfoStruct&);
int main(int argc, wchar_t **argv) int wmain(int argc, wchar_t **argv)
{ {
po::variables_map vm; po::variables_map vm;
printInfoStruct printInfo = { }; printInfoStruct printInfo = { };
@ -67,9 +67,8 @@ int parseArguments(int ac, wchar_t **av, po::variables_map& vm, printInfoStruct&
po::options_description desc; po::options_description desc;
desc.add_options() desc.add_options()
(",h", "print help message and exit") ("help,h", "print help message and exit")
("help", "print verbose help and exit") ("version,V", "print version and exit")
("version,v", "print version and exit")
("warning,w", po::wvalue<wstring>(), "warning threshold (Uses -unit)") ("warning,w", po::wvalue<wstring>(), "warning threshold (Uses -unit)")
("critical,c", po::wvalue<wstring>(), "critical threshold (Uses -unit)") ("critical,c", po::wvalue<wstring>(), "critical threshold (Uses -unit)")
("unit,u", po::wvalue<wstring>(), "desired unit of output\nh\t- hours\nm\t- minutes\ns\t- seconds (default)\nms\t- milliseconds") ("unit,u", po::wvalue<wstring>(), "desired unit of output\nh\t- hours\nm\t- minutes\ns\t- seconds (default)\nms\t- milliseconds")
@ -92,11 +91,6 @@ int parseArguments(int ac, wchar_t **av, po::variables_map& vm, printInfoStruct&
return 3; return 3;
} }
if (vm.count("h")) {
cout << desc << endl;
return 0;
}
if (vm.count("help")) { if (vm.count("help")) {
wcout << progName << " Help\n\tVersion: " << VERSION << endl; wcout << progName << " Help\n\tVersion: " << VERSION << endl;
wprintf( wprintf(
@ -185,19 +179,19 @@ static int printOutput(printInfoStruct& printInfo)
switch (state) { switch (state) {
case OK: case OK:
wcout << L"UPTIME OK " << printInfo.time << TunitStr(printInfo.unit) << L"|uptime=" << printInfo.time wcout << L"UPTIME OK " << printInfo.time << TunitStr(printInfo.unit) << L" | uptime=" << printInfo.time
<< TunitStr(printInfo.unit) << L";" << printInfo.warn.pString() << L";" << TunitStr(printInfo.unit) << L";" << printInfo.warn.pString() << L";"
<< printInfo.crit.pString() << L";0" << endl; << printInfo.crit.pString() << L";0;" << endl;
break; break;
case WARNING: case WARNING:
wcout << L"UPTIME WARNING " << printInfo.time << TunitStr(printInfo.unit) << L"|uptime=" << printInfo.time wcout << L"UPTIME WARNING " << printInfo.time << TunitStr(printInfo.unit) << L" | uptime=" << printInfo.time
<< TunitStr(printInfo.unit) << L";" << printInfo.warn.pString() << L";" << TunitStr(printInfo.unit) << L";" << printInfo.warn.pString() << L";"
<< printInfo.crit.pString() << L";0" << endl; << printInfo.crit.pString() << L";0;" << endl;
break; break;
case CRITICAL: case CRITICAL:
wcout << L"UPTIME CRITICAL " << printInfo.time << TunitStr(printInfo.unit) << L"|uptime=" << printInfo.time wcout << L"UPTIME CRITICAL " << printInfo.time << TunitStr(printInfo.unit) << L" | uptime=" << printInfo.time
<< TunitStr(printInfo.unit) << L";" << printInfo.warn.pString() << L";" << TunitStr(printInfo.unit) << L";" << printInfo.warn.pString() << L";"
<< printInfo.crit.pString() << L";0" << endl; << printInfo.crit.pString() << L";0;" << endl;
break; break;
} }

View File

@ -67,9 +67,8 @@ int parseArguments(int ac, wchar_t **av, po::variables_map& vm, printInfoStruct&
po::options_description desc; po::options_description desc;
desc.add_options() desc.add_options()
(",h", "print help message and exit") ("help,h", "print help message and exit")
("help", "print verbose help and exit") ("version,V", "print version and exit")
("version,v", "print version and exit")
("warning,w", po::wvalue<wstring>(), "warning threshold") ("warning,w", po::wvalue<wstring>(), "warning threshold")
("critical,c", po::wvalue<wstring>(), "critical threshold") ("critical,c", po::wvalue<wstring>(), "critical threshold")
; ;
@ -91,11 +90,6 @@ int parseArguments(int ac, wchar_t **av, po::variables_map& vm, printInfoStruct&
return 3; return 3;
} }
if (vm.count("h")) {
cout << desc << endl;
return 0;
}
if (vm.count("help")) { if (vm.count("help")) {
wcout << progName << " Help\n\tVersion: " << VERSION << endl; wcout << progName << " Help\n\tVersion: " << VERSION << endl;
wprintf( wprintf(
@ -172,16 +166,16 @@ int printOutput(printInfoStruct& printInfo)
switch (state) { switch (state) {
case OK: case OK:
wcout << L"USERS OK " << printInfo.users << L" User(s)|users=" << printInfo.users << L";" wcout << L"USERS OK " << printInfo.users << L" User(s) logged in | users=" << printInfo.users << L";"
<< printInfo.warn.pString() << L";" << printInfo.crit.pString() << L";0" << endl; << printInfo.warn.pString() << L";" << printInfo.crit.pString() << L";0;" << endl;
break; break;
case WARNING: case WARNING:
wcout << L"USERS WARNING " << printInfo.users << L" User(s)|users=" << printInfo.users << L";" wcout << L"USERS WARNING " << printInfo.users << L" User(s) logged in | users=" << printInfo.users << L";"
<< printInfo.warn.pString() << L";" << printInfo.crit.pString() << L";0" << endl; << printInfo.warn.pString() << L";" << printInfo.crit.pString() << L";0;" << endl;
break; break;
case CRITICAL: case CRITICAL:
wcout << L"USERS CRITICAL " << printInfo.users << L" User(s)|users=" << printInfo.users << L";" wcout << L"USERS CRITICAL " << printInfo.users << L" User(s) logged in | users=" << printInfo.users << L";"
<< printInfo.warn.pString() << L";" << printInfo.crit.pString() << L";0" << endl; << printInfo.warn.pString() << L";" << printInfo.crit.pString() << L";0;" << endl;
break; break;
} }