diff options
Diffstat (limited to 'web/attachments/180341-nagios-plugins-1.4.3.ping_source_address.patch')
-rw-r--r-- | web/attachments/180341-nagios-plugins-1.4.3.ping_source_address.patch | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/web/attachments/180341-nagios-plugins-1.4.3.ping_source_address.patch b/web/attachments/180341-nagios-plugins-1.4.3.ping_source_address.patch new file mode 100644 index 0000000..1560a41 --- /dev/null +++ b/web/attachments/180341-nagios-plugins-1.4.3.ping_source_address.patch | |||
@@ -0,0 +1,114 @@ | |||
1 | diff -uNr nagios-plugins-1.4.3.old/plugins/check_ping.c nagios-plugins-1.4.3/plugins/check_ping.c | ||
2 | --- nagios-plugins-1.4.3.old/plugins/check_ping.c 2006-03-13 06:08:28.000000000 -0500 | ||
3 | +++ nagios-plugins-1.4.3/plugins/check_ping.c 2006-05-19 11:33:42.000000000 -0400 | ||
4 | @@ -50,6 +50,7 @@ | ||
5 | float wrta = UNKNOWN_TRIP_TIME; | ||
6 | float crta = UNKNOWN_TRIP_TIME; | ||
7 | char **addresses = NULL; | ||
8 | +char *source_address; | ||
9 | int n_addresses = 0; | ||
10 | int max_addr = 1; | ||
11 | int max_packets = -1; | ||
12 | @@ -67,6 +68,7 @@ | ||
13 | { | ||
14 | char *cmd = NULL; | ||
15 | char *rawcmd = NULL; | ||
16 | + char *ping_args = NULL; | ||
17 | int result = STATE_UNKNOWN; | ||
18 | int this_result = STATE_UNKNOWN; | ||
19 | int i; | ||
20 | @@ -101,15 +103,28 @@ | ||
21 | rawcmd = strdup(PING_COMMAND); | ||
22 | #endif | ||
23 | |||
24 | + ping_args = strdup(""); | ||
25 | + | ||
26 | + /* Need to check ping -I in configure and enclose this in ifdef */ | ||
27 | + if (source_address != NULL) { | ||
28 | + ping_args = realloc (ping_args, 20 * sizeof(char)); | ||
29 | + ping_args = strcat(ping_args, "-I "); | ||
30 | + ping_args = strncat(ping_args, source_address, 15 * sizeof(char)); | ||
31 | + ping_args = strcat(ping_args, " "); | ||
32 | + } | ||
33 | + | ||
34 | + ping_args = realloc (ping_args, strlen(ping_args) + strlen(addresses[i]) + 1); | ||
35 | + ping_args = strcat(ping_args, addresses[i]); | ||
36 | + | ||
37 | /* does the host address of number of packets argument come first? */ | ||
38 | #ifdef PING_PACKETS_FIRST | ||
39 | # ifdef PING_HAS_TIMEOUT | ||
40 | - asprintf (&cmd, rawcmd, timeout_interval, max_packets, addresses[i]); | ||
41 | + asprintf (&cmd, rawcmd, timeout_interval, max_packets, ping_args); | ||
42 | # else | ||
43 | - asprintf (&cmd, rawcmd, max_packets, addresses[i]); | ||
44 | + asprintf (&cmd, rawcmd, max_packets, ping_args); | ||
45 | # endif | ||
46 | #else | ||
47 | - asprintf (&cmd, rawcmd, addresses[i], max_packets); | ||
48 | + asprintf (&cmd, rawcmd, ping_args, max_packets); | ||
49 | #endif | ||
50 | |||
51 | if (verbose >= 2) | ||
52 | @@ -150,6 +165,7 @@ | ||
53 | printf ("%f:%d%% %f:%d%%\n", wrta, wpl, crta, cpl); | ||
54 | |||
55 | result = max_state (result, this_result); | ||
56 | + free (ping_args); | ||
57 | free (rawcmd); | ||
58 | free (cmd); | ||
59 | } | ||
60 | @@ -170,6 +186,7 @@ | ||
61 | static struct option longopts[] = { | ||
62 | STD_LONG_OPTS, | ||
63 | {"packets", required_argument, 0, 'p'}, | ||
64 | + {"source", required_argument, 0, 's'}, | ||
65 | {"nohtml", no_argument, 0, 'n'}, | ||
66 | {"link", no_argument, 0, 'L'}, | ||
67 | {"use-ipv4", no_argument, 0, '4'}, | ||
68 | @@ -188,7 +205,7 @@ | ||
69 | } | ||
70 | |||
71 | while (1) { | ||
72 | - c = getopt_long (argc, argv, "VvhnL46t:c:w:H:p:", longopts, &option); | ||
73 | + c = getopt_long (argc, argv, "VvhnL46t:c:w:H:p:s:", longopts, &option); | ||
74 | |||
75 | if (c == -1 || c == EOF) | ||
76 | break; | ||
77 | @@ -245,6 +262,9 @@ | ||
78 | else | ||
79 | usage2 (_("<max_packets> (%s) must be a non-negative number\n"), optarg); | ||
80 | break; | ||
81 | + case 's': /* number of packets to send */ | ||
82 | + source_address = strdup (optarg); | ||
83 | + break; | ||
84 | case 'n': /* no HTML */ | ||
85 | display_html = FALSE; | ||
86 | break; | ||
87 | @@ -396,6 +416,11 @@ | ||
88 | usage (_("You must specify a server address or host name")); | ||
89 | } | ||
90 | |||
91 | + if (source_address != NULL) { | ||
92 | + if (is_addr(source_address) == FALSE) | ||
93 | + usage2 (_("Invalid source address"), source_address); | ||
94 | + } | ||
95 | + | ||
96 | return OK; | ||
97 | } | ||
98 | |||
99 | @@ -535,6 +560,8 @@ | ||
100 | critical threshold pair\n\ | ||
101 | -p, --packets=INTEGER\n\ | ||
102 | number of ICMP ECHO packets to send (Default: %d)\n\ | ||
103 | +-s, --source=IP\n\ | ||
104 | + source address\n\ | ||
105 | -L, --link\n\ | ||
106 | show HTML in the plugin output (obsoleted by urlize)\n"), | ||
107 | DEFAULT_MAX_PACKETS); | ||
108 | @@ -559,5 +586,5 @@ | ||
109 | print_usage (void) | ||
110 | { | ||
111 | printf ("Usage: %s -H <host_address> -w <wrta>,<wpl>%% -c <crta>,<cpl>%%\n\ | ||
112 | - [-p packets] [-t timeout] [-L] [-4|-6]\n", progname); | ||
113 | + [-p packets] [-s source_address] [-t timeout] [-L] [-4|-6]\n", progname); | ||
114 | } | ||