Merge branch 'collectd-4.0' into collectd-4.1
authorFlorian Forster <octo@leeloo.lan.home.verplant.org>
Fri, 28 Sep 2007 13:46:46 +0000 (15:46 +0200)
committerFlorian Forster <octo@leeloo.lan.home.verplant.org>
Fri, 28 Sep 2007 13:46:46 +0000 (15:46 +0200)
Conflicts:

ChangeLog
configure.in
contrib/PerlLib/Collectd.pm

1  2 
ChangeLog
src/wireless.c

diff --combined ChangeLog
+++ b/ChangeLog
@@@ -1,45 -1,8 +1,48 @@@
- yyyy-mm-dd, Version 4.0.9
 +yyyy-mm-dd, Version 4.1.2
 +      * apcups plugin: Fix reporting of the `load percent' data.
 +      * netlink plugin: Build issues under some older versions of the Linux
 +        includes (i. e. Debian Sarge) have been fixed.
 +
 +2007-09-12, Version 4.1.1
 +      * Build system: The detection of `libnetlink' has been improved.
 +      * collectd: The documentation has been fixed in numerous places.
 +      * exec plugin: Setting the group under which to run a program has been
 +        fixed.
 +      * collectd: The `sstrerror' function was improved to work correctly
 +        with the broken GNU version of `strerror_r'.
 +      * collectd: Write an error message to STDERR when loading of a plugin
 +        fails.
 +      * apcups plugin: Fix the `types' used to submit the values: They still
 +        has an `apcups_' prefix which doesn't work anymore.
 +      * rrdtool plugin: Create new RRD-files with the `begin' time set to
 +        whatever the client thinks is `now'..
 +
 +2007-09-01, Version 4.1.0
 +      * Build system: The build system has been changed to automatically
 +        disable all plugins, which are missing dependencies. The dependency
 +        checking has been removed from the plugins themselves to remove
 +        redundancy.
 +      * Flexible interval: The interval of collected data is now sent along
 +        with the data itself over the network, so that the interval-settings
 +        of server and clients no longer needs to match.
 +      * netlink plugin: The new `netlink' plugin connects to the Linux
 +        kernel using a netlink socket and uses it to query information about
 +        interfaces, qdiscs and classes.
 +      * rrdtool plugin: The cache is now dumped to disk in an extra thread
 +        to not block data collection.
 +      * snmp plugin: The new `snmp' plugin can read values from SNMP enabled
 +        network devices, such as switches, routers, thermometers, rack
 +        monitoring servers, etc. The collectd-snmp(5) manpage documents this
 +        plugin.
 +      * unixsock plugin: Added the `LISTVAL' command.
 +      * xmms plugin: The new `xmms' plugin graphs the bitrate and frequency
 +        of music played with xmms.
 +
+ 2007-09-28, Version 4.0.9
        * apcups plugin: Fix reporting of the `load percent' data.
+       * wireless plugin: Correct the handling of cards returning signal and
+         noise quality as percentage.
+       * perl plugin: Fix a possible buffer overflow in get_module_name().
  
  2007-09-12, Version 4.0.8
        * collectd: The `sstrerror' function was improved to work correctly
          from collectd, parses them and exits according to Nagios-standards.
        * manpages: The manpages have been improved a lot.
  
+ 2007-09-28, Version 3.11.7
+       * wireless plugin: Correct the handling of cards returning signal and
+         noise quality as percentage.
  2007-08-31, Version 3.11.6
        * processes plugin: Fix a potential segmentation fault.
  
diff --combined src/wireless.c
  #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"
  
 -#if WIRELESS_HAVE_READ
  #if 0
  static double wireless_dbm_to_watt (double dbm)
  {
@@@ -64,6 -67,15 +64,15 @@@ static void wireless_submit (const cha
        plugin_dispatch_values (type, &vl);
  } /* void wireless_submit */
  
+ #define POWER_MIN -90.0
+ #define POWER_MAX -50.0
+ static double wireless_percent_to_power (double quality)
+ {
+       assert ((quality >= 0.0) && (quality <= 100.0));
+       return ((quality * (POWER_MAX - POWER_MIN)) + POWER_MIN);
+ } /* double wireless_percent_to_power */
  static int wireless_read (void)
  {
  #ifdef KERNEL_LINUX
        devices_found = 0;
        while (fgets (buffer, sizeof (buffer), fh) != NULL)
        {
+               char *endptr;
                numfields = strsplit (buffer, fields, 8);
  
                if (numfields < 5)
                fields[0][len] = '\0';
  
                device  = fields[0];
-               quality = atof (fields[2]);
-               power   = atof (fields[3]);
-               noise   = atof (fields[4]);
-               /* Fill in invalid values when conversion failed.. */
-               if (quality == 0.0)
-                       quality = -1.0; /* quality >= 0 */
-               if (power == 0.0)
-                       power = 1.0; /* power <= 0 */
  
-               if (noise == 0.0)
-                       noise = 1.0; /* noise <= 0 */
+               quality = strtod (fields[2], &endptr);
+               if (fields[2] == endptr)
+                       quality = -1.0; /* invalid */
+               /* power [dBm] < 0.0 */
+               power = strtod (fields[3], &endptr);
+               if (fields[3] == endptr)
+                       power = 1.0; /* invalid */
+               else if ((power >= 0.0) && (power <= 100.0))
+                       power = wireless_percent_to_power (power);
+               else if (power > 100.0)
+                       power = 1.0; /* invalid */
+               /* noise [dBm] < 0.0 */
+               noise = strtod (fields[3], &endptr);
+               if (fields[3] == endptr)
+                       noise = 1.0; /* invalid */
+               else if ((noise >= 0.0) && (noise <= 100.0))
+                       noise = wireless_percent_to_power (noise);
+               else if (noise > 100.0)
+                       noise = 1.0; /* invalid */
  
                wireless_submit (device, "signal_quality", quality);
                wireless_submit (device, "signal_power", power);
  
        return (0);
  } /* int wireless_read */
 -#endif /* WIRELESS_HAVE_READ */
  
  void module_register (void)
  {
 -#if WIRELESS_HAVE_READ
        plugin_register_read ("wireless", wireless_read);
 -#endif /* WIRELESS_HAVE_READ */
  } /* void module_register */