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.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/plugins/check_procs.c b/plugins/check_procs.c
index d875a618..2f2dcc58 100644
--- a/plugins/check_procs.c
+++ b/plugins/check_procs.c
@@ -137,7 +137,7 @@ main (int argc, char **argv)
137 input_buffer = malloc (MAX_INPUT_BUFFER); 137 input_buffer = malloc (MAX_INPUT_BUFFER);
138 procprog = malloc (MAX_INPUT_BUFFER); 138 procprog = malloc (MAX_INPUT_BUFFER);
139 139
140 asprintf (&metric_name, "PROCS"); 140 xasprintf (&metric_name, "PROCS");
141 metric = METRIC_PROCS; 141 metric = METRIC_PROCS;
142 142
143 /* Parse extra opts if any */ 143 /* Parse extra opts if any */
@@ -176,7 +176,7 @@ main (int argc, char **argv)
176 printf ("%s", input_line); 176 printf ("%s", input_line);
177 177
178 strcpy (procprog, ""); 178 strcpy (procprog, "");
179 asprintf (&procargs, "%s", ""); 179 xasprintf (&procargs, "%s", "");
180 180
181 cols = sscanf (input_line, PS_FORMAT, PS_VARLIST); 181 cols = sscanf (input_line, PS_FORMAT, PS_VARLIST);
182 182
@@ -186,7 +186,7 @@ main (int argc, char **argv)
186 } 186 }
187 if ( cols >= expected_cols ) { 187 if ( cols >= expected_cols ) {
188 resultsum = 0; 188 resultsum = 0;
189 asprintf (&procargs, "%s", input_line + pos); 189 xasprintf (&procargs, "%s", input_line + pos);
190 strip (procargs); 190 strip (procargs);
191 191
192 /* Some ps return full pathname for command. This removes path */ 192 /* Some ps return full pathname for command. This removes path */
@@ -250,12 +250,12 @@ main (int argc, char **argv)
250 if (metric != METRIC_PROCS) { 250 if (metric != METRIC_PROCS) {
251 if (i == STATE_WARNING) { 251 if (i == STATE_WARNING) {
252 warn++; 252 warn++;
253 asprintf (&fails, "%s%s%s", fails, (strcmp(fails,"") ? ", " : ""), procprog); 253 xasprintf (&fails, "%s%s%s", fails, (strcmp(fails,"") ? ", " : ""), procprog);
254 result = max_state (result, i); 254 result = max_state (result, i);
255 } 255 }
256 if (i == STATE_CRITICAL) { 256 if (i == STATE_CRITICAL) {
257 crit++; 257 crit++;
258 asprintf (&fails, "%s%s%s", fails, (strcmp(fails,"") ? ", " : ""), procprog); 258 xasprintf (&fails, "%s%s%s", fails, (strcmp(fails,"") ? ", " : ""), procprog);
259 result = max_state (result, i); 259 result = max_state (result, i);
260 } 260 }
261 } 261 }
@@ -393,7 +393,7 @@ process_arguments (int argc, char **argv)
393 break; 393 break;
394 case 'p': /* process id */ 394 case 'p': /* process id */
395 if (sscanf (optarg, "%d%[^0-9]", &ppid, tmp) == 1) { 395 if (sscanf (optarg, "%d%[^0-9]", &ppid, tmp) == 1) {
396 asprintf (&fmt, "%s%sPPID = %d", (fmt ? fmt : "") , (options ? ", " : ""), ppid); 396 xasprintf (&fmt, "%s%sPPID = %d", (fmt ? fmt : "") , (options ? ", " : ""), ppid);
397 options |= PPID; 397 options |= PPID;
398 break; 398 break;
399 } 399 }
@@ -403,7 +403,7 @@ process_arguments (int argc, char **argv)
403 break; 403 break;
404 else 404 else
405 statopts = optarg; 405 statopts = optarg;
406 asprintf (&fmt, _("%s%sSTATE = %s"), (fmt ? fmt : ""), (options ? ", " : ""), statopts); 406 xasprintf (&fmt, _("%s%sSTATE = %s"), (fmt ? fmt : ""), (options ? ", " : ""), statopts);
407 options |= STAT; 407 options |= STAT;
408 break; 408 break;
409 case 'u': /* user or user id */ 409 case 'u': /* user or user id */
@@ -423,7 +423,7 @@ process_arguments (int argc, char **argv)
423 uid = pw->pw_uid; 423 uid = pw->pw_uid;
424 } 424 }
425 user = pw->pw_name; 425 user = pw->pw_name;
426 asprintf (&fmt, "%s%sUID = %d (%s)", (fmt ? fmt : ""), (options ? ", " : ""), 426 xasprintf (&fmt, "%s%sUID = %d (%s)", (fmt ? fmt : ""), (options ? ", " : ""),
427 uid, user); 427 uid, user);
428 options |= USER; 428 options |= USER;
429 break; 429 break;
@@ -433,7 +433,7 @@ process_arguments (int argc, char **argv)
433 break; 433 break;
434 else 434 else
435 prog = optarg; 435 prog = optarg;
436 asprintf (&fmt, _("%s%scommand name '%s'"), (fmt ? fmt : ""), (options ? ", " : ""), 436 xasprintf (&fmt, _("%s%scommand name '%s'"), (fmt ? fmt : ""), (options ? ", " : ""),
437 prog); 437 prog);
438 options |= PROG; 438 options |= PROG;
439 break; 439 break;
@@ -443,7 +443,7 @@ process_arguments (int argc, char **argv)
443 break; 443 break;
444 else 444 else
445 args = optarg; 445 args = optarg;
446 asprintf (&fmt, "%s%sargs '%s'", (fmt ? fmt : ""), (options ? ", " : ""), args); 446 xasprintf (&fmt, "%s%sargs '%s'", (fmt ? fmt : ""), (options ? ", " : ""), args);
447 options |= ARGS; 447 options |= ARGS;
448 break; 448 break;
449 case CHAR_MAX+1: 449 case CHAR_MAX+1:
@@ -459,19 +459,19 @@ process_arguments (int argc, char **argv)
459 temp_string[i]=','; 459 temp_string[i]=',';
460 i++; 460 i++;
461 } 461 }
462 asprintf (&fmt, "%s%sregex args '%s'", (fmt ? fmt : ""), (options ? ", " : ""), temp_string); 462 xasprintf (&fmt, "%s%sregex args '%s'", (fmt ? fmt : ""), (options ? ", " : ""), temp_string);
463 options |= EREG_ARGS; 463 options |= EREG_ARGS;
464 break; 464 break;
465 case 'r': /* RSS */ 465 case 'r': /* RSS */
466 if (sscanf (optarg, "%d%[^0-9]", &rss, tmp) == 1) { 466 if (sscanf (optarg, "%d%[^0-9]", &rss, tmp) == 1) {
467 asprintf (&fmt, "%s%sRSS >= %d", (fmt ? fmt : ""), (options ? ", " : ""), rss); 467 xasprintf (&fmt, "%s%sRSS >= %d", (fmt ? fmt : ""), (options ? ", " : ""), rss);
468 options |= RSS; 468 options |= RSS;
469 break; 469 break;
470 } 470 }
471 usage4 (_("RSS must be an integer!")); 471 usage4 (_("RSS must be an integer!"));
472 case 'z': /* VSZ */ 472 case 'z': /* VSZ */
473 if (sscanf (optarg, "%d%[^0-9]", &vsz, tmp) == 1) { 473 if (sscanf (optarg, "%d%[^0-9]", &vsz, tmp) == 1) {
474 asprintf (&fmt, "%s%sVSZ >= %d", (fmt ? fmt : ""), (options ? ", " : ""), vsz); 474 xasprintf (&fmt, "%s%sVSZ >= %d", (fmt ? fmt : ""), (options ? ", " : ""), vsz);
475 options |= VSZ; 475 options |= VSZ;
476 break; 476 break;
477 } 477 }
@@ -479,13 +479,13 @@ process_arguments (int argc, char **argv)
479 case 'P': /* PCPU */ 479 case 'P': /* PCPU */
480 /* TODO: -P 1.5.5 is accepted */ 480 /* TODO: -P 1.5.5 is accepted */
481 if (sscanf (optarg, "%f%[^0-9.]", &pcpu, tmp) == 1) { 481 if (sscanf (optarg, "%f%[^0-9.]", &pcpu, tmp) == 1) {
482 asprintf (&fmt, "%s%sPCPU >= %.2f", (fmt ? fmt : ""), (options ? ", " : ""), pcpu); 482 xasprintf (&fmt, "%s%sPCPU >= %.2f", (fmt ? fmt : ""), (options ? ", " : ""), pcpu);
483 options |= PCPU; 483 options |= PCPU;
484 break; 484 break;
485 } 485 }
486 usage4 (_("PCPU must be a float!")); 486 usage4 (_("PCPU must be a float!"));
487 case 'm': 487 case 'm':
488 asprintf (&metric_name, "%s", optarg); 488 xasprintf (&metric_name, "%s", optarg);
489 if ( strcmp(optarg, "PROCS") == 0) { 489 if ( strcmp(optarg, "PROCS") == 0) {
490 metric = METRIC_PROCS; 490 metric = METRIC_PROCS;
491 break; 491 break;
@@ -523,8 +523,8 @@ process_arguments (int argc, char **argv)
523 if (cmax == -1 && argv[c]) 523 if (cmax == -1 && argv[c])
524 cmax = atoi (argv[c++]); 524 cmax = atoi (argv[c++]);
525 if (statopts == NULL && argv[c]) { 525 if (statopts == NULL && argv[c]) {
526 asprintf (&statopts, "%s", argv[c++]); 526 xasprintf (&statopts, "%s", argv[c++]);
527 asprintf (&fmt, _("%s%sSTATE = %s"), (fmt ? fmt : ""), (options ? ", " : ""), statopts); 527 xasprintf (&fmt, _("%s%sSTATE = %s"), (fmt ? fmt : ""), (options ? ", " : ""), statopts);
528 options |= STAT; 528 options |= STAT;
529 } 529 }
530 530