Code

patches: Added battery_acpi_complain.dpatch.
authorSebastian Harl <sh@tokkee.org>
Tue, 14 Apr 2009 13:32:45 +0000 (15:32 +0200)
committerSebastian Harl <sh@tokkee.org>
Tue, 14 Apr 2009 13:33:31 +0000 (15:33 +0200)
This is an upstream patch to fix excessive error messages in the battery
plugin in case /proc/acpi/battery is not available.

The changelog has been updated to 4.6.2-2.

debian/changelog
debian/patches/00list
debian/patches/battery_acpi_complain.dpatch [new file with mode: 0755]

index 248cb5572de000b25d02dc4592acdc64ec0dd53e..c60df686e31c4c542100f10b496cfdb00db29b4b 100644 (file)
@@ -1,3 +1,12 @@
+collectd (4.6.2-2) unstable; urgency=low
+
+  * debian/patches:
+    - Added battery_acpi_complain.dpatch - upstream patch to fix excessive
+      error messages in the battery plugin in case /proc/acpi/battery is not
+      available.
+
+ -- Sebastian Harl <sh@tokkee.org>  Tue, 14 Apr 2009 15:30:35 +0200
+
 collectd (4.6.2-1) unstable; urgency=low
 
   * New upstream release.
index 332b35c8333c22b54c6ead8e9d0f6750c3bfbc7f..aa14973a193e91625968cb11cb2fb96ea8fb3d34 100644 (file)
@@ -1,3 +1,4 @@
 rrd_filter_path.dpatch
 collection_conf_path.dpatch
+battery_acpi_complain.dpatch
 
diff --git a/debian/patches/battery_acpi_complain.dpatch b/debian/patches/battery_acpi_complain.dpatch
new file mode 100755 (executable)
index 0000000..7ed6042
--- /dev/null
@@ -0,0 +1,50 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## battery_acpi_complain.dpatch by Sebastian Harl <sh@tokkee.org>
+##
+## DP: battery plugin: Don't complain about missing /proc/acpi/battery each
+## DP: interval. Instead, complain once when the read callback is called for
+## DP: the first time.
+
+@DPATCH@
+
+diff a/src/battery.c b/src/battery.c
+--- a/src/battery.c
++++ b/src/battery.c
+@@ -23,6 +23,8 @@
+ #include "common.h"
+ #include "plugin.h"
++#include "utils_complain.h"
++
+ #if HAVE_MACH_MACH_TYPES_H
+ #  include <mach/mach_types.h>
+ #endif
+@@ -436,6 +438,8 @@ static int battery_read (void)
+ /* #endif HAVE_IOKIT_IOKITLIB_H || HAVE_IOKIT_PS_IOPOWERSOURCES_H */
+ #elif KERNEL_LINUX
++      static c_complain_t acpi_dir_complaint = C_COMPLAIN_INIT_STATIC;
++
+       FILE *fh;
+       char buffer[1024];
+       char filename[256];
+@@ -506,8 +510,17 @@ static int battery_read (void)
+                       battery_submit ("0", "voltage", voltage);
+       }
+-      walk_directory (battery_acpi_dir, battery_read_acpi,
+-                      /* user_data = */ NULL);
++      if (0 == access (battery_acpi_dir, R_OK))
++              walk_directory (battery_acpi_dir, battery_read_acpi,
++                              /* user_data = */ NULL);
++      else
++      {
++              char errbuf[1024];
++              c_complain_once (LOG_WARNING, &acpi_dir_complaint,
++                              "battery plugin: Failed to access `%s': %s",
++                              battery_acpi_dir,
++                              sstrerror (errno, errbuf, sizeof (errbuf)));
++      }
+ #endif /* KERNEL_LINUX */