summaryrefslogtreecommitdiffstats
path: root/plugins/check_ping.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/check_ping.c')
-rw-r--r--plugins/check_ping.c37
1 files changed, 19 insertions, 18 deletions
diff --git a/plugins/check_ping.c b/plugins/check_ping.c
index 1d34656c..26810f32 100644
--- a/plugins/check_ping.c
+++ b/plugins/check_ping.c
@@ -66,6 +66,7 @@ int
66main (int argc, char **argv) 66main (int argc, char **argv)
67{ 67{
68 char *cmd = NULL; 68 char *cmd = NULL;
69 char *rawcmd = NULL;
69 int result = STATE_UNKNOWN; 70 int result = STATE_UNKNOWN;
70 int this_result = STATE_UNKNOWN; 71 int this_result = STATE_UNKNOWN;
71 int i; 72 int i;
@@ -90,27 +91,26 @@ main (int argc, char **argv)
90 alarm (timeout_interval); 91 alarm (timeout_interval);
91 92
92 for (i = 0 ; i < n_addresses ; i++) { 93 for (i = 0 ; i < n_addresses ; i++) {
94
95#ifdef PING6_COMMAND
96 if (is_inet6_addr(addresses[i]) && address_family != AF_INET)
97 rawcmd = strdup(PING6_COMMAND);
98 else
99 rawcmd = strdup(PING_COMMAND);
100#else
101 rawcmd = strdup(PING_COMMAND);
102#endif
93 103
94 /* does the host address of number of packets argument come first? */ 104 /* does the host address of number of packets argument come first? */
95#ifdef PING6_COMMAND 105#ifdef PING_PACKETS_FIRST
96# ifdef PING_PACKETS_FIRST 106# ifdef PING_HAS_TIMEOUT
97 if (is_inet6_addr(addresses[i]) && address_family != AF_INET) 107 asprintf (&cmd, rawcmd, timeout_interval, max_packets, addresses[i]);
98 asprintf (&cmd, PING6_COMMAND, max_packets, addresses[i]);
99 else
100 asprintf (&cmd, PING_COMMAND, max_packets, addresses[i]);
101# else 108# else
102 if (is_inet6_addr(addresses[i]) && address_family != AF_INET) 109 asprintf (&cmd, rawcmd, max_packets, addresses[i]);
103 asprintf (&cmd, PING6_COMMAND, addresses[i], max_packets);
104 else
105 asprintf (&cmd, PING_COMMAND, addresses[i], max_packets);
106# endif 110# endif
107#else /* USE_IPV6 */ 111#else
108# ifdef PING_PACKETS_FIRST 112 asprintf (&cmd, rawcmd, addresses[i], max_packets);
109 asprintf (&cmd, PING_COMMAND, max_packets, addresses[i]); 113#endif
110# else
111 asprintf (&cmd, PING_COMMAND, addresses[i], max_packets);
112# endif
113#endif /* USE_IPV6 */
114 114
115 if (verbose) 115 if (verbose)
116 printf ("%s ==> ", cmd); 116 printf ("%s ==> ", cmd);
@@ -150,7 +150,8 @@ main (int argc, char **argv)
150 printf ("%f:%d%% %f:%d%%\n", wrta, wpl, crta, cpl); 150 printf ("%f:%d%% %f:%d%%\n", wrta, wpl, crta, cpl);
151 151
152 result = max_state (result, this_result); 152 result = max_state (result, this_result);
153 153 free (rawcmd);
154 free (cmd);
154 } 155 }
155 156
156 return result; 157 return result;