summaryrefslogtreecommitdiffstats
path: root/web/attachments/26654-snmpv3.dif
blob: d4d9ecbdd0b7d027420965d7837934f2db71a9f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
--- plugins/check_snmp.c.orig	Thu Feb 28 07:42:59 2002
+++ plugins/check_snmp.c	Tue Jul  9 11:48:10 2002
@@ -97,6 +97,12 @@
 char oid[MAX_INPUT_BUFFER] = "";
 char *label = NULL;
 char *units = NULL;
+char *secname = NULL;
+char *seclevel = NULL;
+char *authproto = NULL;
+char *authpasswd = NULL;
+char *privpasswd = NULL;
+int  proto = 1;
 char string_value[MAX_INPUT_BUFFER] = "";
 char **labels = NULL;
 char **unitv = NULL;
@@ -143,10 +149,35 @@
 		usage ("Incorrect arguments supplied\n");
 
 	/* create the command line to execute */
-	command_line = ssprintf
+	if (proto == 3) {
+	    if ( strcmp(seclevel, "noAuthNoPriv") == 0 ) {
+	    	command_line = ssprintf
+	                      (command_line,
+	                       "%s -m ALL -v 3 -l noAuthNoPriv  %s %s",
+                               PATH_TO_SNMPGET, server_address, oid);
+	    }
+	    if ( strcmp(seclevel, "authNoPriv") == 0 ) {
+		command_line = ssprintf
+		              (command_line,
+			       "%s -m ALL -v 3 -l authNoPriv -a %s -u %s -A %s %s %s",
+			       PATH_TO_SNMPGET, authproto, secname, authpasswd, 
+			       server_address, oid);
+	    }
+	    if ( strcmp(seclevel, "authPriv") == 0 ) {
+		command_line = ssprintf
+		              (command_line,
+			       "%s -m ALL -v 3 -l authPriv -a %s -u %s -A %s -X %s %s %s",
+			       PATH_TO_SNMPGET, authproto, secname, authpasswd, 
+			       privpasswd, server_address, oid);
+	    }
+	} else {
+	    command_line = ssprintf
 		(command_line,
 		 "%s -m ALL -v 1 %s %s %s",
 		 PATH_TO_SNMPGET, server_address, community, oid);
+	}
+
+	
 
 	/* run the command */
 	child_process = spopen (command_line);
@@ -285,7 +316,7 @@
 	if (found == 0)
 		terminate
 			(STATE_UNKNOWN,
-			 "%s problem - No data recieved from host\nCMD: %s\n",
+			 "%s problem - No data received from host\nCMD: %s\n",
 			 label, command_line);
 
 	/* WARNING if output found on stderr */
@@ -348,6 +379,13 @@
 	if (units == NULL)
 		units = strscpy (NULL, "");
 
+	if (seclevel == NULL || ( strcmp(seclevel, "authNoPriv") && 
+	                          strcmp(seclevel, "authPriv") ) ) 
+	    	seclevel = strscpy (NULL, "noAuthNoPriv");
+
+	if (authproto == NULL)
+	    	authproto = strscpy (NULL, "MD5");
+	
 	return c;
 }
 
@@ -378,6 +416,12 @@
 		{"eregi", required_argument, 0, 'R'},
 		{"label", required_argument, 0, 'l'},
 		{"units", required_argument, 0, 'u'},
+		{"protocol", required_argument,0, 'p'},
+		{"seclevel", required_argument,0, 'L'},
+		{"authproto", required_argument,0, 'a'},
+		{"authpasswd",  required_argument,0, 'A'},
+		{"privpasswd", required_argument,0, 'X'},
+		{"secname", required_argument, 0, 'U'},
 		{0, 0, 0, 0}
 	};
 #endif
@@ -385,10 +429,10 @@
 	while (1) {
 #ifdef HAVE_GETOPT_H
 		c =
-			getopt_long (argc, argv, "+?hVt:c:w:H:C:o:d:D:s:R:r:l:u:",
+			getopt_long (argc, argv, "+?hVt:c:w:H:C:o:d:D:s:R:r:l:u:p:L:a:A:X:U:",
 									 long_options, &option_index);
 #else
-		c = getopt (argc, argv, "+?hVt:c:w:H:C:o:d:D:s:R:r:l:u:");
+		c = getopt (argc, argv, "+?hVt:c:w:H:C:o:d:D:s:R:r:l:u:p:L:a:A:X:U:");
 #endif
 
 		if (c == -1 || c == EOF)
@@ -409,6 +453,12 @@
 		case 'r':
 		case 'l':
 		case 'u':
+		case 'p':
+		case 'L':
+		case 'a':
+		case 'A':
+		case 'X':
+		case 'U':
 			i++;
 		}
 
@@ -568,6 +618,24 @@
 					unitv[nunits - 1] = ptr;
 			}
 			break;
+		case 'p':
+			proto = atoi(optarg);
+			break;
+		case 'L':
+			seclevel = strscpy (seclevel, optarg);
+			break;
+		case 'a':
+			authproto = strscpy (authproto, optarg);
+			break;	
+	   	case 'A':
+			authpasswd = strscpy (authpasswd, optarg);
+			break;
+		case 'X':
+			privpasswd = strscpy (privpasswd, optarg);
+			break;
+		case 'U':
+			secname = strscpy (secname, optarg);
+			break;
 		}
 	}
 	return i;
@@ -580,6 +648,8 @@
 		("Usage: check_snmp -H <ip_address> -o <OID> [-w warn_range] [-c crit_range] \n"
 		 "                  [-C community] [-s string] [-r regex] [-R regexi] [-t timeout]\n"
 		 "                  [-l label] [-u units] [-d delimiter] [-D output-delimiter]\n"
+		 "                  [-p protocol] [-L seclevel] [-a authproto] [-A authpasswd]\n"
+		 "                  [-X privpasswd] [-U secname]\n"
 		 "       check_snmp --help\n" "       check_snmp --version\n");
 }
 
@@ -597,6 +667,18 @@
 		 "    Print version information\n"
 		 " -H, --hostname=HOST\n"
 		 "    Name or IP address of the device you wish to query\n"
+		 " -p, --protocol=[1|3]\n"
+		 "    SNMP protocol version\n"
+		 " -L, --seclevel=[noAuthNoPriv|authNoPriv|authPriv]\n"
+		 "    SNMPv3 securityLevel\n"
+		 " -U, --secname=USERNAME\n"
+		 "    SNMPv3 username\n"
+		 " -a, --authproto=[MD5|SHA]\n"
+		 "    SNMPv3 authproto\n"
+		 " -A, --authpasswd=PASSWORD\n"
+		 "    SNMPv3 authentication password\n"
+		 " -X, --privpasswd=PASSWORD\n"
+		 "    SNMPv3 crypt password (DES)\n"
 		 " -o, --oid=OID(s)\n"
 		 "    Object identifier(s) whose value you wish to query\n"
 		 " -w, --warning=INTEGER_RANGE(s)\n"