[Nagiosplug-checkins] SF.net SVN: nagiosplug:[2112] nagiosplug/trunk/plugins/check_snmp.c

dermoth at users.sourceforge.net dermoth at users.sourceforge.net
Tue Dec 23 12:53:16 CET 2008


Revision: 2112
          http://nagiosplug.svn.sourceforge.net/nagiosplug/?rev=2112&view=rev
Author:   dermoth
Date:     2008-12-23 11:53:16 +0000 (Tue, 23 Dec 2008)

Log Message:
-----------
Allow privproto to be passed through check_snmp to snmpget. Defaults to DES
for compatibility

Modified Paths:
--------------
    nagiosplug/trunk/plugins/check_snmp.c

Modified: nagiosplug/trunk/plugins/check_snmp.c
===================================================================
--- nagiosplug/trunk/plugins/check_snmp.c	2008-12-13 14:08:33 UTC (rev 2111)
+++ nagiosplug/trunk/plugins/check_snmp.c	2008-12-23 11:53:16 UTC (rev 2112)
@@ -43,6 +43,7 @@
 #define DEFAULT_TIMEOUT 1
 #define DEFAULT_RETRIES 5
 #define DEFAULT_AUTH_PROTOCOL "MD5"
+#define DEFAULT_PRIV_PROTOCOL "DES"
 #define DEFAULT_DELIMITER "="
 #define DEFAULT_OUTPUT_DELIMITER " "
 
@@ -102,6 +103,7 @@
 char *seclevel = NULL;
 char *secname = NULL;
 char *authproto = NULL;
+char *privproto = NULL;
 char *authpasswd = NULL;
 char *privpasswd = NULL;
 char *oid;
@@ -438,6 +440,7 @@
 		{"seclevel", required_argument, 0, 'L'},
 		{"secname", required_argument, 0, 'U'},
 		{"authproto", required_argument, 0, 'a'},
+		{"privproto", required_argument, 0, 'x'},
 		{"authpasswd", required_argument, 0, 'A'},
 		{"privpasswd", required_argument, 0, 'X'},
 		{"next", no_argument, 0, 'n'},
@@ -458,7 +461,7 @@
 	}
 
 	while (1) {
-		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:",
+		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:",
 									 longopts, &option);
 
 		if (c == -1 || c == EOF)
@@ -505,6 +508,9 @@
 		case 'a':	/* auth protocol */
 			authproto = optarg;
 			break;
+		case 'x':	/* priv protocol */
+			privproto = optarg;
+			break;
 		case 'A':	/* auth passwd */
 			authpasswd = optarg;
 			break;
@@ -717,8 +723,9 @@
 	if (authproto == NULL )
 		asprintf(&authproto, DEFAULT_AUTH_PROTOCOL);
 
+	if (privproto == NULL )
+		asprintf(&privproto, DEFAULT_PRIV_PROTOCOL);
 
-
 	if (proto == NULL || (strcmp(proto,DEFAULT_PROTOCOL) == 0) ) {	/* default protocol version */
 		asprintf(&proto, DEFAULT_PROTOCOL);
 		asprintf(&authpriv, "%s%s", "-c ", community);
@@ -746,7 +753,7 @@
 				print_usage ();
 				exit (STATE_UNKNOWN);
 			}
-			asprintf(&authpriv, "-l authPriv -a %s -u %s -A %s -x DES -X %s ", authproto, secname, authpasswd, privpasswd);
+			asprintf(&authpriv, "-l authPriv -a %s -u %s -A %s -x %s -X %s ", authproto, secname, authpasswd, privproto, privpasswd);
 		}
 
 	}
@@ -948,6 +955,8 @@
   printf ("    %s\n", _("SNMPv3 securityLevel"));
   printf (" %s\n", "-a, --authproto=[MD5|SHA]");
   printf ("    %s\n", _("SNMPv3 auth proto"));
+  printf (" %s\n", "-x, --privproto=[DES|AES]");
+  printf ("    %s\n", _("SNMPv3 priv proto (default DES)"));
 
 	/* Authentication Tokens*/
 	printf (" %s\n", "-C, --community=STRING");
@@ -1038,5 +1047,5 @@
   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] [-L seclevel] [-U secname] [-a authproto]\n");
-  printf ("[-A authpasswd] [-X privpasswd]\n");
+  printf ("[-A authpasswd] [-x privproto] [-X privpasswd]\n");
 }


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Commits mailing list