]> git.ipfire.org Git - collecty.git/commitdiff
graphs: Add a disk graph
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 30 Oct 2025 22:35:25 +0000 (22:35 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 30 Oct 2025 22:35:25 +0000 (22:35 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
src/daemon/colors.h
src/daemon/graphs.c
src/daemon/graphs/disk.c [new file with mode: 0644]
src/daemon/graphs/disk.h [new file with mode: 0644]
src/daemon/graphs/graph.h

index fa69b1e922b73be872bfb9474a9bd494a756de03..00de27014cfac322b775d3fa65d1678b76ae4884 100644 (file)
@@ -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 \
index f3639e6186a03211cda82716ec2f70656fb9a888..2d452a80689d378e98289310c95d9e7c412a8146 100644 (file)
 #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) {
index 373f761b08813c040f21eebb75809f50e1208df7..e3f0c468633f026daca43d68957749e35f4bbb7f 100644 (file)
@@ -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 (file)
index 0000000..91b10c8
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.       #
+#                                                                             #
+#############################################################################*/
+
+#include <limits.h>
+
+#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 (file)
index 0000000..26c45b3
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.       #
+#                                                                             #
+#############################################################################*/
+
+#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 */
index 95d70b7a9a000031ca35e88900d402d19e13410b..13332a4e931df4fbe7d488550b06f56d7ed9b545 100644 (file)
@@ -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 */