| 39 | static bool l_NoISATAP; |
| 40 | |
| 41 | static int parseArguments(int ac, WCHAR **av, po::variables_map& vm, printInfoStruct& printInfo) |
| 42 | { |
| 43 | WCHAR namePath[MAX_PATH]; |
| 44 | GetModuleFileName(NULL, namePath, MAX_PATH); |
| 45 | WCHAR *progName = PathFindFileName(namePath); |
| 46 | |
| 47 | po::options_description desc("Options"); |
| 48 | |
| 49 | desc.add_options() |
| 50 | ("help,h", "print usage and exit") |
| 51 | ("version,V", "print version and exit") |
| 52 | ("debug,d", "Verbose/Debug output") |
| 53 | ("noisatap,n", "Don't show ISATAP interfaces in output") |
| 54 | ("warning,w", po::wvalue<std::wstring>(), "warning value") |
| 55 | ("critical,c", po::wvalue<std::wstring>(), "critical value") |
| 56 | ; |
| 57 | |
| 58 | po::wcommand_line_parser parser(ac, av); |
| 59 | |
| 60 | try { |
| 61 | po::store( |
| 62 | parser |
| 63 | .options(desc) |
| 64 | .style( |
| 65 | po::command_line_style::unix_style | |
| 66 | po::command_line_style::allow_long_disguise) |
| 67 | .run(), |
| 68 | vm); |
| 69 | vm.notify(); |
| 70 | } catch (const std::exception& e) { |
| 71 | std::cout << e.what() << '\n' << desc << '\n'; |
| 72 | return 3; |
| 73 | } |
| 74 | |
| 75 | if (vm.count("help")) { |
| 76 | std::wcout << progName << " Help\n\tVersion: " << VERSION << '\n'; |
| 77 | wprintf( |
| 78 | L"%s is a simple program to check a machines network performance.\n" |
| 79 | L"You can use the following options to define its behaviour:\n\n", progName); |
| 80 | std::cout << desc; |
| 81 | wprintf( |
| 82 | L"\nIt will then output a string looking something like this:\n\n" |
| 83 | L"\tNETWORK WARNING 1131B/s | network=1131B;1000;7000;0\n\n" |
| 84 | L"\"NETWORK\" being the type of the check, \"WARNING\" the returned status\n" |
| 85 | L"and \"1131B/s\" is the returned value.\n" |
| 86 | L"The performance data is found behind the \"|\", in order:\n" |
| 87 | L"returned value, warning threshold, critical threshold, minimal value and,\n" |
| 88 | L"if applicable, the maximal value. Performance data will only be displayed when\n" |
| 89 | L"you set at least one threshold\n\n" |
| 90 | L"This program will also print out additional performance data interface\n" |
| 91 | L"by interface\n\n" |
| 92 | L"%s' exit codes denote the following:\n" |
| 93 | L" 0\tOK,\n\tNo Thresholds were broken or the programs check part was not executed\n" |
| 94 | L" 1\tWARNING,\n\tThe warning, but not the critical threshold was broken\n" |
| 95 | L" 2\tCRITICAL,\n\tThe critical threshold was broken\n" |
| 96 | L" 3\tUNKNOWN, \n\tThe program experienced an internal or input error\n\n" |
| 97 | L"Threshold syntax:\n\n" |
| 98 | L"-w THRESHOLD\n" |