]> git.ipfire.org Git - telemetry.git/commitdiff
interface: Add an interface throughput graph
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 29 Nov 2025 12:46:10 +0000 (12:46 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 29 Nov 2025 12:46:10 +0000 (12:46 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
src/daemon/graphs.c
src/daemon/graphs/interface-throughput.c [new file with mode: 0644]
src/daemon/graphs/interface-throughput.h [new file with mode: 0644]

index 923405c616bcfd0185e7a553c78825c3036f2eea..393be43141d2add3e2be38a5d393f35d65eb1417 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/interface-throughput.c \
+       src/daemon/graphs/interface-throughput.h \
        src/daemon/graphs/legacy-gateway-latency4.c \
        src/daemon/graphs/legacy-gateway-latency4.h \
        src/daemon/graphs/legacy-suricata.c \
index c61dfeb07709ef38af4563818c043744e4f57adc..3ca2b5427b0cb7bcc5e3ee4d45fb038d24976f7d 100644 (file)
@@ -35,6 +35,7 @@
 #include "graphs/hostapd-station-bandwidth.h"
 #include "graphs/hostapd-station-rate-info.h"
 #include "graphs/hostapd-station-signal.h"
+#include "graphs/interface-throughput.h"
 #include "graphs/loadavg.h"
 #include "graphs/memory.h"
 #include "graphs/pressure.h"
@@ -63,6 +64,9 @@ static const td_graph_impl* graph_impls[] = {
        &disk_io_graph,
        &disk_temp_graph,
 
+       // Interfaces
+       &interface_throughput_graph,
+
        // Pressure (PSI)
        &pressure_cpu_graph,
        &pressure_io_graph,
diff --git a/src/daemon/graphs/interface-throughput.c b/src/daemon/graphs/interface-throughput.c
new file mode 100644 (file)
index 0000000..526c641
--- /dev/null
@@ -0,0 +1,59 @@
+/*#############################################################################
+#                                                                             #
+# 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 "../string.h"
+#include "graph.h"
+#include "interface-throughput.h"
+
+static int interface_throughput_title(td_ctx* ctx, td_graph* graph,
+               const char* object, char* title, size_t length) {
+       return __td_string_format(title, length, _("Throughput - %s"), object);
+}
+
+static int interface_throughput_render(td_ctx* ctx,td_graph* graph,
+               const td_graph_render_options* options, td_args* args, const char* object) {
+       int r;
+
+       // Require the source
+       r = td_graph_require_source(graph, args, "interfaces", object);
+       if (r < 0)
+               return r;
+
+       // Header
+       PRINT_HEADER4(args, _("Current"), _("Average"), _("Minimum"), _("Maximum"));
+
+       // Draw the bandwidth graph
+       DRAW_BANDWIDTH(args, object, "rx_bytes", "tx_bytes");
+
+       return 0;
+}
+
+const td_graph_impl interface_throughput_graph = {
+       .name    = "InterfaceThroughput",
+       .render  = interface_throughput_render,
+       .title   = interface_throughput_title,
+       .vlabel  = td_graph_vlabel_bps,
+
+       // Limits
+       .lower_limit = 0,
+       .upper_limit = LONG_MAX,
+};
diff --git a/src/daemon/graphs/interface-throughput.h b/src/daemon/graphs/interface-throughput.h
new file mode 100644 (file)
index 0000000..40c6061
--- /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_INTERFACE_THROUGHPUT_H
+#define TELEMETRY_GRAPH_INTERFACE_THROUGHPUT_H
+
+#include "../graph.h"
+
+extern const td_graph_impl interface_throughput_graph;
+
+#endif /* TELEMETRY_GRAPH_INTERFACE_THROUGHPUT_H */