summaryrefslogtreecommitdiffstats
path: root/web/attachments/221749-check_snmp_sourceip.patch
blob: 2bba2f488f3add817a3b81e75eb4936b72292621 (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
--- check_snmp.c.orig	2007-03-22 15:24:22.000000000 +0100
+++ check_snmp.c	2007-03-22 15:23:00.000000000 +0100
@@ -103,6 +103,7 @@
 int errcode, excode;
 
 char *server_address = NULL;
+char *client_address = NULL;
 char *community = NULL;
 char *authpriv = NULL;
 char *proto = NULL;
@@ -183,11 +184,22 @@
 
 	/* create the command line to execute */
 		if(usesnmpgetnext == TRUE) {
+		if (client_address != NULL)
+		asprintf(&command_line, "%s --clientaddr=%s -t %d -r %d -m %s -v %s %s %s:%s %s",
+				    PATH_TO_SNMPGETNEXT, client_address, timeout_interval, retries, miblist, proto,
+						authpriv, server_address, port, oid);
+		if (client_address == NULL)
 		asprintf(&command_line, "%s -t %d -r %d -m %s -v %s %s %s:%s %s",
 				    PATH_TO_SNMPGETNEXT, timeout_interval, retries, miblist, proto,
 						authpriv, server_address, port, oid);
 	}else{
 
+		if (client_address != NULL)
+		asprintf (&command_line, "%s --clientaddr=%s -t %d -r %d -m %s -v %s %s %s:%s %s",
+	          PATH_TO_SNMPGET, client_address, timeout_interval, retries, miblist, proto,
+	          authpriv, server_address, port, oid);
+
+		if (client_address == NULL)
 		asprintf (&command_line, "%s -t %d -r %d -m %s -v %s %s %s:%s %s",
 	          PATH_TO_SNMPGET, timeout_interval, retries, miblist, proto,
 	          authpriv, server_address, port, oid);
@@ -398,6 +410,7 @@
 	static struct option longopts[] = {
 		STD_LONG_OPTS,
 		{"community", required_argument, 0, 'C'},
+		{"source", required_argument, 0, 'S'},
 		{"oid", required_argument, 0, 'o'},
 		{"object", required_argument, 0, 'o'},
 		{"delimiter", required_argument, 0, 'd'},
@@ -436,7 +449,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:S:C:o:e:E:d:D:s:t:R:r:l:u:p:m:P:L:U:a:A:X:",
 									 longopts, &option);
 
 		if (c == -1 || c == EOF)
@@ -462,6 +475,9 @@
 		case 'H':									/* Host or server */
 			server_address = optarg;
 			break;
+		case 'S':								/* Client source address */
+			client_address = optarg;
+			break;
 		case 'p':       /* TCP port number */
 			port = optarg;
 			break;
@@ -919,6 +935,8 @@
 	/* SNMP and Authentication Protocol */
 	printf (" %s\n", "-n, --next");
   printf ("    %s\n", _("Use SNMP GETNEXT instead of SNMP GET"));
+  printf (" %s\n", "-S, --source=ADDRESS");
+  printf ("    %s\n", _("Specify SNMP client source address"));
   printf (" %s\n", "-P, --protocol=[1|2c|3]");
   printf ("    %s\n", _("SNMP protocol version"));
   printf (" %s\n", "-L, --seclevel=[noAuthNoPriv|authNoPriv|authPriv]");
@@ -1005,7 +1023,7 @@
 print_usage (void)
 {
   printf (_("Usage:"));
-	printf ("%s -H <ip_address> -o <OID> [-w warn_range] [-c crit_range]\n",progname);
+	printf ("%s -H <ip_address> -o <OID> [-S source_ip_address] [-w warn_range] [-c crit_range]\n",progname);
   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");