From 997d0a2364e24b92305cb9ac86c42396f3da176e Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Thu, 23 Oct 2025 17:53:01 +0000 Subject: [PATCH] sources: sensors: Collect energy sensors Signed-off-by: Michael Tremer --- src/daemon/sources.c | 1 + src/daemon/sources/sensors.c | 25 +++++++++++++++++++++++++ src/daemon/sources/sensors.h | 1 + 3 files changed, 27 insertions(+) diff --git a/src/daemon/sources.c b/src/daemon/sources.c index bca20af..76199b2 100644 --- a/src/daemon/sources.c +++ b/src/daemon/sources.c @@ -93,6 +93,7 @@ static const td_source_impl* source_impls[] = { &sensors_fan_source, &sensors_temp_source, &sensors_power_source, + &sensors_energy_source, #endif /* HAVE_SENSORS */ #if ENABLE_TESTS diff --git a/src/daemon/sources/sensors.c b/src/daemon/sources/sensors.c index 7e09342..956c652 100644 --- a/src/daemon/sources/sensors.c +++ b/src/daemon/sources/sensors.c @@ -447,3 +447,28 @@ const td_source_impl sensors_power_source = { // Methods .heartbeat = sensors_power_heartbeat, }; + +/* + Energy +*/ +static int sensors_energy_heartbeat(td_ctx* ctx, td_source* source) { + sensors_value values[] = { + { "input", SENSORS_SUBFEATURE_ENERGY_INPUT }, + { NULL }, + }; + + return read_sensors(ctx, source, SENSORS_FEATURE_ENERGY, values); +} + +const td_source_impl sensors_energy_source = { + .name = "sensors-energy", + + // RRD Data Sources + .rrd_dss = { + { "input", "GAUGE", 0, -1, }, + { NULL }, + }, + + // Methods + .heartbeat = sensors_energy_heartbeat, +}; diff --git a/src/daemon/sources/sensors.h b/src/daemon/sources/sensors.h index 4be195d..7fea277 100644 --- a/src/daemon/sources/sensors.h +++ b/src/daemon/sources/sensors.h @@ -27,5 +27,6 @@ extern const td_source_impl sensors_input_source; extern const td_source_impl sensors_fan_source; extern const td_source_impl sensors_temp_source; extern const td_source_impl sensors_power_source; +extern const td_source_impl sensors_energy_source; #endif /* TELEMETRY_SOURCE_SENSORS_H */ -- 2.47.3