[collectd] [PATCH] fix test_liboping

apevec at gmail.com apevec at gmail.com
Tue Mar 3 19:00:11 CET 2009


From: Alan Pevec <apevec at redhat.com>

---
 src/liboping/test_liboping.c |   21 ++++++++++++++-------
 1 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/src/liboping/test_liboping.c b/src/liboping/test_liboping.c
index cd7a781..35e7a4c 100644
--- a/src/liboping/test_liboping.c
+++ b/src/liboping/test_liboping.c
@@ -1,7 +1,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 
-#include "liboping.h"
+#include "oping.h"
 
 int main (int argc, char **argv)
 {
@@ -26,9 +26,10 @@ int main (int argc, char **argv)
 	{
 		printf ("Adding host `%s'..\n", argv[i]);
 
-		if (ping_host_add (ping, argv[i]) > 0)
+		if (ping_host_add (ping, argv[i]) < 0)
 		{
-			fprintf (stderr, "ping_host_add (verplant.org) failed\n");
+			fprintf (stderr, "ping_host_add (%s) failed: %s\n",
+				argv[i], ping_get_error(ping));
 			return (-1);
 		}
 	}
@@ -37,17 +38,23 @@ int main (int argc, char **argv)
 	{
 		if (ping_send (ping) < 0)
 		{
-			fprintf (stderr, "ping_send failed\n");
+			fprintf (stderr, "ping_send failed: %s\n",
+				ping_get_error(ping));
 			return (-1);
 		}
 
 		for (iter = ping_iterator_get (ping); iter != NULL; iter = ping_iterator_next (iter))
 		{
-			const char *host;
+			char        host[255];
 			double      latency;
+			size_t      size;
 
-			host    = ping_iterator_get_host (iter);
-			latency = ping_iterator_get_latency (iter);
+			size = sizeof(host);
+			ping_iterator_get_info (iter, PING_INFO_HOSTNAME,
+				(void*) host, &size );
+			size = sizeof(latency);
+			ping_iterator_get_info (iter, PING_INFO_LATENCY,
+				(void*) &latency, &size );
 
 			printf ("host = %s, latency = %f\n", host, latency);
 		}
-- 
1.6.0.6




More information about the collectd mailing list