Code

Merge branch 'pull/collectd-4.0' into collectd-4.0
authorFlorian Forster <octo@huhu.verplant.org>
Fri, 28 Sep 2007 14:42:13 +0000 (16:42 +0200)
committerFlorian Forster <octo@huhu.verplant.org>
Fri, 28 Sep 2007 14:42:13 +0000 (16:42 +0200)
ChangeLog
configure.in
contrib/PerlLib/Collectd.pm
contrib/collection.cgi
src/wireless.c

index a4f3fc5b6a9030be39cbd2ac8ad7a354236e8477..653227f5284165bb2af0701eb6e87a0ecb0f3f46 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
-yyyy-mm-dd, Version 4.0.9
+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
@@ -106,6 +109,10 @@ yyyy-mm-dd, Version 4.0.9
          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.
 
index 9ba98db8101f5b2d96cbb87fce799db4489619b3..40016fdb9d457a304f3797d702cfe9efca6367c0 100644 (file)
@@ -1,5 +1,5 @@
 dnl Process this file with autoconf to produce a configure script.
-AC_INIT(collectd, 4.0.8)
+AC_INIT(collectd, 4.0.9)
 AC_CONFIG_SRCDIR(src/collectd.c)
 AC_CONFIG_HEADERS(src/config.h)
 AM_INIT_AUTOMAKE(dist-bzip2)
index a8f604359eccd1da43e428def6062669736da4d6..61dd1b5ec63eebd00639eb7be926ac24d1290c72 100644 (file)
@@ -44,7 +44,7 @@ our %EXPORT_TAGS = (
 
 Exporter::export_ok_tags('all');
 
-bootstrap Collectd "4.0.8";
+bootstrap Collectd "4.0.9";
 
 1;
 
index ebd937ef9010798b4b490845136919e632546ade..791976027827adba69de670ca6c93b97d67b6a9b 100755 (executable)
@@ -944,10 +944,10 @@ sub load_graph_definitions
     'GPRINT:max:MAX:%5.1lf%s Max,',
     'GPRINT:avg:LAST:%5.1lf%s Last\l'
     ],
-    charge => [
-    'DEF:avg={file}:charge:AVERAGE',
-    'DEF:min={file}:charge:MIN',
-    'DEF:max={file}:charge:MAX',
+    charge => ['-v', 'Ah',
+    'DEF:avg={file}:value:AVERAGE',
+    'DEF:min={file}:value:MIN',
+    'DEF:max={file}:value:MAX',
     "AREA:max#$HalfBlue",
     "AREA:min#$Canvas",
     "LINE1:avg#$FullBlue:Charge",
@@ -956,18 +956,6 @@ sub load_graph_definitions
     'GPRINT:max:MAX:%5.1lf%sAh Max,',
     'GPRINT:avg:LAST:%5.1lf%sAh Last\l'
     ],
-    charge_percent => [
-    'DEF:avg={file}:percent:AVERAGE',
-    'DEF:min={file}:percent:MIN',
-    'DEF:max={file}:percent:MAX',
-    "AREA:max#$HalfBlue",
-    "AREA:min#$Canvas",
-    "LINE1:avg#$FullBlue:Charge",
-    'GPRINT:min:MIN:%5.1lf%s%% Min,',
-    'GPRINT:avg:AVERAGE:%5.1lf%s%% Avg,',
-    'GPRINT:max:MAX:%5.1lf%s%% Max,',
-    'GPRINT:avg:LAST:%5.1lf%s%% Last\l'
-    ],
     cpu => ['-v', 'CPU load',
     'DEF:avg={file}:value:AVERAGE',
     'DEF:min={file}:value:MIN',
@@ -980,10 +968,10 @@ sub load_graph_definitions
     'GPRINT:max:MAX:%6.2lf%% Max,',
     'GPRINT:avg:LAST:%6.2lf%% Last\l'
     ],
-    current => [
-    'DEF:avg={file}:current:AVERAGE',
-    'DEF:min={file}:current:MIN',
-    'DEF:max={file}:current:MAX',
+    current => ['-v', 'Ampere',
+    'DEF:avg={file}:value:AVERAGE',
+    'DEF:min={file}:value:MIN',
+    'DEF:max={file}:value:MAX',
     "AREA:max#$HalfBlue",
     "AREA:min#$Canvas",
     "LINE1:avg#$FullBlue:Current",
@@ -2517,7 +2505,7 @@ sub meta_graph_memory
   . (defined ($plugin_instance) ? "-$plugin_instance" : '') . "/$type";
   $opts->{'number_format'} = '%5.1lf%s';
 
-  $opts->{'rrd_opts'} = ['-b', '1024'];
+  $opts->{'rrd_opts'} = ['-b', '1024', '-v', 'Bytes'];
 
   my @files = ();
 
@@ -2777,10 +2765,10 @@ sub meta_graph_swap
 
   $opts->{'colors'} =
   {
-    'Free'   => '00e000',
-    'Cached'  => '0000ff',
-    'Reserved'      => 'ffb000',
-    'Used'   => 'ff0000'
+    'Free'     => '00e000',
+    'Cached'   => '0000ff',
+    'Reserved' => 'ffb000',
+    'Used'     => 'ff0000'
   };
 
   _custom_sort_arrayref ($type_instances,
index 81c968e8d9b4e462a57129b6c37cb7fdd05e303d..106754996c962518bc66e7348e36b2661a211562 100644 (file)
@@ -67,6 +67,15 @@ static void wireless_submit (const char *plugin_instance, const char *type,
        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
@@ -96,6 +105,8 @@ static int wireless_read (void)
        devices_found = 0;
        while (fgets (buffer, sizeof (buffer), fh) != NULL)
        {
+               char *endptr;
+
                numfields = strsplit (buffer, fields, 8);
 
                if (numfields < 5)
@@ -109,19 +120,28 @@ static int wireless_read (void)
                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);