]> git.ipfire.org Git - oddments/collecty.git/commitdiff
sources: sensors: Collect energy sensors
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 23 Oct 2025 17:53:01 +0000 (17:53 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 23 Oct 2025 17:53:01 +0000 (17:53 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/daemon/sources.c
src/daemon/sources/sensors.c
src/daemon/sources/sensors.h

index bca20afef377289d00244ef7e8bba8af50c95ea2..76199b2426ddc5af41a874990f8ffb956d73262f 100644 (file)
@@ -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
index 7e09342e63dc05cab16ebb69c892e080789e2a97..956c65207ab532d51faef54ccddd5535ec63a0bd 100644 (file)
@@ -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,
+};
index 4be195d88f33da0af1ff8ff58c17c89c33e6dc53..7fea277c34b881d236478aae648fc2d44ab5a893 100644 (file)
@@ -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 */