diff options
author | abrist <abrist@nagios.com> | 2015-05-19 17:32:54 -0400 |
---|---|---|
committer | Sven Nierlein <sven@nierlein.de> | 2016-11-07 22:13:07 +0100 |
commit | 7276ce77c7f1dc682b6ac0b58d78445c6bb814bf (patch) | |
tree | 27d3b08fd2d2b7e70cd63d2bea9c3b0ee07c69a8 /plugins/check_snmp.c | |
parent | aa7ed88c549141a403d3d8de2bd9760c1f411cb0 (diff) | |
download | monitoring-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.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c index 9839d6e8..da9638c4 100644 --- a/plugins/check_snmp.c +++ b/plugins/check_snmp.c @@ -152,7 +152,7 @@ state_data *previous_state; double *previous_value; size_t previous_size = OID_COUNT_STEP; int perf_labels = 1; - +char* ip_version = ""; static char *fix_snmp_range(char *th) { @@ -680,6 +680,8 @@ process_arguments (int argc, char **argv) {"offset", required_argument, 0, L_OFFSET}, {"invert-search", no_argument, 0, L_INVERT_SEARCH}, {"perf-oids", no_argument, 0, 'O'}, + {"ipv4", no_argument, 0, '4'}, + {"ipv6", no_argument, 0, '6'}, {0, 0, 0, 0} }; @@ -697,7 +699,7 @@ process_arguments (int argc, char **argv) } while (1) { - 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:", + 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:", longopts, &option); if (c == -1 || c == EOF) @@ -922,6 +924,13 @@ process_arguments (int argc, char **argv) case 'O': perf_labels=0; break; + case '4': + break; + case '6': + xasprintf(&ip_version, "udp6:"); + if(verbose>2) + printf("IPv6 detected! Will pass \"udp6:\" to snmpget.\n"); + break; } } @@ -1127,6 +1136,7 @@ print_help (void) printf (UT_HELP_VRSN); printf (UT_EXTRA_OPTS); + printf (UT_IPv46); printf (UT_HOST_PORT, 'p', DEFAULT_PORT); @@ -1245,5 +1255,5 @@ print_usage (void) printf ("[-C community] [-s string] [-r regex] [-R regexi] [-t timeout] [-e retries]\n"); printf ("[-l label] [-u units] [-p port-number] [-d delimiter] [-D output-delimiter]\n"); printf ("[-m miblist] [-P snmp version] [-N context] [-L seclevel] [-U secname]\n"); - printf ("[-a authproto] [-A authpasswd] [-x privproto] [-X privpasswd]\n"); + printf ("[-a authproto] [-A authpasswd] [-x privproto] [-X privpasswd] [-4|6]\n"); } |