]> git.ipfire.org Git - oddments/collecty.git/commitdiff
sources: sensors: Collect fan metrics
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 23 Oct 2025 17:32:16 +0000 (17:32 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 23 Oct 2025 17:32:16 +0000 (17:32 +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 886e93a80dca124cd8c73600d94c092167a125b2..a3352b4c7dcc133b6e9da0c8954c18fcad94ddbf 100644 (file)
@@ -90,6 +90,7 @@ static const td_source_impl* source_impls[] = {
        // sensors
 #ifdef HAVE_SENSORS
        &sensors_input_source,
+       &sensors_fan_source,
        &sensors_temp_source,
 #endif /* HAVE_SENSORS */
 
index 61150d66869bd911ec245032884b4a771429a78f..b5abe1dd9474821da72960542e3d74e9a4d5302a 100644 (file)
@@ -278,6 +278,49 @@ const td_source_impl sensors_input_source = {
        .heartbeat = sensors_input_heartbeat,
 };
 
+/*
+       Fan
+*/
+static int sensors_fan_heartbeat(td_ctx* ctx, td_source* source) {
+       const sensors_value values[] = {
+               { "current",     SENSORS_SUBFEATURE_FAN_INPUT },
+               { "min",         SENSORS_SUBFEATURE_FAN_MIN },
+               { "max",         SENSORS_SUBFEATURE_FAN_MAX },
+               { "alarm",       SENSORS_SUBFEATURE_FAN_ALARM },
+               { "alarm_max",   SENSORS_SUBFEATURE_FAN_MAX_ALARM },
+               { "alarm_min",   SENSORS_SUBFEATURE_FAN_MIN_ALARM },
+               { "beep",        SENSORS_SUBFEATURE_FAN_BEEP },
+               { "fault",       SENSORS_SUBFEATURE_FAN_FAULT },
+               { "div",         SENSORS_SUBFEATURE_FAN_DIV },
+               { "pulses",      SENSORS_SUBFEATURE_FAN_PULSES },
+               { NULL },
+       };
+
+       return read_sensors(ctx, source, SENSORS_FEATURE_FAN, values);
+}
+
+const td_source_impl sensors_fan_source = {
+       .name = "sensors-fan",
+
+       // RRD Data Sources
+       .rrd_dss = {
+               { "current",     "GAUGE",  0, -1, },
+               { "min",         "GAUGE",  0, -1, },
+               { "max",         "GAUGE",  0, -1, },
+               { "alarm",       "GAUGE",  0, -1, },
+               { "alarm_max",   "GAUGE",  0, -1, },
+               { "alarm_min",   "GAUGE",  0, -1, },
+               { "beep",        "GAUGE",  0, -1, },
+               { "fault",       "GAUGE",  0, -1, },
+               { "div",         "GAUGE",  0, -1, },
+               { "pulses",      "GAUGE",  0, -1, },
+               { NULL },
+       },
+
+       // Methods
+       .heartbeat = sensors_fan_heartbeat,
+};
+
 /*
        Temperature
 */
index 48287934b265dc400d7554a150532f0d4dee5335..45c309f7484044c2b8147eaaf6df84e58d6f648b 100644 (file)
@@ -24,6 +24,7 @@
 #include "../source.h"
 
 extern const td_source_impl sensors_input_source;
+extern const td_source_impl sensors_fan_source;
 extern const td_source_impl sensors_temp_source;
 
 #endif /* TELEMETRY_SOURCE_SENSORS_H */