X-Git-Url: https://git.octo.it/?p=collectd.git;a=blobdiff_plain;f=src%2Fbattery.c;h=33ba29231556bc7feec6a00b35276931224100d1;hp=272193ee507b742d78ac30de98cfe7466b697f45;hb=9b626288aff81c68fe19210a58b4a32eeefde9d3;hpb=4ea822d83441f31e816d0742f1276bb501a0cb11 diff --git a/src/battery.c b/src/battery.c index 272193ee..33ba2923 100644 --- 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 #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 */