summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 84b0b42)
raw | patch | inline | side by side (parent: 84b0b42)
author | octo <octo> | |
Mon, 23 Jan 2006 10:39:27 +0000 (10:39 +0000) | ||
committer | octo <octo> | |
Mon, 23 Jan 2006 10:39:27 +0000 (10:39 +0000) |
configure.in | patch | blob | history | |
src/Makefile.am | patch | blob | history | |
src/battery.c | patch | blob | history |
diff --git a/configure.in b/configure.in
index e7e2ea5aee5624ad6d9f3f9f6d4565ff3d095aa0..21c09871c833a73a2d21f7cee7d3bd727ead3714 100644 (file)
--- a/configure.in
+++ b/configure.in
dnl Process this file with autoconf to produce a configure script.
-AC_INIT(collectd, 3.6.1)
+AC_INIT(collectd, 3.7.alpha0)
AC_CONFIG_SRCDIR(src/collectd.c)
AC_CONFIG_HEADERS(src/config.h)
AM_INIT_AUTOMAKE(dist-bzip2)
diff --git a/src/Makefile.am b/src/Makefile.am
index b959eb8b29fc3b389d8d9f2b4f53dc347ebfbd86..a98eab1bce0a90d11f01941bf37919581fe99bbe 100644 (file)
--- a/src/Makefile.am
+++ b/src/Makefile.am
if BUILD_MODULE_BATTERY
pkglib_LTLIBRARIES += battery.la
-battery_la_SOURCES = battery.c battery.h
+battery_la_SOURCES = battery.c
battery_la_LDFLAGS = -module -avoid-version
battery_la_CFLAGS = -Wall -Werror
collectd_LDADD += "-dlopen" battery.la
diff --git a/src/battery.c b/src/battery.c
index a1c5e28b3be81a7e49d80b8e94a548f30963d495..b87b24ee39b6209c41fc0da16521ce17c5280ce7 100644 (file)
--- a/src/battery.c
+++ b/src/battery.c
static void battery_current_write (char *host, char *inst, char *val)
{
- rrd_update_file (host, battery_current_file, val,
+ char filename[BUFSIZE];
+ int len;
+
+ len = snprintf (filename, BUFSIZE, battery_current_file, inst);
+ if ((len >= BUFSIZE) || (len < 0))
+ return;
+
+ rrd_update_file (host, filename, val,
ds_def_current, ds_num_current);
}
static void battery_voltage_write (char *host, char *inst, char *val)
{
- rrd_update_file (host, battery_voltage_file, val,
+ char filename[BUFSIZE];
+ int len;
+
+ len = snprintf (filename, BUFSIZE, battery_voltage_file, inst);
+ if ((len >= BUFSIZE) || (len < 0))
+ return;
+
+ rrd_update_file (host, filename, val,
ds_def_voltage, ds_num_voltage);
}
static void battery_charge_write (char *host, char *inst, char *val)
{
- rrd_update_file (host, battery_charge_file, val,
+ char filename[BUFSIZE];
+ int len;
+
+ len = snprintf (filename, BUFSIZE, battery_charge_file, inst);
+ if ((len >= BUFSIZE) || (len < 0))
+ return;
+
+ rrd_update_file (host, filename, val,
ds_def_charge, ds_num_charge);
}
fclose (fh);
fh = NULL;
}
+
+ if (access ("/proc/acpi/battery", R_OK | X_OK) == 0)
+ {
+ /*
+ * [11:00] <@tokkee> $ cat /proc/acpi/battery/BAT1/state
+ * [11:00] <@tokkee> present: yes
+ * [11:00] <@tokkee> capacity state: ok
+ * [11:00] <@tokkee> charging state: charging
+ * [11:00] <@tokkee> present rate: 1724 mA
+ * [11:00] <@tokkee> remaining capacity: 4136 mAh
+ * [11:00] <@tokkee> present voltage: 12428 mV
+ */
+ syslog (LOG_DEBUG, "Found directory `/proc/acpi/battery'");
+ }
#endif /* KERNEL_LINUX */
}
#else