Module: monitoring-plugins
    Branch: master
    Commit: 7276ce77c7f1dc682b6ac0b58d78445c6bb814bf
    Author: abrist <abr...@nagios.com>
 Committer: Sven Nierlein <s...@nierlein.de>
      Date: Tue May 19 17:32:54 2015 -0400
       URL: 
https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=7276ce7

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.

---

 NEWS                 |  1 +
 THANKS.in            |  1 +
 plugins/check_snmp.c | 16 +++++++++++++---
 3 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/NEWS b/NEWS
index dd229a9..6742879 100644
--- a/NEWS
+++ b/NEWS
@@ -13,6 +13,7 @@ This file documents the major additions and syntax changes 
between releases.
        The check_http -S/--ssl option now allows for specifying the desired
          protocol with a "+" suffix to also accept newer versions
        check_users: add support for range thresholds (John C. Frickson)
+       check_snmp: add ipv6 support (abrist)
 
        FIXES
        Let check_real terminate lines with CRLF when talking to the server, as
diff --git a/THANKS.in b/THANKS.in
index 59c90fe..717dad0 100644
--- a/THANKS.in
+++ b/THANKS.in
@@ -336,3 +336,4 @@ Nick Peelman
 Sebastian Herbszt
 Christopher Schultz
 Matthias Hähnel
+Roberto Greiner
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;
 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");
 }

Reply via email to