diff options
Diffstat (limited to 'plugins/check_snmp.c')
-rw-r--r-- | plugins/check_snmp.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c index 9d966faa..da9638c4 100644 --- a/plugins/check_snmp.c +++ b/plugins/check_snmp.c | |||
@@ -41,7 +41,6 @@ const char *email = "devel@monitoring-plugins.org"; | |||
41 | #define DEFAULT_PORT "161" | 41 | #define DEFAULT_PORT "161" |
42 | #define DEFAULT_MIBLIST "ALL" | 42 | #define DEFAULT_MIBLIST "ALL" |
43 | #define DEFAULT_PROTOCOL "1" | 43 | #define DEFAULT_PROTOCOL "1" |
44 | #define DEFAULT_TIMEOUT 1 | ||
45 | #define DEFAULT_RETRIES 5 | 44 | #define DEFAULT_RETRIES 5 |
46 | #define DEFAULT_AUTH_PROTOCOL "MD5" | 45 | #define DEFAULT_AUTH_PROTOCOL "MD5" |
47 | #define DEFAULT_PRIV_PROTOCOL "DES" | 46 | #define DEFAULT_PRIV_PROTOCOL "DES" |
@@ -153,7 +152,7 @@ state_data *previous_state; | |||
153 | double *previous_value; | 152 | double *previous_value; |
154 | size_t previous_size = OID_COUNT_STEP; | 153 | size_t previous_size = OID_COUNT_STEP; |
155 | int perf_labels = 1; | 154 | int perf_labels = 1; |
156 | 155 | char* ip_version = ""; | |
157 | 156 | ||
158 | static char *fix_snmp_range(char *th) | 157 | static char *fix_snmp_range(char *th) |
159 | { | 158 | { |
@@ -227,7 +226,7 @@ main (int argc, char **argv) | |||
227 | outbuff = strdup (""); | 226 | outbuff = strdup (""); |
228 | delimiter = strdup (" = "); | 227 | delimiter = strdup (" = "); |
229 | output_delim = strdup (DEFAULT_OUTPUT_DELIMITER); | 228 | output_delim = strdup (DEFAULT_OUTPUT_DELIMITER); |
230 | timeout_interval = DEFAULT_TIMEOUT; | 229 | timeout_interval = DEFAULT_SOCKET_TIMEOUT; |
231 | retries = DEFAULT_RETRIES; | 230 | retries = DEFAULT_RETRIES; |
232 | 231 | ||
233 | np_init( (char *) progname, argc, argv ); | 232 | np_init( (char *) progname, argc, argv ); |
@@ -418,6 +417,9 @@ main (int argc, char **argv) | |||
418 | else if (strstr (response, "INTEGER: ")) { | 417 | else if (strstr (response, "INTEGER: ")) { |
419 | show = strstr (response, "INTEGER: ") + 9; | 418 | show = strstr (response, "INTEGER: ") + 9; |
420 | } | 419 | } |
420 | else if (strstr (response, "OID: ")) { | ||
421 | show = strstr (response, "OID: ") + 5; | ||
422 | } | ||
421 | else if (strstr (response, "STRING: ")) { | 423 | else if (strstr (response, "STRING: ")) { |
422 | show = strstr (response, "STRING: ") + 8; | 424 | show = strstr (response, "STRING: ") + 8; |
423 | conv = "%.10g"; | 425 | conv = "%.10g"; |
@@ -678,6 +680,8 @@ process_arguments (int argc, char **argv) | |||
678 | {"offset", required_argument, 0, L_OFFSET}, | 680 | {"offset", required_argument, 0, L_OFFSET}, |
679 | {"invert-search", no_argument, 0, L_INVERT_SEARCH}, | 681 | {"invert-search", no_argument, 0, L_INVERT_SEARCH}, |
680 | {"perf-oids", no_argument, 0, 'O'}, | 682 | {"perf-oids", no_argument, 0, 'O'}, |
683 | {"ipv4", no_argument, 0, '4'}, | ||
684 | {"ipv6", no_argument, 0, '6'}, | ||
681 | {0, 0, 0, 0} | 685 | {0, 0, 0, 0} |
682 | }; | 686 | }; |
683 | 687 | ||
@@ -695,7 +699,7 @@ process_arguments (int argc, char **argv) | |||
695 | } | 699 | } |
696 | 700 | ||
697 | while (1) { | 701 | while (1) { |
698 | c = getopt_long (argc, argv, "nhvVOt:c:w:H:C:o:e:E:d:D:s:t:R:r:l:u:p:m:P:N:L:U:a:x:A:X:", | 702 | c = getopt_long (argc, argv, "nhvVO46t:c:w:H:C:o:e:E:d:D:s:t:R:r:l:u:p:m:P:N:L:U:a:x:A:X:", |
699 | longopts, &option); | 703 | longopts, &option); |
700 | 704 | ||
701 | if (c == -1 || c == EOF) | 705 | if (c == -1 || c == EOF) |
@@ -706,10 +710,10 @@ process_arguments (int argc, char **argv) | |||
706 | usage5 (); | 710 | usage5 (); |
707 | case 'h': /* help */ | 711 | case 'h': /* help */ |
708 | print_help (); | 712 | print_help (); |
709 | exit (STATE_OK); | 713 | exit (STATE_UNKNOWN); |
710 | case 'V': /* version */ | 714 | case 'V': /* version */ |
711 | print_revision (progname, NP_VERSION); | 715 | print_revision (progname, NP_VERSION); |
712 | exit (STATE_OK); | 716 | exit (STATE_UNKNOWN); |
713 | case 'v': /* verbose */ | 717 | case 'v': /* verbose */ |
714 | verbose++; | 718 | verbose++; |
715 | break; | 719 | break; |
@@ -920,6 +924,13 @@ process_arguments (int argc, char **argv) | |||
920 | case 'O': | 924 | case 'O': |
921 | perf_labels=0; | 925 | perf_labels=0; |
922 | break; | 926 | break; |
927 | case '4': | ||
928 | break; | ||
929 | case '6': | ||
930 | xasprintf(&ip_version, "udp6:"); | ||
931 | if(verbose>2) | ||
932 | printf("IPv6 detected! Will pass \"udp6:\" to snmpget.\n"); | ||
933 | break; | ||
923 | } | 934 | } |
924 | } | 935 | } |
925 | 936 | ||
@@ -1125,6 +1136,7 @@ print_help (void) | |||
1125 | 1136 | ||
1126 | printf (UT_HELP_VRSN); | 1137 | printf (UT_HELP_VRSN); |
1127 | printf (UT_EXTRA_OPTS); | 1138 | printf (UT_EXTRA_OPTS); |
1139 | printf (UT_IPv46); | ||
1128 | 1140 | ||
1129 | printf (UT_HOST_PORT, 'p', DEFAULT_PORT); | 1141 | printf (UT_HOST_PORT, 'p', DEFAULT_PORT); |
1130 | 1142 | ||
@@ -1243,5 +1255,5 @@ print_usage (void) | |||
1243 | printf ("[-C community] [-s string] [-r regex] [-R regexi] [-t timeout] [-e retries]\n"); | 1255 | printf ("[-C community] [-s string] [-r regex] [-R regexi] [-t timeout] [-e retries]\n"); |
1244 | printf ("[-l label] [-u units] [-p port-number] [-d delimiter] [-D output-delimiter]\n"); | 1256 | printf ("[-l label] [-u units] [-p port-number] [-d delimiter] [-D output-delimiter]\n"); |
1245 | printf ("[-m miblist] [-P snmp version] [-N context] [-L seclevel] [-U secname]\n"); | 1257 | printf ("[-m miblist] [-P snmp version] [-N context] [-L seclevel] [-U secname]\n"); |
1246 | printf ("[-a authproto] [-A authpasswd] [-x privproto] [-X privpasswd]\n"); | 1258 | printf ("[-a authproto] [-A authpasswd] [-x privproto] [-X privpasswd] [-4|6]\n"); |
1247 | } | 1259 | } |