From: Michael Tremer Date: Sun, 12 Jul 2026 13:29:50 +0000 (+0000) Subject: graphs: openvpn: Add client throughput graph X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1011cf4cbd73d16fa9baf5bb8e945c92782cc84e;p=telemetry.git graphs: openvpn: Add client throughput graph Signed-off-by: Michael Tremer --- diff --git a/Makefile.am b/Makefile.am index 5f08d11..d89db6d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 \ diff --git a/src/daemon/graphs.c b/src/daemon/graphs.c index 071e06d..a23949d 100644 --- a/src/daemon/graphs.c +++ b/src/daemon/graphs.c @@ -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 index 0000000..c2ef619 --- /dev/null +++ b/src/daemon/graphs/openvpn.c @@ -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 . # +# # +#############################################################################*/ + +#include + +#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 index 0000000..63b7859 --- /dev/null +++ b/src/daemon/graphs/openvpn.h @@ -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 . # +# # +#############################################################################*/ + +#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 */