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

Function parseArguments

plugins/check_disk.cpp:200–326  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

198}
199
200static int parseArguments(int ac, WCHAR **av, po::variables_map& vm, printInfoStruct& printInfo)
201{
202 WCHAR namePath[MAX_PATH];
203 GetModuleFileName(NULL, namePath, MAX_PATH);
204 WCHAR *progName = PathFindFileName(namePath);
205
206 po::options_description desc("Options");
207
208 desc.add_options()
209 ("help,h", "Print usage message and exit")
210 ("version,V", "Print version and exit")
211 ("debug,d", "Verbose/Debug output")
212 ("warning,w", po::wvalue<std::wstring>(), "Warning threshold")
213 ("critical,c", po::wvalue<std::wstring>(), "Critical threshold")
214 ("path,p", po::wvalue<std::vector<std::wstring>>()->multitoken(), "Declare explicitly which drives to check (default checks all)")
215 ("exclude_device,x", po::wvalue<std::vector<std::wstring>>()->multitoken(), "Exclude these drives from check")
216 ("exclude-type,X", po::wvalue<std::vector<std::wstring>>()->multitoken(), "Exclude partition types (ignored)")
217 ("iwarning,W", po::wvalue<std::wstring>(), "Warning threshold for inodes (ignored)")
218 ("icritical,K", po::wvalue<std::wstring>(), "Critical threshold for inodes (ignored)")
219 ("unit,u", po::wvalue<std::wstring>(), "Assign unit possible are: B, kB, MB, GB, TB")
220 ("show-used,U", "Show used space instead of the free space")
221 ("megabytes,m", "use megabytes, overridden by -unit")
222 ;
223
224 po::wcommand_line_parser parser(ac, av);
225
226 try {
227 po::store(
228 parser
229 .options(desc)
230 .style(
231 po::command_line_style::unix_style |
232 po::command_line_style::allow_long_disguise)
233 .run(),
234 vm);
235 vm.notify();
236 } catch (const std::exception& e) {
237 std::cout << e.what() << '\n' << desc << '\n';
238 return 3;
239 }
240
241 if (vm.count("help")) {
242 std::wcout << progName << " Help\n\tVersion: " << VERSION << '\n';
243 wprintf(
244 L"%s is a simple program to check a machines disk space usage.\n"
245 L"You can use the following options to define its behaviour:\n\n", progName);
246 std::cout << desc;
247 wprintf(
248 L"\nIt will then output a string looking something like this:\n\n"
249 L"\tDISK WARNING 29GB | disk=29GB;50%%;5;0;120\n\n"
250 L"\"DISK\" being the type of the check, \"WARNING\" the returned status\n"
251 L"and \"23.8304%%\" is the returned value.\n"
252 L"The performance data is found behind the \"|\", in order:\n"
253 L"returned value, warning threshold, critical threshold, minimal value and,\n"
254 L"if applicable, the maximal value.\n"
255 L"This program will also print out additional performance data disk by disk\n\n"
256 L"%s' exit codes denote the following:\n\n"
257 L" 0\tOK,\n\tNo Thresholds were broken or the programs check part was not executed\n"

Callers 1

wmainFunction · 0.70

Calls 5

thresholdClass · 0.85
parseBUnitFunction · 0.85
optionsMethod · 0.80
countMethod · 0.80
whatMethod · 0.45

Tested by

no test coverage detected