X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fbattery.c;h=70d0486b9b25ed602b3d2d72cd3ccb62f5c7b524;hb=b597804afc25d374944100ab9726849b1401cc23;hp=416f3397d0e6c01da373ca17dfc8d48fac8ab03a;hpb=39ba035b60b509311874ccf89d11d240c0271a90;p=collectd.git diff --git a/src/battery.c b/src/battery.c index 416f3397..70d0486b 100644 --- a/src/battery.c +++ b/src/battery.c @@ -1,6 +1,7 @@ /** * collectd - src/battery.c * Copyright (C) 2006,2007 Florian octo Forster + * Copyright (C) 2008 Michał Mirosław * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -17,12 +18,15 @@ * * Authors: * Florian octo Forster + * Michał Mirosław **/ #include "collectd.h" #include "common.h" #include "plugin.h" +#include "utils_complain.h" + #if HAVE_MACH_MACH_TYPES_H # include #endif @@ -437,6 +441,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; + FILE *fh; char buffer[1024]; char filename[256]; @@ -507,8 +513,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 */