From: Michael Tremer Date: Thu, 30 Oct 2025 22:35:25 +0000 (+0000) Subject: graphs: Add a disk graph X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ec246a6052e9f6e8f8b5c68b6abde656006f03a6;p=collecty.git graphs: Add a disk graph Signed-off-by: Michael Tremer --- diff --git a/Makefile.am b/Makefile.am index fa69b1e..00de270 100644 --- a/Makefile.am +++ b/Makefile.am @@ -117,6 +117,8 @@ dist_telemetryd_SOURCES = \ src/daemon/graphs/contextswitches.h \ src/daemon/graphs/cpufreq.c \ src/daemon/graphs/cpufreq.h \ + src/daemon/graphs/disk.c \ + src/daemon/graphs/disk.h \ src/daemon/graphs/graph.h \ src/daemon/graphs/hostapd-station-bandwidth.c \ src/daemon/graphs/hostapd-station-bandwidth.h \ diff --git a/src/daemon/colors.h b/src/daemon/colors.h index f3639e6..2d452a8 100644 --- a/src/daemon/colors.h +++ b/src/daemon/colors.h @@ -66,9 +66,13 @@ #define COLOR_RX "#43a047" #define COLOR_TX "#fb8c00" +// Caches #define COLOR_CACHE_HIT COLOR_GREEN #define COLOR_CACHE_MISS COLOR_RED +// Temperature +#define COLOR_TEMPERATURE COLOR_RED + // CPU Colors static inline const char* COLOR_CPU(long i) { diff --git a/src/daemon/graphs.c b/src/daemon/graphs.c index 373f761..e3f0c46 100644 --- a/src/daemon/graphs.c +++ b/src/daemon/graphs.c @@ -31,6 +31,7 @@ #include "graphs/conntrack.h" #include "graphs/contextswitches.h" #include "graphs/cpufreq.h" +#include "graphs/disk.h" #include "graphs/hostapd-station-bandwidth.h" #include "graphs/hostapd-station-rate-info.h" #include "graphs/hostapd-station-signal.h" @@ -49,6 +50,7 @@ static const td_graph_impl* graph_impls[] = { &conntrack_graph, &contextswitches_graph, &cpufreq_graph, + &disk_temp_graph, &hostapd_station_bandwidth_graph, &hostapd_station_rate_info_graph, &hostapd_station_signal_graph, diff --git a/src/daemon/graphs/disk.c b/src/daemon/graphs/disk.c new file mode 100644 index 0000000..91b10c8 --- /dev/null +++ b/src/daemon/graphs/disk.c @@ -0,0 +1,58 @@ +/*############################################################################# +# # +# telemetryd - The IPFire Telemetry Collection Service # +# Copyright (C) 2025 IPFire Development Team # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +#############################################################################*/ + +#include + +#include "graph.h" +#include "disk.h" + +static int disk_temp_title(td_ctx* ctx, td_graph* graph, + const char* object, char* title, size_t length) { + return __td_string_set(title, length, _("Disk Temperature")); +} + +static int disk_temp_render(td_ctx* ctx, + td_graph* graph, td_args* args, const char* object) { + int r; + + // Load all sources + r = td_graph_require_source(graph, args, "disk", object); + if (r < 0) + return r; + + // Header + PRINT_HEADER4(args, _("Current"), _("Average"), _("Minimum"), _("Maximum")); + + // Draw the temperature + DRAW_TEMPERATURE_KELVIN(args, "temperature", object, "%s", _("Temperature")); + + return 0; +} + +const td_graph_impl disk_temp_graph = { + .name = "DiskTemperature", + .render = disk_temp_render, + .title = disk_temp_title, + //.vlabel = td_graph_vlabel_qps, + + // Limits + .lower_limit = -LONG_MAX, + .upper_limit = LONG_MAX, +}; diff --git a/src/daemon/graphs/disk.h b/src/daemon/graphs/disk.h new file mode 100644 index 0000000..26c45b3 --- /dev/null +++ b/src/daemon/graphs/disk.h @@ -0,0 +1,28 @@ +/*############################################################################# +# # +# telemetryd - The IPFire Telemetry Collection Service # +# Copyright (C) 2025 IPFire Development Team # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +#############################################################################*/ + +#ifndef TELEMETRY_GRAPH_DISK_H +#define TELEMETRY_GRAPH_DISK_H + +#include "../graph.h" + +extern const td_graph_impl disk_temp_graph; + +#endif /* TELEMETRY_GRAPH_DISK_H */ diff --git a/src/daemon/graphs/graph.h b/src/daemon/graphs/graph.h index 95d70b7..13332a4 100644 --- a/src/daemon/graphs/graph.h +++ b/src/daemon/graphs/graph.h @@ -74,6 +74,9 @@ typedef enum flags { #define SECONDS_HIGHRES "%%12.2lf%%ss" #define SECONDS "%%13.2lfs" +// Temperatures +#define KELVIN "%%12.2lf K" + // Macro to terminate a line #define EOL "\\j" @@ -334,4 +337,13 @@ static inline int __DRAW(td_args* args, const char* what, const char* field, PRINT_CAMM(args, bytes, object, BPS); \ } while (0) +/* + This draws a temperature graph +*/ +#define DRAW_TEMPERATURE_KELVIN(args, field, object, ...) \ + do { \ + DRAW_LINE_WITH_LABEL(args, 1, field, object, COLOR_TEMPERATURE, 0, ##__VA_ARGS__); \ + PRINT_CAMM(args, field, object, KELVIN); \ + } while (0) + #endif /* TELEMETRY_GRAPHS_GRAPH_H */