summaryrefslogtreecommitdiffstats
path: root/plugins/check_snmp.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/check_snmp.c')
-rw-r--r--plugins/check_snmp.c48
1 files changed, 22 insertions, 26 deletions
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c
index 821f10e..68ffaf5 100644
--- a/plugins/check_snmp.c
+++ b/plugins/check_snmp.c
@@ -43,18 +43,14 @@ const char *email = "nagiosplug-devel@lists.sourceforge.net";
43void 43void
44print_usage (void) 44print_usage (void)
45{ 45{
46 printf ("\ 46 printf (_("\
47Usage: %s -H <ip_address> -o <OID> [-w warn_range] [-c crit_range] \n\ 47Usage: %s -H <ip_address> -o <OID> [-w warn_range] [-c crit_range] \n\
48 [-C community] [-s string] [-r regex] [-R regexi] [-t timeout]\n\ 48 [-C community] [-s string] [-r regex] [-R regexi] [-t timeout]\n\
49 [-l label] [-u units] [-p port-number] [-d delimiter]\n\ 49 [-l label] [-u units] [-p port-number] [-d delimiter]\n\
50 [-D output-delimiter] [-m miblist] [-P snmp version]\n\ 50 [-D output-delimiter] [-m miblist] [-P snmp version]\n\
51 [-L seclevel] [-U secname] [-a authproto] [-A authpasswd]\n\ 51 [-L seclevel] [-U secname] [-a authproto] [-A authpasswd]\n\
52 [-X privpasswd]\n", 52 [-X privpasswd]\n"), progname);
53 progname); 53 printf (_(UT_HLP_VRS), progname, progname);
54 printf ("\
55 %s (-h | --help) for detailed help\n\
56 %s (-V | --version) for version information\n",
57 progname, progname);
58} 54}
59 55
60void 56void
@@ -160,7 +156,7 @@ Check status of remote machines and obtain sustem information via SNMP\n\n"));
160- All evaluation methods other than PR, STR, and SUBSTR expect that the value\n\ 156- All evaluation methods other than PR, STR, and SUBSTR expect that the value\n\
161 returned from the SNMP query is an unsigned integer.\n")); 157 returned from the SNMP query is an unsigned integer.\n"));
162 158
163 support (); 159 printf (_(UT_SUPPORT));
164} 160}
165 161
166 162
@@ -271,7 +267,7 @@ main (int argc, char **argv)
271 i = 0; 267 i = 0;
272 268
273 if (process_arguments (argc, argv) == ERROR) 269 if (process_arguments (argc, argv) == ERROR)
274 usage ("Incorrect arguments supplied\n"); 270 usage (_("Incorrect arguments supplied\n"));
275 271
276 /* create the command line to execute */ 272 /* create the command line to execute */
277 asprintf (&command_line, "%s -t 1 -r %d -m %s -v %s %s %s:%s %s", 273 asprintf (&command_line, "%s -t 1 -r %d -m %s -v %s %s %s:%s %s",
@@ -283,13 +279,13 @@ main (int argc, char **argv)
283 /* run the command */ 279 /* run the command */
284 child_process = spopen (command_line); 280 child_process = spopen (command_line);
285 if (child_process == NULL) { 281 if (child_process == NULL) {
286 printf ("Could not open pipe: %s\n", command_line); 282 printf (_("Could not open pipe: %s\n"), command_line);
287 exit (STATE_UNKNOWN); 283 exit (STATE_UNKNOWN);
288 } 284 }
289 285
290 child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r"); 286 child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r");
291 if (child_stderr == NULL) { 287 if (child_stderr == NULL) {
292 printf ("Could not open stderr for %s\n", command_line); 288 printf (_("Could not open stderr for %s\n"), command_line);
293 } 289 }
294 290
295 while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) 291 while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process))
@@ -388,14 +384,14 @@ main (int argc, char **argv)
388 } 384 }
389 else if (excode != REG_NOMATCH) { 385 else if (excode != REG_NOMATCH) {
390 regerror (excode, &preg, errbuf, MAX_INPUT_BUFFER); 386 regerror (excode, &preg, errbuf, MAX_INPUT_BUFFER);
391 printf ("Execute Error: %s\n", errbuf); 387 printf (_("Execute Error: %s\n"), errbuf);
392 exit (STATE_CRITICAL); 388 exit (STATE_CRITICAL);
393 } 389 }
394 else { 390 else {
395 iresult = STATE_CRITICAL; 391 iresult = STATE_CRITICAL;
396 } 392 }
397#else 393#else
398 printf ("%s UNKNOWN: call for regex which was not a compiled option", label); 394 printf (_("%s UNKNOWN: call for regex which was not a compiled option"), label);
399 exit (STATE_UNKNOWN); 395 exit (STATE_UNKNOWN);
400#endif 396#endif
401 } 397 }
@@ -433,7 +429,7 @@ main (int argc, char **argv)
433 if (found == 0) 429 if (found == 0)
434 terminate 430 terminate
435 (STATE_UNKNOWN, 431 (STATE_UNKNOWN,
436 "%s problem - No data recieved from host\nCMD: %s\n", 432 _("%s problem - No data recieved from host\nCMD: %s\n"),
437 label, command_line); 433 label, command_line);
438 434
439 /* WARNING if output found on stderr */ 435 /* WARNING if output found on stderr */
@@ -554,14 +550,14 @@ process_arguments (int argc, char **argv)
554 break; 550 break;
555 case 't': /* timeout period */ 551 case 't': /* timeout period */
556 if (!is_integer (optarg)) 552 if (!is_integer (optarg))
557 usage2 ("Timeout Interval must be an integer", optarg); 553 usage2 (_("Timeout Interval must be an integer"), optarg);
558 timeout_interval = atoi (optarg); 554 timeout_interval = atoi (optarg);
559 break; 555 break;
560 556
561 /* Test parameters */ 557 /* Test parameters */
562 case 'c': /* critical time threshold */ 558 case 'c': /* critical time threshold */
563 if (strspn (optarg, "0123456789:,") < strlen (optarg)) { 559 if (strspn (optarg, "0123456789:,") < strlen (optarg)) {
564 printf ("Invalid critical threshold: %s\n", optarg); 560 printf (_("Invalid critical threshold: %s\n"), optarg);
565 print_usage (); 561 print_usage ();
566 exit (STATE_UNKNOWN); 562 exit (STATE_UNKNOWN);
567 } 563 }
@@ -575,7 +571,7 @@ process_arguments (int argc, char **argv)
575 break; 571 break;
576 case 'w': /* warning time threshold */ 572 case 'w': /* warning time threshold */
577 if (strspn (optarg, "0123456789:,") < strlen (optarg)) { 573 if (strspn (optarg, "0123456789:,") < strlen (optarg)) {
578 printf ("Invalid warning threshold: %s\n", optarg); 574 printf (_("Invalid warning threshold: %s\n"), optarg);
579 print_usage (); 575 print_usage ();
580 exit (STATE_UNKNOWN); 576 exit (STATE_UNKNOWN);
581 } 577 }
@@ -622,13 +618,13 @@ process_arguments (int argc, char **argv)
622 errcode = regcomp (&preg, regex_expect, cflags); 618 errcode = regcomp (&preg, regex_expect, cflags);
623 if (errcode != 0) { 619 if (errcode != 0) {
624 regerror (errcode, &preg, errbuf, MAX_INPUT_BUFFER); 620 regerror (errcode, &preg, errbuf, MAX_INPUT_BUFFER);
625 printf ("Could Not Compile Regular Expression"); 621 printf (_("Could Not Compile Regular Expression"));
626 return ERROR; 622 return ERROR;
627 } 623 }
628 eval_method[jj++] = CRIT_REGEX; 624 eval_method[jj++] = CRIT_REGEX;
629 ii++; 625 ii++;
630#else 626#else
631 printf ("%s UNKNOWN: call for regex which was not a compiled option", label); 627 printf (_("%s UNKNOWN: call for regex which was not a compiled option"), label);
632 exit (STATE_UNKNOWN); 628 exit (STATE_UNKNOWN);
633#endif 629#endif
634 break; 630 break;
@@ -648,7 +644,7 @@ process_arguments (int argc, char **argv)
648 labels = realloc (labels, labels_size); 644 labels = realloc (labels, labels_size);
649 if (labels == NULL) 645 if (labels == NULL)
650 terminate (STATE_UNKNOWN, 646 terminate (STATE_UNKNOWN,
651 "Could not realloc() labels[%d]", nlabels); 647 _("Could not realloc() labels[%d]"), nlabels);
652 } 648 }
653 labels[nlabels - 1] = optarg; 649 labels[nlabels - 1] = optarg;
654 ptr = thisarg (optarg); 650 ptr = thisarg (optarg);
@@ -661,7 +657,7 @@ process_arguments (int argc, char **argv)
661 labels_size += 8; 657 labels_size += 8;
662 labels = realloc (labels, labels_size); 658 labels = realloc (labels, labels_size);
663 if (labels == NULL) 659 if (labels == NULL)
664 terminate (STATE_UNKNOWN, "Could not realloc() labels\n"); 660 terminate (STATE_UNKNOWN, _("Could not realloc() labels\n"));
665 } 661 }
666 labels++; 662 labels++;
667 ptr = thisarg (ptr); 663 ptr = thisarg (ptr);
@@ -679,7 +675,7 @@ process_arguments (int argc, char **argv)
679 unitv = realloc (unitv, unitv_size); 675 unitv = realloc (unitv, unitv_size);
680 if (unitv == NULL) 676 if (unitv == NULL)
681 terminate (STATE_UNKNOWN, 677 terminate (STATE_UNKNOWN,
682 "Could not realloc() units [%d]\n", nunits); 678 _("Could not realloc() units [%d]\n"), nunits);
683 } 679 }
684 unitv[nunits - 1] = optarg; 680 unitv[nunits - 1] = optarg;
685 ptr = thisarg (optarg); 681 ptr = thisarg (optarg);
@@ -692,7 +688,7 @@ process_arguments (int argc, char **argv)
692 unitv_size += 8; 688 unitv_size += 8;
693 unitv = realloc (unitv, unitv_size); 689 unitv = realloc (unitv, unitv_size);
694 if (units == NULL) 690 if (units == NULL)
695 terminate (STATE_UNKNOWN, "Could not realloc() units\n"); 691 terminate (STATE_UNKNOWN, _("Could not realloc() units\n"));
696 } 692 }
697 nunits++; 693 nunits++;
698 ptr = thisarg (ptr); 694 ptr = thisarg (ptr);
@@ -759,7 +755,7 @@ validate_arguments ()
759 } 755 }
760 else if ( strcmp(seclevel, "authNoPriv") == 0 ) { 756 else if ( strcmp(seclevel, "authNoPriv") == 0 ) {
761 if ( secname == NULL || authpasswd == NULL) { 757 if ( secname == NULL || authpasswd == NULL) {
762 printf ("Missing secname (%s) or authpassword (%s) ! \n",secname, authpasswd ); 758 printf (_("Missing secname (%s) or authpassword (%s) ! \n)"),secname, authpasswd );
763 print_usage (); 759 print_usage ();
764 exit (STATE_UNKNOWN); 760 exit (STATE_UNKNOWN);
765 } 761 }
@@ -767,7 +763,7 @@ validate_arguments ()
767 } 763 }
768 else if ( strcmp(seclevel, "authPriv") == 0 ) { 764 else if ( strcmp(seclevel, "authPriv") == 0 ) {
769 if ( secname == NULL || authpasswd == NULL || privpasswd == NULL ) { 765 if ( secname == NULL || authpasswd == NULL || privpasswd == NULL ) {
770 printf ("Missing secname (%s), authpassword (%s), or privpasswd (%s)! \n",secname, authpasswd,privpasswd ); 766 printf (("Missing secname (%s), authpassword (%s), or privpasswd (%s)! \n"),secname, authpasswd,privpasswd );
771 print_usage (); 767 print_usage ();
772 exit (STATE_UNKNOWN); 768 exit (STATE_UNKNOWN);
773 } 769 }
@@ -777,7 +773,7 @@ validate_arguments ()
777 773
778 } 774 }
779 else { 775 else {
780 printf ("Invalid SNMP version: %s\n", proto); 776 printf (_("Invalid SNMP version: %s\n"), proto);
781 print_usage (); 777 print_usage ();
782 exit (STATE_UNKNOWN); 778 exit (STATE_UNKNOWN);
783 } 779 }