]> git.ipfire.org Git - telemetry.git/commitdiff
graphs: openvpn: Add client throughput graph
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 12 Jul 2026 13:29:50 +0000 (13:29 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 12 Jul 2026 13:29:50 +0000 (13:29 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
src/daemon/graphs.c
src/daemon/graphs/openvpn.c [new file with mode: 0644]
src/daemon/graphs/openvpn.h [new file with mode: 0644]

index 5f08d117df18201c5937686256a7dd50c39e4779..d89db6d994956e1f13d3568f9e3fa09e60f0b971 100644 (file)
@@ -146,6 +146,8 @@ dist_telemetryd_SOURCES = \
        src/daemon/graphs/loadavg.h \
        src/daemon/graphs/memory.c \
        src/daemon/graphs/memory.h \
+       src/daemon/graphs/openvpn.c \
+       src/daemon/graphs/openvpn.h \
        src/daemon/graphs/pressure.c \
        src/daemon/graphs/pressure.h \
        src/daemon/graphs/processor.c \
index 071e06d3c9ae31dbe9c875c0bad47b6df5429b25..a23949d32a9dc7e39a1334ea9069c4747b5c934e 100644 (file)
@@ -40,6 +40,7 @@
 #include "graphs/knot-resolver.h"
 #include "graphs/loadavg.h"
 #include "graphs/memory.h"
+#include "graphs/openvpn.h"
 #include "graphs/pressure.h"
 #include "graphs/processor.h"
 #include "graphs/processor-power-consumption.h"
@@ -81,6 +82,9 @@ static const td_graph_impl* graph_impls[] = {
        &interface_throughput_graph,
        &interface_packets_graph,
 
+       // OpenVPN
+       &openvpn_client_throughput_graph,
+
        // Pressure (PSI)
        &pressure_cpu_graph,
        &pressure_io_graph,
diff --git a/src/daemon/graphs/openvpn.c b/src/daemon/graphs/openvpn.c
new file mode 100644 (file)
index 0000000..c2ef619
--- /dev/null
@@ -0,0 +1,80 @@
+/*#############################################################################
+#                                                                             #
+# telemetryd - The IPFire Telemetry Collection Service                        #
+# Copyright (C) 2026 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 "../openvpn.h"
+#include "../string.h"
+#include "graph.h"
+#include "openvpn.h"
+
+static int openvpn_client_can_render(td_ctx* ctx, td_graph* graph,
+               const td_graph_render_options* options, const char* object) {
+       char name[OPENVPN_NAME_MAX];
+       int r;
+
+       // Escape the name
+       r = openvpn_escape_name(name, object);
+       if (r < 0)
+               return r;
+
+       return td_graph_requires_source(graph, "openvpn", name);
+}
+
+static int openvpn_client_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 openvpn_client_throughput_render(td_ctx* ctx,td_graph* graph,
+               const td_graph_render_options* options, td_args* args, const char* object) {
+       char name[OPENVPN_NAME_MAX];
+       int r;
+
+       // Escape the name
+       r = openvpn_escape_name(name, object);
+       if (r < 0)
+               return r;
+
+       // Require the source
+       r = td_graph_load_source(graph, args, "openvpn", name);
+       if (r < 0)
+               return r;
+
+       // Header
+       PRINT_HEADER4(args, _("Current"), _("Average"), _("Minimum"), _("Maximum"));
+
+       // Draw the bandwidth graph
+       DRAW_BANDWIDTH(args, name, "rx_bytes", "tx_bytes");
+
+       return 0;
+}
+
+const td_graph_impl openvpn_client_throughput_graph = {
+       .name        = "OpenVPNClientThroughput",
+       .can_render  = openvpn_client_can_render,
+       .render      = openvpn_client_throughput_render,
+       .title       = openvpn_client_throughput_title,
+       .vlabel      = td_graph_vlabel_bps,
+
+       // Limits
+       .lower_limit = 0,
+       .upper_limit = LONG_MAX,
+};
diff --git a/src/daemon/graphs/openvpn.h b/src/daemon/graphs/openvpn.h
new file mode 100644 (file)
index 0000000..63b7859
--- /dev/null
@@ -0,0 +1,28 @@
+/*#############################################################################
+#                                                                             #
+# telemetryd - The IPFire Telemetry Collection Service                        #
+# Copyright (C) 2026 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_OPENVPN_H
+#define TELEMETRY_GRAPH_OPENVPN_H
+
+#include "../graph.h"
+
+extern const td_graph_impl openvpn_client_throughput_graph;
+
+#endif /* TELEMETRY_GRAPH_OPENVPN_H */