Merge branch 'collectd-4.0'
[collectd.git] / src / wireless.c
index 929d5d8..09df407 100644 (file)
 #include "common.h"
 #include "plugin.h"
 
-#if defined(KERNEL_LINUX)
-# define WIRELESS_HAVE_READ 1
-#else
-# define WIRELESS_HAVE_READ 0
+#if !KERNEL_LINUX
+# error "No applicable input method."
 #endif
 
 #define WIRELESS_PROC_FILE "/proc/net/wireless"
 
-static data_source_t data_source_quality[1] =
-{
-       {"value", DS_TYPE_GAUGE, 0, NAN}
-};
-
-static data_set_t quality_ds =
-{
-       "signal_quality", 1, data_source_quality
-};
-
-static data_source_t data_source_signal[1] =
-{
-       {"value", DS_TYPE_GAUGE, NAN, 0}
-};
-
-static data_set_t power_ds =
-{
-       "signal_power", 1, data_source_signal
-};
-
-static data_set_t noise_ds =
-{
-       "signal_noise", 1, data_source_signal
-};
-
-#if WIRELESS_HAVE_READ
 #if 0
 static double wireless_dbm_to_watt (double dbm)
 {
@@ -84,7 +56,7 @@ static void wireless_submit (const char *plugin_instance, const char *type,
        vl.values = values;
        vl.values_len = 1;
        vl.time = time (NULL);
-       strcpy (vl.host, hostname);
+       strcpy (vl.host, hostname_g);
        strcpy (vl.plugin, "wireless");
        strncpy (vl.plugin_instance, plugin_instance,
                        sizeof (vl.plugin_instance));
@@ -112,7 +84,9 @@ static int wireless_read (void)
        /* there are a variety of names for the wireless device */
        if ((fh = fopen (WIRELESS_PROC_FILE, "r")) == NULL)
        {
-               syslog (LOG_WARNING, "wireless: fopen: %s", strerror (errno));
+               char errbuf[1024];
+               WARNING ("wireless: fopen: %s",
+                               sstrerror (errno, errbuf, sizeof (errbuf)));
                return (-1);
        }
 
@@ -163,15 +137,8 @@ static int wireless_read (void)
 
        return (0);
 } /* int wireless_read */
-#endif /* WIRELESS_HAVE_READ */
 
 void module_register (void)
 {
-       plugin_register_data_set (&quality_ds);
-       plugin_register_data_set (&power_ds);
-       plugin_register_data_set (&noise_ds);
-
-#if WIRELESS_HAVE_READ
        plugin_register_read ("wireless", wireless_read);
-#endif /* WIRELESS_HAVE_READ */
-}
+} /* void module_register */