From: Florian Forster Date: Sun, 9 Jul 2006 10:16:02 +0000 (+0200) Subject: ping plugin: Updated the ping plugin to work with liboping 0.2.2. X-Git-Tag: collectd-3.10.0~5 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=7a137624a0b5490d284460ed8d22317a14297b5e;p=collectd.git ping plugin: Updated the ping plugin to work with liboping 0.2.2. --- diff --git a/src/ping.c b/src/ping.c index 91e0dbcc..8e2c50b4 100644 --- a/src/ping.c +++ b/src/ping.c @@ -29,7 +29,7 @@ #define MODULE_NAME "ping" #include -#include "liboping/liboping.h" +#include "liboping/oping.h" static pingobj_t *pingobj = NULL; @@ -123,8 +123,9 @@ static void ping_read (void) { pingobj_iter_t *iter; - char *host; - double latency; + char host[512]; + double latency; + size_t buf_len; if (pingobj == NULL) return; @@ -136,21 +137,22 @@ static void ping_read (void) return; } - for (iter = ping_iterator_get (pingobj); iter != NULL; iter = ping_iterator_next (iter)) + for (iter = ping_iterator_get (pingobj); + iter != NULL; + iter = ping_iterator_next (iter)) { - const char *tmp; - - if ((tmp = ping_iterator_get_host (iter)) == NULL) - continue; - if ((host = strdup (tmp)) == NULL) + buf_len = sizeof (host); + if (ping_iterator_get_info (iter, PING_INFO_HOSTNAME, + host, &buf_len)) continue; - latency = ping_iterator_get_latency (iter); + buf_len = sizeof (latency); + if (ping_iterator_get_info (iter, PING_INFO_LATENCY, + &latency, &buf_len)) + continue; DBG ("host = %s, latency = %f", host, latency); ping_submit (host, latency); - - free (host); host = NULL; } }