summaryrefslogtreecommitdiffstats
path: root/plugins/check_procs.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/check_procs.c')
-rw-r--r--plugins/check_procs.c28
1 files changed, 10 insertions, 18 deletions
diff --git a/plugins/check_procs.c b/plugins/check_procs.c
index 1be93f4..0cd9153 100644
--- a/plugins/check_procs.c
+++ b/plugins/check_procs.c
@@ -343,9 +343,7 @@ process_arguments (int argc, char **argv)
343 343
344 switch (c) { 344 switch (c) {
345 case '?': /* help */ 345 case '?': /* help */
346 printf (_("%s: Unknown argument: %s\n\n"), progname, optarg); 346 usage2 (_("Unknown argument"), optarg);
347 print_usage ();
348 exit (STATE_UNKNOWN);
349 case 'h': /* help */ 347 case 'h': /* help */
350 print_help (); 348 print_help ();
351 exit (STATE_OK); 349 exit (STATE_OK);
@@ -368,7 +366,7 @@ process_arguments (int argc, char **argv)
368 else if (sscanf (optarg, "%d:", &cmin) == 1) 366 else if (sscanf (optarg, "%d:", &cmin) == 1)
369 break; 367 break;
370 else 368 else
371 usage (_("Critical Process Count must be an integer!\n\n")); 369 usage4 (_("Critical Process Count must be an integer!"));
372 break; 370 break;
373 case 'w': /* warning threshold */ 371 case 'w': /* warning threshold */
374 if (is_integer (optarg)) 372 if (is_integer (optarg))
@@ -380,7 +378,7 @@ process_arguments (int argc, char **argv)
380 else if (sscanf (optarg, "%d:", &wmin) == 1) 378 else if (sscanf (optarg, "%d:", &wmin) == 1)
381 break; 379 break;
382 else 380 else
383 usage (_("Warning Process Count must be an integer!\n\n")); 381 usage4 (_("Warning Process Count must be an integer!"));
384 break; 382 break;
385 case 'p': /* process id */ 383 case 'p': /* process id */
386 if (sscanf (optarg, "%d%[^0-9]", &ppid, tmp) == 1) { 384 if (sscanf (optarg, "%d%[^0-9]", &ppid, tmp) == 1) {
@@ -388,7 +386,7 @@ process_arguments (int argc, char **argv)
388 options |= PPID; 386 options |= PPID;
389 break; 387 break;
390 } 388 }
391 usage2 (_("%s: Parent Process ID must be an integer!\n\n"), progname); 389 usage4 (_("Parent Process ID must be an integer!"));
392 case 's': /* status */ 390 case 's': /* status */
393 if (statopts) 391 if (statopts)
394 break; 392 break;
@@ -403,13 +401,13 @@ process_arguments (int argc, char **argv)
403 pw = getpwuid ((uid_t) uid); 401 pw = getpwuid ((uid_t) uid);
404 /* check to be sure user exists */ 402 /* check to be sure user exists */
405 if (pw == NULL) 403 if (pw == NULL)
406 usage2 (_("UID %s was not found\n"), optarg); 404 usage2 (_("UID %s was not found"), optarg);
407 } 405 }
408 else { 406 else {
409 pw = getpwnam (optarg); 407 pw = getpwnam (optarg);
410 /* check to be sure user exists */ 408 /* check to be sure user exists */
411 if (pw == NULL) 409 if (pw == NULL)
412 usage2 (_("User name %s was not found\n"), optarg); 410 usage2 (_("User name %s was not found"), optarg);
413 /* then get uid */ 411 /* then get uid */
414 uid = pw->pw_uid; 412 uid = pw->pw_uid;
415 } 413 }
@@ -443,14 +441,14 @@ process_arguments (int argc, char **argv)
443 options |= RSS; 441 options |= RSS;
444 break; 442 break;
445 } 443 }
446 usage2 (_("%s: RSS must be an integer!\n\n"), progname); 444 usage4 (_("RSS must be an integer!"));
447 case 'z': /* VSZ */ 445 case 'z': /* VSZ */
448 if (sscanf (optarg, "%d%[^0-9]", &vsz, tmp) == 1) { 446 if (sscanf (optarg, "%d%[^0-9]", &vsz, tmp) == 1) {
449 asprintf (&fmt, _("%s%sVSZ >= %d"), (fmt ? fmt : ""), (options ? ", " : ""), vsz); 447 asprintf (&fmt, _("%s%sVSZ >= %d"), (fmt ? fmt : ""), (options ? ", " : ""), vsz);
450 options |= VSZ; 448 options |= VSZ;
451 break; 449 break;
452 } 450 }
453 usage2 (_("%s: VSZ must be an integer!\n\n"), progname); 451 usage4 (_("VSZ must be an integer!"));
454 case 'P': /* PCPU */ 452 case 'P': /* PCPU */
455 /* TODO: -P 1.5.5 is accepted */ 453 /* TODO: -P 1.5.5 is accepted */
456 if (sscanf (optarg, "%f%[^0-9.]", &pcpu, tmp) == 1) { 454 if (sscanf (optarg, "%f%[^0-9.]", &pcpu, tmp) == 1) {
@@ -458,7 +456,7 @@ process_arguments (int argc, char **argv)
458 options |= PCPU; 456 options |= PCPU;
459 break; 457 break;
460 } 458 }
461 usage2 (_("%s: PCPU must be a float!\n\n"), progname); 459 usage4 (_("PCPU must be a float!"));
462 case 'm': 460 case 'm':
463 asprintf (&metric_name, "%s", optarg); 461 asprintf (&metric_name, "%s", optarg);
464 if ( strcmp(optarg, "PROCS") == 0) { 462 if ( strcmp(optarg, "PROCS") == 0) {
@@ -482,10 +480,7 @@ process_arguments (int argc, char **argv)
482 break; 480 break;
483 } 481 }
484 482
485 printf (_("%s: metric must be one of PROCS, VSZ, RSS, CPU, ELAPSED!\n\n"), 483 usage4 (_("Metric must be one of PROCS, VSZ, RSS, CPU, ELAPSED!"));
486 progname);
487 print_usage ();
488 exit (STATE_UNKNOWN);
489 case 'v': /* command */ 484 case 'v': /* command */
490 verbose++; 485 verbose++;
491 break; 486 break;
@@ -588,8 +583,6 @@ check_thresholds (int value)
588} 583}
589 584
590 585
591
592
593/* convert the elapsed time to seconds */ 586/* convert the elapsed time to seconds */
594int 587int
595convert_to_seconds(char *etime) { 588convert_to_seconds(char *etime) {
@@ -653,7 +646,6 @@ convert_to_seconds(char *etime) {
653} 646}
654 647
655 648
656
657void 649void
658print_help (void) 650print_help (void)
659{ 651{