From 7a137624a0b5490d284460ed8d22317a14297b5e Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Sun, 9 Jul 2006 12:16:02 +0200 Subject: [PATCH] ping plugin: Updated the ping plugin to work with liboping 0.2.2. --- src/ping.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) 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; } } -- 2.11.0