aboutsummaryrefslogtreecommitdiff
path: root/plugins/check_ping.c
diff options
context:
space:
mode:
authorGravatar Karl DeBisschop <kdebisschop@users.sourceforge.net> 2004-02-25 07:49:12 +0000
committerGravatar Karl DeBisschop <kdebisschop@users.sourceforge.net> 2004-02-25 07:49:12 +0000
commit8809baebc0d825b5ca966a4e7f412aa2ec627a2a (patch)
treec5571a2708a744e1e168d5355fc0b6d59b712d26 /plugins/check_ping.c
parentb8c407e0f5df94186363ac16c610bcef85745aa5 (diff)
downloadmonitoring-plugins-8809baebc0d825b5ca966a4e7f412aa2ec627a2a.tar.gz
pass timeout to ping if supported with -w parameter (linux)
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@824 f882894a-f735-0410-b71e-b25c423dba1c
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
main (int argc, char **argv)
{
char *cmd = NULL;
+ char *rawcmd = NULL;
int result = STATE_UNKNOWN;
int this_result = STATE_UNKNOWN;
int i;
@@ -90,27 +91,26 @@ main (int argc, char **argv)
alarm (timeout_interval);
for (i = 0 ; i < n_addresses ; i++) {
+
+#ifdef PING6_COMMAND
+ if (is_inet6_addr(addresses[i]) && address_family != AF_INET)
+ rawcmd = strdup(PING6_COMMAND);
+ else
+ rawcmd = strdup(PING_COMMAND);
+#else
+ rawcmd = strdup(PING_COMMAND);
+#endif
/* does the host address of number of packets argument come first? */
-#ifdef PING6_COMMAND
-# ifdef PING_PACKETS_FIRST
- if (is_inet6_addr(addresses[i]) && address_family != AF_INET)
- asprintf (&cmd, PING6_COMMAND, max_packets, addresses[i]);
- else
- asprintf (&cmd, PING_COMMAND, max_packets, addresses[i]);
+#ifdef PING_PACKETS_FIRST
+# ifdef PING_HAS_TIMEOUT
+ asprintf (&cmd, rawcmd, timeout_interval, max_packets, addresses[i]);
# else
- if (is_inet6_addr(addresses[i]) && address_family != AF_INET)
- asprintf (&cmd, PING6_COMMAND, addresses[i], max_packets);
- else
- asprintf (&cmd, PING_COMMAND, addresses[i], max_packets);
+ asprintf (&cmd, rawcmd, max_packets, addresses[i]);
# endif
-#else /* USE_IPV6 */
-# ifdef PING_PACKETS_FIRST
- asprintf (&cmd, PING_COMMAND, max_packets, addresses[i]);
-# else
- asprintf (&cmd, PING_COMMAND, addresses[i], max_packets);
-# endif
-#endif /* USE_IPV6 */
+#else
+ asprintf (&cmd, rawcmd, addresses[i], max_packets);
+#endif
if (verbose)
printf ("%s ==> ", cmd);
@@ -150,7 +150,8 @@ main (int argc, char **argv)
printf ("%f:%d%% %f:%d%%\n", wrta, wpl, crta, cpl);
result = max_state (result, this_result);
-
+ free (rawcmd);
+ free (cmd);
}
return result;