disk plugin: Correct the collection of {read,write}-time.
[collectd.git] / src / ntpd.c
index 668e302..83bf162 100644 (file)
 # include <poll.h>
 #endif
 
-static data_source_t seconds_dsrc[1] =
-{
-       {"seconds", DS_TYPE_GAUGE, -1000000.0, 1000000.0}
-};
-
-static data_set_t time_offset_ds =
-{
-       "time_offset", 1, seconds_dsrc
-};
-
-static data_set_t time_dispersion_ds =
-{
-       "time_dispersion", 1, seconds_dsrc
-};
-
-static data_set_t delay_ds =
-{
-       "delay", 1, seconds_dsrc
-};
-
-static data_source_t ppm_dsrc[1] =
-{
-       {"ppm", DS_TYPE_GAUGE, -1000000.0, 1000000.0}
-};
-
-static data_set_t frequency_offset_ds =
-{
-       "frequency_offset", 1, ppm_dsrc
-};
-
 static const char *config_keys[] =
 {
        "Host",
@@ -389,12 +359,12 @@ static int ntpd_connect (void)
 
        if ((status = getaddrinfo (host, port, &ai_hints, &ai_list)) != 0)
        {
-               DEBUG ("getaddrinfo (%s, %s): %s",
-                               host, port,
-                               status == EAI_SYSTEM ? strerror (errno) : gai_strerror (status));
+               char errbuf[1024];
                ERROR ("ntpd plugin: getaddrinfo (%s, %s): %s",
                                host, port,
-                               status == EAI_SYSTEM ? strerror (errno) : gai_strerror (status));
+                               (status == EAI_SYSTEM)
+                               ? sstrerror (errno, errbuf, sizeof (errbuf))
+                               : gai_strerror (status));
                return (-1);
        }
 
@@ -470,8 +440,9 @@ static int ntpd_receive_response (int req_code, int *res_items, int *res_size,
 
        if (gettimeofday (&time_end, NULL) < 0)
        {
+               char errbuf[1024];
                ERROR ("ntpd plugin: gettimeofday failed: %s",
-                               strerror (errno));
+                               sstrerror (errno, errbuf, sizeof (errbuf)));
                return (-1);
        }
        time_end.tv_sec++; /* wait for a most one second */
@@ -481,8 +452,9 @@ static int ntpd_receive_response (int req_code, int *res_items, int *res_size,
        {
                if (gettimeofday (&time_now, NULL) < 0)
                {
+                       char errbuf[1024];
                        ERROR ("ntpd plugin: gettimeofday failed: %s",
-                                       strerror (errno));
+                                       sstrerror (errno, errbuf, sizeof (errbuf)));
                        return (-1);
                }
 
@@ -502,9 +474,9 @@ static int ntpd_receive_response (int req_code, int *res_items, int *res_size,
 
                if (status < 0)
                {
-                       DEBUG ("poll failed: %s", strerror (errno));
+                       char errbuf[1024];
                        ERROR ("ntpd plugin: poll failed: %s",
-                                       strerror (errno));
+                                       sstrerror (errno, errbuf, sizeof (errbuf)));
                        return (-1);
                }
 
@@ -522,7 +494,9 @@ static int ntpd_receive_response (int req_code, int *res_items, int *res_size,
 
                if (status < 0)
                {
-                       DEBUG ("recv(2) failed: %s", strerror (errno));
+                       char errbuf[1024];
+                       DEBUG ("recv(2) failed: %s",
+                                       sstrerror (errno, errbuf, sizeof (errbuf)));
                        DEBUG ("Closing socket #%i", sd);
                        close (sd);
                        sock_descr = sd = -1;
@@ -874,9 +848,10 @@ static int ntpd_read (void)
                                        NULL, 0, 0 /* no flags */);
                        if (status != 0)
                        {
+                               char errbuf[1024];
                                ERROR ("ntpd plugin: getnameinfo failed: %s",
-                                               status == EAI_SYSTEM
-                                               ? strerror (errno)
+                                               (status == EAI_SYSTEM)
+                                               ? sstrerror (errno, errbuf, sizeof (errbuf))
                                                : gai_strerror (status));
                                continue;
                        }
@@ -957,13 +932,9 @@ static int ntpd_read (void)
 
 void module_register (void)
 {
-       plugin_register_data_set (&time_offset_ds);
-       plugin_register_data_set (&time_dispersion_ds);
-       plugin_register_data_set (&delay_ds);
-       plugin_register_data_set (&frequency_offset_ds);
-
 #if NTPD_HAVE_READ
-       plugin_register_config ("ntpd", ntpd_config, config_keys, config_keys_num);
+       plugin_register_config ("ntpd", ntpd_config,
+                       config_keys, config_keys_num);
        plugin_register_read ("ntpd", ntpd_read);
 #endif /* NTPD_HAVE_READ */
-}
+} /* void module_register */