Code

collectd.conf(5): Document the per-plugin interval configuration.
[collectd.git] / src / ping.c
index 5366b98fbcc1d309be5b4161c82f5dd9ca23ff85..7adbfe13e4d4288dcf5ebb11b55c34e9889970eb 100644 (file)
@@ -184,10 +184,11 @@ static void *ping_thread (void *arg) /* {{{ */
   count = 0;
   for (hl = hostlist_head; hl != NULL; hl = hl->next)
   {
-    int status;
-    status = ping_host_add (pingobj, hl->host);
-    if (status != 0)
-      WARNING ("ping plugin: ping_host_add (%s) failed.", hl->host);
+    int tmp_status;
+    tmp_status = ping_host_add (pingobj, hl->host);
+    if (tmp_status != 0)
+      WARNING ("ping plugin: ping_host_add (%s) failed: %s",
+          hl->host, ping_get_error (pingobj));
     else
       count++;
   }
@@ -217,7 +218,9 @@ static void *ping_thread (void *arg) /* {{{ */
 
     if (gettimeofday (&tv_begin, NULL) < 0)
     {
-      ERROR ("ping plugin: gettimeofday failed");
+      char errbuf[1024];
+      ERROR ("ping plugin: gettimeofday failed: %s",
+          sstrerror (errno, errbuf, sizeof (errbuf)));
       ping_thread_error = 1;
       break;
     }
@@ -322,7 +325,9 @@ static void *ping_thread (void *arg) /* {{{ */
 
     if (gettimeofday (&tv_end, NULL) < 0)
     {
-      ERROR ("ping plugin: gettimeofday failed");
+      char errbuf[1024];
+      ERROR ("ping plugin: gettimeofday failed: %s",
+          sstrerror (errno, errbuf, sizeof (errbuf)));
       ping_thread_error = 1;
       break;
     }
@@ -537,7 +542,7 @@ static void submit (const char *host, const char *type, /* {{{ */
     gauge_t value)
 {
   value_t values[1];
-  value_list_t vl = VALUE_LIST_INIT;
+  value_list_t vl = VALUE_LIST_INIT (plugin_interval);
 
   values[0].gauge = value;
 
@@ -662,12 +667,14 @@ static int ping_shutdown (void) /* {{{ */
   return (0);
 } /* }}} int ping_shutdown */
 
-void module_register (void)
+void module_register (plugin_loaddata_t *data)
 {
+  PLUGIN_INIT_INTERVAL (data);
+
   plugin_register_config ("ping", ping_config,
       config_keys, config_keys_num);
   plugin_register_init ("ping", ping_init);
-  plugin_register_read ("ping", ping_read);
+  plugin_register_read ("ping", ping_read, plugin_interval);
   plugin_register_shutdown ("ping", ping_shutdown);
 } /* void module_register */