static _Bool report_percent = 0;
static _Bool report_degraded = 0;
+static _Bool query_statefs = 0;
static void battery_submit2 (char const *plugin_instance, /* {{{ */
char const *type, char const *type_instance, gauge_t value)
gauge_t capacity_full = NAN; /* Total capacity */
gauge_t capacity_design = NAN; /* Full design capacity */
+ if (query_statefs)
+ return battery_read_statefs ();
+
#if HAVE_IOKIT_PS_IOPOWERSOURCES_H
get_via_io_power_sources (&charge_rel, ¤t, &voltage);
#endif
{
int status;
+ if (query_statefs)
+ return battery_read_statefs ();
+
DEBUG ("battery plugin: Trying sysfs ...");
status = read_sysfs ();
if (status == 0)
static int battery_config (oconfig_item_t *ci)
{
- _Bool query_statefs = 0;
-
for (int i = 0; i < ci->children_num; i++)
{
oconfig_item_t *child = ci->children + i;
child->key);
}
- if (query_statefs)
- {
- /* register read function from statefs backend. to avoid conflicts, unregister the current one */
- plugin_unregister_read ("battery");
- plugin_register_read ("battery", battery_read_statefs);
- }
-
return (0);
} /* }}} int battery_config */
vl.values_len = 1;
sstrncpy (vl.host, hostname_g, sizeof (vl.host));
sstrncpy (vl.plugin, "battery", sizeof (vl.plugin));
+ /* statefs supports 1 battery at present */
+ sstrncpy (vl.plugin_instance, "0", sizeof (vl.plugin_instance));
sstrncpy (vl.type, type, sizeof (vl.type));
plugin_dispatch_values (&vl);
submitted_this_run = 0;
-
if ( getvalue(STATEFS_ROOT "ChargePercentage", &value, buffer, BFSZ) )
battery_submit( "charge", value );
// Use capacity as a charge estimate if ChargePercentage is not available
if ( submitted_this_run == 0 )
{
- ERROR ("statefs_battery plugin: none of the statistics are available.");
+ ERROR ("battery plugin: statefs backend: none of the statistics are available");
return (-1);
}