]> git.ipfire.org Git - collecty.git/commitdiff
graphs: Add a new legacy gateway latency graph
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 11 Nov 2025 20:26:42 +0000 (20:26 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 11 Nov 2025 20:26:42 +0000 (20:26 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
src/daemon/graphs.c
src/daemon/graphs/graph.h
src/daemon/graphs/legacy-gateway-latency4.c [new file with mode: 0644]
src/daemon/graphs/legacy-gateway-latency4.h [new file with mode: 0644]

index 56d03f40578b41f4dafe18a639ad67eddbc9b7c4..fb37c9b44a4f1777e9dc8e3f1990c0453f2e4854 100644 (file)
@@ -126,6 +126,8 @@ dist_telemetryd_SOURCES = \
        src/daemon/graphs/hostapd-station-rate-info.h \
        src/daemon/graphs/hostapd-station-signal.c \
        src/daemon/graphs/hostapd-station-signal.h \
+       src/daemon/graphs/legacy-gateway-latency4.c \
+       src/daemon/graphs/legacy-gateway-latency4.h \
        src/daemon/graphs/legacy-suricata.c \
        src/daemon/graphs/legacy-suricata.h \
        src/daemon/graphs/loadavg.c \
index 51b7ab67c8c9e617a571cf84597624f886e769c4..d7fd551c215b51a20d313dc99414b4fb8f5331ea 100644 (file)
@@ -43,6 +43,7 @@
 #include "graphs/uptime.h"
 
 // Legacy graphs
+#include "graphs/legacy-gateway-latency4.h"
 #include "graphs/legacy-suricata.h"
 
 // Register all graphs
@@ -72,6 +73,7 @@ static const td_graph_impl* graph_impls[] = {
        &unbound_recursion_time_graph,
 
        // Legacy
+       &legacy_gateway_latency4_graph,
        &legacy_suricata_graph,
 
        NULL,
index 58e043eae9355b8e5b80842e5efbb7e994da39bb..c0d3d5a87d359a27e4b5592d68d71fc6e72b7494 100644 (file)
@@ -173,6 +173,10 @@ static inline int __DRAW(td_args* args, const char* what, const char* field,
                DRAW_AREA_OUTLINE_WITH_LABEL(args, field, object, color, flags, label, ##__VA_ARGS__); \
        } while(0)
 
+// Draws an invisible AREA
+#define DRAW_SPACER(args, field, object) \
+       SCRIPT(args, "AREA:" FIELD, FIELD_AND_OBJECT(field, object))
+
 // Horizontal lines
 #define DRAW_HRULE(args, value, color) \
        SCRIPT(args, "HRULE:%lf" color, (double)value)
@@ -229,11 +233,13 @@ static inline int __DRAW(td_args* args, const char* what, const char* field,
        } while (0)
 
 // Handles for fields
+#define FIELD_SPACER(field)                                    field "_spacer"
 #define FIELD_CURRENT(field)                           field "_cur"
 #define FIELD_AVERAGE(field)                           field "_avg"
 #define FIELD_MINIMUM(field)                           field "_min"
 #define FIELD_MAXIMUM(field)                           field "_max"
 #define FIELD_PERCENT(field)                           field "_p"
+#define FIELD_STDDEV2(field)                           field "_stddev2"
 #define FIELD_INF(field)                                       field "_inf"
 #define FIELD_NEGINF(field)                                    field "_neginf"
 #define FIELD_BITS(field)                                      field "_bits"
@@ -350,6 +356,17 @@ static inline int __DRAW(td_args* args, const char* what, const char* field,
                VALUE_ALL(args, FIELD_BYTES(field), object); \
        } while (0)
 
+/*
+       Draw a standard deviation (this takes the baseline and the deviation)
+*/
+#define DRAW_STDDEV(args, baseline, stddev, object, color) \
+       do { \
+               COMPUTE_DIFFERENCE(args, FIELD_SPACER(baseline), object, baseline, object, stddev, object); \
+               COMPUTE_MULTIPLY(args, FIELD_STDDEV2(stddev), object, stddev, object, 2); \
+               DRAW_SPACER(args, FIELD_SPACER(baseline), object); \
+               DRAW_AREA_BACKGROUND(args, FIELD_STDDEV2(stddev), object, color, STACKED); \
+       } while (0)
+
 /*
        This draws an I/O graph
 */
diff --git a/src/daemon/graphs/legacy-gateway-latency4.c b/src/daemon/graphs/legacy-gateway-latency4.c
new file mode 100644 (file)
index 0000000..66acab9
--- /dev/null
@@ -0,0 +1,64 @@
+/*#############################################################################
+#                                                                             #
+# 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 "legacy-gateway-latency4.h"
+
+static int legacy_gateway_latency4_title(td_ctx* ctx, td_graph* graph,
+               const char* object, char* title, size_t length) {
+       return __td_string_set(title, length, _("Latency to the Default Gateway"));
+}
+
+static int legacy_gateway_latency4_render(td_ctx* ctx, td_graph* graph,
+               const td_graph_render_options* options, td_args* args, const char* object) {
+       int r;
+
+       // Load all sources
+       r = td_graph_require_source(graph, args, "legacy-gateway-latency4", NULL);
+       if (r < 0)
+               return r;
+
+       // Header
+       PRINT_HEADER4(args, _("Current"), _("Average"), _("Minimum"), _("Maximum"));
+
+       // Draw the stddev area
+       DRAW_STDDEV(args, "latency", "stddev", NULL, COLOR_DEFAULT);
+
+       // Draw the measured latency
+       DRAW_LINE_WITH_LABEL(args, 1, "latency", NULL, COLOR_DEFAULT, 0, _("Latency"));
+       PRINT_CAMM(args, "latency", NULL, SECONDS_HIGHRES);
+
+       PRINT_EMPTY_LINE(args);
+
+       return 0;
+}
+
+const td_graph_impl legacy_gateway_latency4_graph = {
+       .name    = "LegacyGatewayLatency4",
+       .render  = legacy_gateway_latency4_render,
+       .title   = legacy_gateway_latency4_title,
+       .vlabel  = td_graph_vlabel_seconds,
+
+       // Limits
+       .lower_limit = 0,
+       .upper_limit = LONG_MAX,
+};
diff --git a/src/daemon/graphs/legacy-gateway-latency4.h b/src/daemon/graphs/legacy-gateway-latency4.h
new file mode 100644 (file)
index 0000000..2ca80af
--- /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_LEGACY_GATEWAY_LATENCY4_H
+#define TELEMETRY_GRAPH_LEGACY_GATEWAY_LATENCY4_H
+
+#include "../graph.h"
+
+extern const td_graph_impl legacy_gateway_latency4_graph;
+
+#endif /* TELEMETRY_GRAPH_LEGACY_GATEWAY_LATENCY4_H */