From: Michael Tremer Date: Sat, 29 Nov 2025 12:46:10 +0000 (+0000) Subject: interface: Add an interface throughput graph X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=89363e370a928230df41c3b1a5b7430cefb72762;p=telemetry.git interface: Add an interface throughput graph Signed-off-by: Michael Tremer --- diff --git a/Makefile.am b/Makefile.am index 923405c..393be43 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 \ diff --git a/src/daemon/graphs.c b/src/daemon/graphs.c index c61dfeb..3ca2b54 100644 --- a/src/daemon/graphs.c +++ b/src/daemon/graphs.c @@ -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 index 0000000..526c641 --- /dev/null +++ b/src/daemon/graphs/interface-throughput.c @@ -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 . # +# # +#############################################################################*/ + +#include + +#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 index 0000000..40c6061 --- /dev/null +++ b/src/daemon/graphs/interface-throughput.h @@ -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 . # +# # +#############################################################################*/ + +#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 */