Integrated `liboping' into collectd. This obsoletes the old `libping'
authorocto <octo>
Sun, 5 Feb 2006 11:49:25 +0000 (11:49 +0000)
committerocto <octo>
Sun, 5 Feb 2006 11:49:25 +0000 (11:49 +0000)
configure.in
src/Makefile.am
src/liboping/Makefile
src/libping/ping.c
src/ping.c

index d9ac917..8388678 100644 (file)
@@ -712,7 +712,7 @@ AC_COLLECTD([wireless],  [disable], [module], [wireless link statistics])
 
 #AC_COLLECTD([users],     [disable], [module], [user count statistics])
 
-AC_OUTPUT(Makefile src/libconfig/Makefile src/libping/Makefile src/Makefile)
+AC_OUTPUT(Makefile src/libconfig/Makefile src/liboping/Makefile src/Makefile)
 
 cat <<EOF;
 
index f6cca37..2563462 100644 (file)
@@ -1,6 +1,6 @@
 SUBDIRS = libconfig
 if BUILD_MODULE_PING
-SUBDIRS += libping
+SUBDIRS += liboping
 endif
 
 if COMPILER_IS_GCC
@@ -142,8 +142,8 @@ if BUILD_MODULE_PING
 pkglib_LTLIBRARIES += ping.la
 ping_la_SOURCES = ping.c ping.h
 ping_la_LDFLAGS = -module -avoid-version
-ping_la_LIBADD  = libping/libping.la
-ping_la_DEPENDENCIES = libping/libping.la
+ping_la_LIBADD  = liboping/liboping.la
+ping_la_DEPENDENCIES = liboping/liboping.la
 collectd_LDADD += "-dlopen" ping.la
 collectd_DEPENDENCIES += ping.la
 endif
index 1233cce..9b99d77 100644 (file)
-CFLAGS=-Wall -Werror -O0 -g -DDEBUG=1
-#CFLAGS=-Wall -Werror -O3
+# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# src/liboping/Makefile.  Generated from Makefile.in by configure.
 
-all: test_liboping
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005  Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
 
-clean:
-       rm -f *.o
-       rm -f test_liboping
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
 
-liboping.o: liboping.c liboping.h
 
-test_liboping.o: test_liboping.c liboping.h
 
-test_liboping: test_liboping.o liboping.o
+srcdir = .
+top_srcdir = ../..
+
+pkgdatadir = $(datadir)/collectd
+pkglibdir = $(libdir)/collectd
+pkgincludedir = $(includedir)/collectd
+top_builddir = ../..
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+INSTALL = /usr/bin/install -c
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = i686-pc-linux-gnu
+host_triplet = i686-pc-linux-gnu
+subdir = src/liboping
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+       $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/src/config.h
+CONFIG_CLEAN_FILES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+liboping_la_LIBADD =
+am_liboping_la_OBJECTS = liboping.lo
+liboping_la_OBJECTS = $(am_liboping_la_OBJECTS)
+DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/src
+depcomp =
+am__depfiles_maybe =
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+       $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \
+       $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+       $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+       $(AM_LDFLAGS) $(LDFLAGS) -o $@
+SOURCES = $(liboping_la_SOURCES)
+DIST_SOURCES = $(liboping_la_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = ${SHELL} /home/octo/collectd/trunk/missing --run aclocal-1.9
+AMDEP_FALSE = #
+AMDEP_TRUE = 
+AMTAR = ${SHELL} /home/octo/collectd/trunk/missing --run tar
+AR = ar
+AUTOCONF = ${SHELL} /home/octo/collectd/trunk/missing --run autoconf
+AUTOHEADER = ${SHELL} /home/octo/collectd/trunk/missing --run autoheader
+AUTOMAKE = ${SHELL} /home/octo/collectd/trunk/missing --run automake-1.9
+AWK = mawk
+BUILD_FEATURE_DAEMON_FALSE = #
+BUILD_FEATURE_DAEMON_TRUE = 
+BUILD_FEATURE_DEBUG_FALSE = #
+BUILD_FEATURE_DEBUG_TRUE = 
+BUILD_MODULE_BATTERY_FALSE = #
+BUILD_MODULE_BATTERY_TRUE = 
+BUILD_MODULE_CPUFREQ_FALSE = #
+BUILD_MODULE_CPUFREQ_TRUE = 
+BUILD_MODULE_CPU_FALSE = #
+BUILD_MODULE_CPU_TRUE = 
+BUILD_MODULE_DF_FALSE = #
+BUILD_MODULE_DF_TRUE = 
+BUILD_MODULE_DISK_FALSE = #
+BUILD_MODULE_DISK_TRUE = 
+BUILD_MODULE_HDDTEMP_FALSE = #
+BUILD_MODULE_HDDTEMP_TRUE = 
+BUILD_MODULE_LOAD_FALSE = #
+BUILD_MODULE_LOAD_TRUE = 
+BUILD_MODULE_MEMORY_FALSE = #
+BUILD_MODULE_MEMORY_TRUE = 
+BUILD_MODULE_MYSQL_FALSE = #
+BUILD_MODULE_MYSQL_TRUE = 
+BUILD_MODULE_NFS_FALSE = #
+BUILD_MODULE_NFS_TRUE = 
+BUILD_MODULE_PING_FALSE = #
+BUILD_MODULE_PING_TRUE = 
+BUILD_MODULE_PROCESSES_FALSE = #
+BUILD_MODULE_PROCESSES_TRUE = 
+BUILD_MODULE_QUOTA_FALSE = 
+BUILD_MODULE_QUOTA_TRUE = #
+BUILD_MODULE_SENSORS_FALSE = #
+BUILD_MODULE_SENSORS_TRUE = 
+BUILD_MODULE_SERIAL_FALSE = #
+BUILD_MODULE_SERIAL_TRUE = 
+BUILD_MODULE_SWAP_FALSE = #
+BUILD_MODULE_SWAP_TRUE = 
+BUILD_MODULE_TAPE_FALSE = #
+BUILD_MODULE_TAPE_TRUE = 
+BUILD_MODULE_TRAFFIC_FALSE = #
+BUILD_MODULE_TRAFFIC_TRUE = 
+BUILD_MODULE_USERS_FALSE = #
+BUILD_MODULE_USERS_TRUE = 
+BUILD_MODULE_WIRELESS_FALSE = #
+BUILD_MODULE_WIRELESS_TRUE = 
+BUILD_WITH_KSTAT_FALSE = 
+BUILD_WITH_KSTAT_TRUE = #
+BUILD_WITH_LIBMYSQL_FALSE = #
+BUILD_WITH_LIBMYSQL_TRUE = 
+BUILD_WITH_LIBRESOLV_FALSE = #
+BUILD_WITH_LIBRESOLV_TRUE = 
+BUILD_WITH_LIBSOCKET_FALSE = 
+BUILD_WITH_LIBSOCKET_TRUE = #
+BUILD_WITH_LIBSTATGRAB_FALSE = 
+BUILD_WITH_LIBSTATGRAB_TRUE = #
+BUILD_WITH_LM_SENSORS_FALSE = #
+BUILD_WITH_LM_SENSORS_TRUE = 
+BUILD_WITH_RRDTOOL_FALSE = #
+BUILD_WITH_RRDTOOL_TRUE = 
+CC = gcc
+CCDEPMODE = depmode=gcc3
+CFLAGS = -g -O2
+COMPILER_IS_GCC_FALSE = #
+COMPILER_IS_GCC_TRUE = 
+CPP = gcc -E
+CPPFLAGS = 
+CXX = g++
+CXXCPP = g++ -E
+CXXDEPMODE = depmode=gcc3
+CXXFLAGS = -g -O2
+CYGPATH_W = echo
+DEFS = -DHAVE_CONFIG_H
+DEPDIR = .deps
+ECHO = echo
+ECHO_C = 
+ECHO_N = -n
+ECHO_T = 
+EGREP = grep -E
+EXEEXT = 
+F77 = 
+FFLAGS = 
+INSTALL_DATA = ${INSTALL} -m 644
+INSTALL_PROGRAM = ${INSTALL}
+INSTALL_SCRIPT = ${INSTALL}
+INSTALL_STRIP_PROGRAM = ${SHELL} $(install_sh) -c -s
+LDFLAGS = 
+LIBLTDL = ${top_builddir}/libltdl/libltdlc.la
+LIBOBJS = 
+LIBS = 
+LIBTOOL = $(SHELL) $(top_builddir)/libtool
+LN_S = ln -s
+LTDLINCL = -I${top_srcdir}/libltdl
+LTLIBOBJS = 
+MAKEINFO = ${SHELL} /home/octo/collectd/trunk/missing --run makeinfo
+OBJEXT = o
+PACKAGE = collectd
+PACKAGE_BUGREPORT = 
+PACKAGE_NAME = collectd
+PACKAGE_STRING = collectd 3.7.0
+PACKAGE_TARNAME = collectd
+PACKAGE_VERSION = 3.7.0
+PATH_SEPARATOR = :
+RANLIB = ranlib
+SET_MAKE = 
+SHELL = /bin/sh
+STRIP = strip
+VERSION = 3.7.0
+ac_ct_AR = ar
+ac_ct_CC = gcc
+ac_ct_CXX = g++
+ac_ct_F77 = 
+ac_ct_RANLIB = ranlib
+ac_ct_STRIP = strip
+am__fastdepCC_FALSE = #
+am__fastdepCC_TRUE = 
+am__fastdepCXX_FALSE = #
+am__fastdepCXX_TRUE = 
+am__include = include
+am__leading_dot = .
+am__quote = 
+am__tar = ${AMTAR} chof - "$$tardir"
+am__untar = ${AMTAR} xf -
+bindir = ${exec_prefix}/bin
+build = i686-pc-linux-gnu
+build_alias = 
+build_cpu = i686
+build_os = linux-gnu
+build_vendor = pc
+datadir = ${prefix}/share
+exec_prefix = ${prefix}
+host = i686-pc-linux-gnu
+host_alias = 
+host_cpu = i686
+host_os = linux-gnu
+host_vendor = pc
+includedir = ${prefix}/include
+infodir = ${prefix}/info
+install_sh = /home/octo/collectd/trunk/install-sh
+libdir = ${exec_prefix}/lib
+libexecdir = ${exec_prefix}/libexec
+localstatedir = ${prefix}/var
+mandir = ${prefix}/man
+mkdir_p = mkdir -p --
+oldincludedir = /usr/include
+prefix = /tmp/collectd
+program_transform_name = s,x,x,
+sbindir = ${exec_prefix}/sbin
+sharedstatedir = ${prefix}/com
+subdirs =  libltdl src/libconfig
+sysconfdir = ${prefix}/etc
+target_alias = 
+AUTOMAKE_OPTIONS = foreign no-dependencies
+noinst_LTLIBRARIES = liboping.la
+
+#liboping_la_CFLAGS = 
+liboping_la_LDFLAGS = -avoid-version
+liboping_la_SOURCES = liboping.h liboping.c
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+       @for dep in $?; do \
+         case '$(am__configure_deps)' in \
+           *$$dep*) \
+             cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+               && exit 0; \
+             exit 1;; \
+         esac; \
+       done; \
+       echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/liboping/Makefile'; \
+       cd $(top_srcdir) && \
+         $(AUTOMAKE) --foreign  src/liboping/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+       @case '$?' in \
+         *config.status*) \
+           cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+         *) \
+           echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+           cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+       esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+clean-noinstLTLIBRARIES:
+       -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+       @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
+         dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+         test "$$dir" != "$$p" || dir=.; \
+         echo "rm -f \"$${dir}/so_locations\""; \
+         rm -f "$${dir}/so_locations"; \
+       done
+liboping.la: $(liboping_la_OBJECTS) $(liboping_la_DEPENDENCIES) 
+       $(LINK)  $(liboping_la_LDFLAGS) $(liboping_la_OBJECTS) $(liboping_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+       -rm -f *.$(OBJEXT)
+
+distclean-compile:
+       -rm -f *.tab.c
+
+.c.o:
+       $(COMPILE) -c $<
+
+.c.obj:
+       $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+       $(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+       -rm -f *.lo
+
+clean-libtool:
+       -rm -rf .libs _libs
+
+distclean-libtool:
+       -rm -f libtool
+uninstall-info-am:
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+       list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+       unique=`for i in $$list; do \
+           if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+         done | \
+         $(AWK) '    { files[$$0] = 1; } \
+              END { for (i in files) print i; }'`; \
+       mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+               $(TAGS_FILES) $(LISP)
+       tags=; \
+       here=`pwd`; \
+       list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+       unique=`for i in $$list; do \
+           if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+         done | \
+         $(AWK) '    { files[$$0] = 1; } \
+              END { for (i in files) print i; }'`; \
+       if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+         test -n "$$unique" || unique=$$empty_fix; \
+         $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+           $$tags $$unique; \
+       fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+               $(TAGS_FILES) $(LISP)
+       tags=; \
+       here=`pwd`; \
+       list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+       unique=`for i in $$list; do \
+           if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+         done | \
+         $(AWK) '    { files[$$0] = 1; } \
+              END { for (i in files) print i; }'`; \
+       test -z "$(CTAGS_ARGS)$$tags$$unique" \
+         || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+            $$tags $$unique
+
+GTAGS:
+       here=`$(am__cd) $(top_builddir) && pwd` \
+         && cd $(top_srcdir) \
+         && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+       @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
+       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
+       list='$(DISTFILES)'; for file in $$list; do \
+         case $$file in \
+           $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
+           $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
+         esac; \
+         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+         dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
+         if test "$$dir" != "$$file" && test "$$dir" != "."; then \
+           dir="/$$dir"; \
+           $(mkdir_p) "$(distdir)$$dir"; \
+         else \
+           dir=''; \
+         fi; \
+         if test -d $$d/$$file; then \
+           if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+             cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+           fi; \
+           cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+         else \
+           test -f $(distdir)/$$file \
+           || cp -p $$d/$$file $(distdir)/$$file \
+           || exit 1; \
+         fi; \
+       done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+       $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+         install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+         `test -z '$(STRIP)' || \
+           echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+       @echo "This command is intended for maintainers to use"
+       @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
+       mostlyclean-am
+
+distclean: distclean-am
+       -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+       distclean-libtool distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-exec-am:
+
+install-info: install-info-am
+
+install-man:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+       -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+       mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-info-am
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+       clean-libtool clean-noinstLTLIBRARIES ctags distclean \
+       distclean-compile distclean-generic distclean-libtool \
+       distclean-tags distdir dvi dvi-am html html-am info info-am \
+       install install-am install-data install-data-am install-exec \
+       install-exec-am install-info install-info-am install-man \
+       install-strip installcheck installcheck-am installdirs \
+       maintainer-clean maintainer-clean-generic mostlyclean \
+       mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
+       pdf pdf-am ps ps-am tags uninstall uninstall-am \
+       uninstall-info-am
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
index c6a0096..8c6f9d7 100644 (file)
@@ -178,7 +178,7 @@ send_ping( const char *host, struct sockaddr_in *taddr, struct ping_priv * datum
   icp->icmp_code  = 0;
   icp->icmp_cksum = 0;
   icp->icmp_id    = getpid() & 0xFFFF;
-  icp->icmp_seq   = icp->icmp_id;
+  icp->icmp_seq   = icp->icmp_id; /* FIXME this is not nice.. */
   icp->icmp_cksum = in_checksum((u_short *)icp, len );
 
   if(( ss = sendto( datum->sock, buf, sizeof( buf ), 0, 
index f80cab5..2a9802a 100644 (file)
 #define MODULE_NAME "ping"
 
 #include <netinet/in.h>
-#include "libping/ping.h"
+#include "liboping/liboping.h"
 
-#define MAX_PINGHOSTS 32
-
-typedef struct
-{
-       char *name;
-       int   flags;
-       int   disable; /* How long (how many iterations) this host is still disabled */
-       int   backoff; /* How long the host will be disabled, if it failes again */
-} pinghost_t;
-
-static pinghost_t hosts[MAX_PINGHOSTS];
-static int        num_pinghosts;
+static pingobj_t *pingobj = NULL;
 
 static char *file_template = "ping-%s.rrd";
 
@@ -61,15 +50,6 @@ static int config_keys_num = 1;
 
 static void ping_init (void)
 {
-       int i;
-
-       for (i = 0; i < MAX_PINGHOSTS; i++)
-       {
-               hosts[i].flags = 0;
-               hosts[i].disable = 0;
-               hosts[i].backoff = 1;
-       }
-
        return;
 }
 
@@ -79,19 +59,23 @@ static int ping_config (char *key, char *value)
        {
                return (-1);
        }
-       else if (num_pinghosts >= MAX_PINGHOSTS)
-       {
-               return (1);
-       }
-       else if ((hosts[num_pinghosts].name = strdup (value)) == NULL)
+
+       if (pingobj == NULL)
        {
-               return (2);
+               if ((pingobj = ping_construct ()) == NULL)
+               {
+                       syslog (LOG_ERR, "ping: `ping_construct' failed.\n");
+                       return (-1);
+               }
        }
-       else
+
+       if (ping_host_add (pingobj, value) < 0)
        {
-               num_pinghosts++;
-               return (0);
+               syslog (LOG_ERR, "ping: `ping_host_add' failed.\n");
+               return (-1);
        }
+
+       return (0);
 }
 
 static void ping_write (char *host, char *inst, char *val)
@@ -109,11 +93,11 @@ static void ping_write (char *host, char *inst, char *val)
 }
 
 #define BUFSIZE 256
-static void ping_submit (int ping_time, char *host)
+static void ping_submit (char *host, double latency)
 {
        char buf[BUFSIZE];
 
-       if (snprintf (buf, BUFSIZE, "%u:%i", (unsigned int) curtime, ping_time) >= BUFSIZE)
+       if (snprintf (buf, BUFSIZE, "%u:%f", (unsigned int) curtime, latency) >= BUFSIZE)
                return;
 
        plugin_submit (MODULE_NAME, host, buf);
@@ -122,56 +106,35 @@ static void ping_submit (int ping_time, char *host)
 
 static void ping_read (void)
 {
-       int ping;
-       int i;
+       pingobj_iter_t *iter;
 
-       for (i = 0; i < num_pinghosts; i++)
+       char   *host;
+       double  latency;
+
+       if (pingobj == NULL)
+               return;
+
+       if (ping_send (pingobj) < 0)
        {
-               if (hosts[i].disable > 0)
-               {
-                       hosts[i].disable--;
+               syslog (LOG_ERR, "ping: `ping_send' failed.");
+               return;
+       }
+
+       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)
                        continue;
-               }
-               
-               ping = tpinghost (hosts[i].name);
 
-               switch (ping)
-               {
-                       case 0:
-                               if (!(hosts[i].flags & 0x01))
-                                       syslog (LOG_WARNING, "ping %s: Connection timed out.", hosts[i].name);
-                               hosts[i].flags |= 0x01;
-                               break;
-
-                       case -1:
-                               if (!(hosts[i].flags & 0x02))
-                                       syslog (LOG_WARNING, "ping %s: Host or service is not reachable.", hosts[i].name);
-                               hosts[i].flags |= 0x02;
-                               break;
-
-                       case -2:
-                               syslog (LOG_ERR, "ping %s: Socket error. Ping will be disabled for %i iteration(s).",
-                                               hosts[i].name, hosts[i].backoff);
-                               hosts[i].disable = hosts[i].backoff;
-                               if (hosts[i].backoff < 8192) /* 22 3/4 hours */
-                                       hosts[i].backoff *= 2;
-                               hosts[i].flags |= 0x10;
-                               break;
-
-                       case -3:
-                               if (!(hosts[i].flags & 0x04))
-                                       syslog (LOG_WARNING, "ping %s: Connection refused.", hosts[i].name);
-                               hosts[i].flags |= 0x04;
-                               break;
-
-                       default:
-                               if (hosts[i].flags != 0x00)
-                                       syslog (LOG_NOTICE, "ping %s: Back to normal: %ims.", hosts[i].name, ping);
-                               hosts[i].flags = 0x00;
-                               hosts[i].backoff = 1;
-                               ping_submit (ping, hosts[i].name);
-               } /* switch (ping) */
-       } /* for (i = 0; i < num_pinghosts; i++) */
+               latency = ping_iterator_get_latency (iter);
+
+               ping_submit (host, latency);
+
+               free (host); host = NULL;
+       }
 }
 
 void module_register (void)