summaryrefslogtreecommitdiffstats
path: root/plugins/check_snmp.c
diff options
context:
space:
mode:
authorTon Voon <tonvoon@macbook.local>2008-12-23 11:52:04 +0000
committerTon Voon <tonvoon@macbook.local>2008-12-23 11:52:04 +0000
commit639f7b2c822135412dca4a0a3ac8834ac7431251 (patch)
tree52091952edb7fe8c2a524fc10fd2383dec88e4ee /plugins/check_snmp.c
parentf8b606b728f7ffd3333f93a21ee4bacaea00e7b3 (diff)
downloadmonitoring-plugins-639f7b2c822135412dca4a0a3ac8834ac7431251.tar.gz
Allow privproto to be passed through check_snmp to snmpget. Defaults to DES
for compatibility
Diffstat (limited to 'plugins/check_snmp.c')
-rw-r--r--plugins/check_snmp.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c
index 1c92534c..a19da909 100644
--- a/plugins/check_snmp.c
+++ b/plugins/check_snmp.c
@@ -43,6 +43,7 @@ const char *email = "nagiosplug-devel@lists.sourceforge.net";
43#define DEFAULT_TIMEOUT 1 43#define DEFAULT_TIMEOUT 1
44#define DEFAULT_RETRIES 5 44#define DEFAULT_RETRIES 5
45#define DEFAULT_AUTH_PROTOCOL "MD5" 45#define DEFAULT_AUTH_PROTOCOL "MD5"
46#define DEFAULT_PRIV_PROTOCOL "DES"
46#define DEFAULT_DELIMITER "=" 47#define DEFAULT_DELIMITER "="
47#define DEFAULT_OUTPUT_DELIMITER " " 48#define DEFAULT_OUTPUT_DELIMITER " "
48 49
@@ -102,6 +103,7 @@ char *proto = NULL;
102char *seclevel = NULL; 103char *seclevel = NULL;
103char *secname = NULL; 104char *secname = NULL;
104char *authproto = NULL; 105char *authproto = NULL;
106char *privproto = NULL;
105char *authpasswd = NULL; 107char *authpasswd = NULL;
106char *privpasswd = NULL; 108char *privpasswd = NULL;
107char *oid; 109char *oid;
@@ -438,6 +440,7 @@ process_arguments (int argc, char **argv)
438 {"seclevel", required_argument, 0, 'L'}, 440 {"seclevel", required_argument, 0, 'L'},
439 {"secname", required_argument, 0, 'U'}, 441 {"secname", required_argument, 0, 'U'},
440 {"authproto", required_argument, 0, 'a'}, 442 {"authproto", required_argument, 0, 'a'},
443 {"privproto", required_argument, 0, 'x'},
441 {"authpasswd", required_argument, 0, 'A'}, 444 {"authpasswd", required_argument, 0, 'A'},
442 {"privpasswd", required_argument, 0, 'X'}, 445 {"privpasswd", required_argument, 0, 'X'},
443 {"next", no_argument, 0, 'n'}, 446 {"next", no_argument, 0, 'n'},
@@ -458,7 +461,7 @@ process_arguments (int argc, char **argv)
458 } 461 }
459 462
460 while (1) { 463 while (1) {
461 c = getopt_long (argc, argv, "nhvVt:c:w:H:C:o:e:E:d:D:s:t:R:r:l:u:p:m:P:L:U:a:A:X:", 464 c = getopt_long (argc, argv, "nhvVt:c:w:H:C:o:e:E:d:D:s:t:R:r:l:u:p:m:P:L:U:a:x:A:X:",
462 longopts, &option); 465 longopts, &option);
463 466
464 if (c == -1 || c == EOF) 467 if (c == -1 || c == EOF)
@@ -505,6 +508,9 @@ process_arguments (int argc, char **argv)
505 case 'a': /* auth protocol */ 508 case 'a': /* auth protocol */
506 authproto = optarg; 509 authproto = optarg;
507 break; 510 break;
511 case 'x': /* priv protocol */
512 privproto = optarg;
513 break;
508 case 'A': /* auth passwd */ 514 case 'A': /* auth passwd */
509 authpasswd = optarg; 515 authpasswd = optarg;
510 break; 516 break;
@@ -717,7 +723,8 @@ validate_arguments ()
717 if (authproto == NULL ) 723 if (authproto == NULL )
718 asprintf(&authproto, DEFAULT_AUTH_PROTOCOL); 724 asprintf(&authproto, DEFAULT_AUTH_PROTOCOL);
719 725
720 726 if (privproto == NULL )
727 asprintf(&privproto, DEFAULT_PRIV_PROTOCOL);
721 728
722 if (proto == NULL || (strcmp(proto,DEFAULT_PROTOCOL) == 0) ) { /* default protocol version */ 729 if (proto == NULL || (strcmp(proto,DEFAULT_PROTOCOL) == 0) ) { /* default protocol version */
723 asprintf(&proto, DEFAULT_PROTOCOL); 730 asprintf(&proto, DEFAULT_PROTOCOL);
@@ -746,7 +753,7 @@ validate_arguments ()
746 print_usage (); 753 print_usage ();
747 exit (STATE_UNKNOWN); 754 exit (STATE_UNKNOWN);
748 } 755 }
749 asprintf(&authpriv, "-l authPriv -a %s -u %s -A %s -x DES -X %s ", authproto, secname, authpasswd, privpasswd); 756 asprintf(&authpriv, "-l authPriv -a %s -u %s -A %s -x %s -X %s ", authproto, secname, authpasswd, privproto, privpasswd);
750 } 757 }
751 758
752 } 759 }
@@ -948,6 +955,8 @@ print_help (void)
948 printf (" %s\n", _("SNMPv3 securityLevel")); 955 printf (" %s\n", _("SNMPv3 securityLevel"));
949 printf (" %s\n", "-a, --authproto=[MD5|SHA]"); 956 printf (" %s\n", "-a, --authproto=[MD5|SHA]");
950 printf (" %s\n", _("SNMPv3 auth proto")); 957 printf (" %s\n", _("SNMPv3 auth proto"));
958 printf (" %s\n", "-x, --privproto=[DES|AES]");
959 printf (" %s\n", _("SNMPv3 priv proto (default DES)"));
951 960
952 /* Authentication Tokens*/ 961 /* Authentication Tokens*/
953 printf (" %s\n", "-C, --community=STRING"); 962 printf (" %s\n", "-C, --community=STRING");
@@ -1038,5 +1047,5 @@ print_usage (void)
1038 printf ("[-C community] [-s string] [-r regex] [-R regexi] [-t timeout] [-e retries]\n"); 1047 printf ("[-C community] [-s string] [-r regex] [-R regexi] [-t timeout] [-e retries]\n");
1039 printf ("[-l label] [-u units] [-p port-number] [-d delimiter] [-D output-delimiter]\n"); 1048 printf ("[-l label] [-u units] [-p port-number] [-d delimiter] [-D output-delimiter]\n");
1040 printf ("[-m miblist] [-P snmp version] [-L seclevel] [-U secname] [-a authproto]\n"); 1049 printf ("[-m miblist] [-P snmp version] [-L seclevel] [-U secname] [-a authproto]\n");
1041 printf ("[-A authpasswd] [-X privpasswd]\n"); 1050 printf ("[-A authpasswd] [-x privproto] [-X privpasswd]\n");
1042} 1051}