From: Michael Tremer Date: Thu, 23 Oct 2025 17:32:16 +0000 (+0000) Subject: sources: sensors: Collect fan metrics X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1d93efb0e5aabf41078548ad7a67bd913ba70671;p=telemetry.git sources: sensors: Collect fan metrics Signed-off-by: Michael Tremer --- diff --git a/src/daemon/sources.c b/src/daemon/sources.c index 886e93a..a3352b4 100644 --- a/src/daemon/sources.c +++ b/src/daemon/sources.c @@ -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 */ diff --git a/src/daemon/sources/sensors.c b/src/daemon/sources/sensors.c index 61150d6..b5abe1d 100644 --- a/src/daemon/sources/sensors.c +++ b/src/daemon/sources/sensors.c @@ -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 */ diff --git a/src/daemon/sources/sensors.h b/src/daemon/sources/sensors.h index 4828793..45c309f 100644 --- a/src/daemon/sources/sensors.h +++ b/src/daemon/sources/sensors.h @@ -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 */