summaryrefslogtreecommitdiffstats
path: root/plugins/check_snmp.c
diff options
context:
space:
mode:
authorabrist <abrist@nagios.com>2015-05-19 21:32:54 (GMT)
committerSven Nierlein <sven@nierlein.de>2016-11-07 21:13:07 (GMT)
commit7276ce77c7f1dc682b6ac0b58d78445c6bb814bf (patch)
tree27d3b08fd2d2b7e70cd63d2bea9c3b0ee07c69a8 /plugins/check_snmp.c
parentaa7ed88c549141a403d3d8de2bd9760c1f411cb0 (diff)
downloadmonitoring-plugins-7276ce77c7f1dc682b6ac0b58d78445c6bb814bf.tar.gz
check_snmp.c - Added IPv6 support
The "-6" optarg now prepends the server_address with "udp6:" for the snmpget external command as per the net-snmp syntax at: http://www.net-snmp.org/wiki/index.php/FAQ:Applications_28 Thanks to DrydenK (Roberto Greiner) for the heads up.
Diffstat (limited to 'plugins/check_snmp.c')
-rw-r--r--plugins/check_snmp.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c
index 9839d6e..da9638c 100644
--- a/plugins/check_snmp.c
+++ b/plugins/check_snmp.c
@@ -152,7 +152,7 @@ state_data *previous_state;
152double *previous_value; 152double *previous_value;
153size_t previous_size = OID_COUNT_STEP; 153size_t previous_size = OID_COUNT_STEP;
154int perf_labels = 1; 154int perf_labels = 1;
155 155char* ip_version = "";
156 156
157static char *fix_snmp_range(char *th) 157static char *fix_snmp_range(char *th)
158{ 158{
@@ -680,6 +680,8 @@ process_arguments (int argc, char **argv)
680 {"offset", required_argument, 0, L_OFFSET}, 680 {"offset", required_argument, 0, L_OFFSET},
681 {"invert-search", no_argument, 0, L_INVERT_SEARCH}, 681 {"invert-search", no_argument, 0, L_INVERT_SEARCH},
682 {"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'},
683 {0, 0, 0, 0} 685 {0, 0, 0, 0}
684 }; 686 };
685 687
@@ -697,7 +699,7 @@ process_arguments (int argc, char **argv)
697 } 699 }
698 700
699 while (1) { 701 while (1) {
700 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:",
701 longopts, &option); 703 longopts, &option);
702 704
703 if (c == -1 || c == EOF) 705 if (c == -1 || c == EOF)
@@ -922,6 +924,13 @@ process_arguments (int argc, char **argv)
922 case 'O': 924 case 'O':
923 perf_labels=0; 925 perf_labels=0;
924 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;
925 } 934 }
926 } 935 }
927 936
@@ -1127,6 +1136,7 @@ print_help (void)
1127 1136
1128 printf (UT_HELP_VRSN); 1137 printf (UT_HELP_VRSN);
1129 printf (UT_EXTRA_OPTS); 1138 printf (UT_EXTRA_OPTS);
1139 printf (UT_IPv46);
1130 1140
1131 printf (UT_HOST_PORT, 'p', DEFAULT_PORT); 1141 printf (UT_HOST_PORT, 'p', DEFAULT_PORT);
1132 1142
@@ -1245,5 +1255,5 @@ print_usage (void)
1245 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");
1246 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");
1247 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");
1248 printf ("[-a authproto] [-A authpasswd] [-x privproto] [-X privpasswd]\n"); 1258 printf ("[-a authproto] [-A authpasswd] [-x privproto] [-X privpasswd] [-4|6]\n");
1249} 1259}