From: Michael Tremer Date: Wed, 3 Dec 2025 13:42:17 +0000 (+0000) Subject: graphs: Create a graph for interface packets X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a971b43dec222d34ca8edd4805ce6e9a2c5001c5;p=people%2Fms%2Ftelemetry.git graphs: Create a graph for interface packets Signed-off-by: Michael Tremer --- diff --git a/Makefile.am b/Makefile.am index 2a2601e..6171b79 100644 --- a/Makefile.am +++ b/Makefile.am @@ -128,6 +128,8 @@ dist_telemetryd_SOURCES = \ src/daemon/graphs/hostapd-station-signal.h \ src/daemon/graphs/interface-throughput.c \ src/daemon/graphs/interface-throughput.h \ + src/daemon/graphs/interface-packets.c \ + src/daemon/graphs/interface-packets.h \ src/daemon/graphs/legacy-gateway-latency4.c \ src/daemon/graphs/legacy-gateway-latency4.h \ src/daemon/graphs/legacy-suricata.c \ diff --git a/po/POTFILES.in b/po/POTFILES.in index f6a266b..d82ce1e 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -35,6 +35,8 @@ src/daemon/graphs/hostapd-station-rate-info.c 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-packets.c +src/daemon/graphs/interface-packets.h src/daemon/graphs/interface-throughput.c src/daemon/graphs/interface-throughput.h src/daemon/graphs/legacy-gateway-latency4.c diff --git a/po/telemetry.pot b/po/telemetry.pot index 10a3336..e195236 100644 --- a/po/telemetry.pot +++ b/po/telemetry.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-12-03 13:27+0000\n" +"POT-Creation-Date: 2025-12-03 13:41+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -29,6 +29,9 @@ msgstr "" msgid "Objects" msgstr "" +msgid "Packets Per Second" +msgstr "" + msgid "Queries Per Second" msgstr "" @@ -99,6 +102,9 @@ msgstr "" msgid "bps" msgstr "" +msgid "pps" +msgstr "" + msgid "qps" msgstr "" @@ -117,6 +123,12 @@ msgstr "" msgid "Outgoing Traffic" msgstr "" +msgid "Received Packets" +msgstr "" + +msgid "Sent Packets" +msgstr "" + #, c-format msgid "Station %s - Bandwidth" msgstr "" @@ -151,6 +163,10 @@ msgstr "" msgid "Last ACK Signal" msgstr "" +#, c-format +msgid "Packets - %s" +msgstr "" + #, c-format msgid "Throughput - %s" msgstr "" diff --git a/src/daemon/graph.c b/src/daemon/graph.c index f9c6a51..cfbe998 100644 --- a/src/daemon/graph.c +++ b/src/daemon/graph.c @@ -565,6 +565,11 @@ int td_graph_vlabel_objects(td_ctx* ctx, td_graph* graph, return __td_string_set(vlabel, length, _("Objects")); } +int td_graph_vlabel_pps(td_ctx* ctx, td_graph* graph, + const td_graph_render_options* options, const char* object, char* vlabel, size_t length) { + return __td_string_set(vlabel, length, _("Packets Per Second")); +} + int td_graph_vlabel_qps(td_ctx* ctx, td_graph* graph, const td_graph_render_options* options, const char* object, char* vlabel, size_t length) { return __td_string_set(vlabel, length, _("Queries Per Second")); diff --git a/src/daemon/graph.h b/src/daemon/graph.h index 76f5deb..cdc4123 100644 --- a/src/daemon/graph.h +++ b/src/daemon/graph.h @@ -129,6 +129,9 @@ int td_graph_vlabel_days(td_ctx* ctx, td_graph* graph, int td_graph_vlabel_objects(td_ctx* ctx, td_graph* graph, const td_graph_render_options* options, const char* object, char* vlabel, size_t length); +int td_graph_vlabel_pps(td_ctx* ctx, td_graph* graph, + const td_graph_render_options* options, const char* object, char* vlabel, size_t length); + int td_graph_vlabel_qps(td_ctx* ctx, td_graph* graph, const td_graph_render_options* options, const char* object, char* vlabel, size_t length); diff --git a/src/daemon/graphs.c b/src/daemon/graphs.c index 5d4901e..b13bfd5 100644 --- a/src/daemon/graphs.c +++ b/src/daemon/graphs.c @@ -36,6 +36,7 @@ #include "graphs/hostapd-station-rate-info.h" #include "graphs/hostapd-station-signal.h" #include "graphs/interface-throughput.h" +#include "graphs/interface-packets.h" #include "graphs/loadavg.h" #include "graphs/memory.h" #include "graphs/pressure.h" @@ -69,6 +70,7 @@ static const td_graph_impl* graph_impls[] = { // Interfaces &interface_throughput_graph, + &interface_packets_graph, // Pressure (PSI) &pressure_cpu_graph, diff --git a/src/daemon/graphs/graph.h b/src/daemon/graphs/graph.h index 88a0800..3fe4735 100644 --- a/src/daemon/graphs/graph.h +++ b/src/daemon/graphs/graph.h @@ -69,6 +69,7 @@ typedef enum flags { #define FLOAT_WITH_UNIT "%%10.2lf %3s" #define LARGE_FLOAT "%%14.2lf %%s" #define BPS "%%9.2lf %%s%3s", _("bps") +#define PPS "%%14.2lf %3s", _("pps") #define QPS "%%14.2lf %3s", _("qps") #define HZ "%%10.2lf %%s%2s", _("Hz") #define SECONDS_HIGHRES "%%12.2lf%%ss" @@ -433,6 +434,27 @@ static inline int __DRAW(td_args* args, const char* what, const char* field, PRINT_CAMM(args, bytes, object, BPS); \ } while (0) +/* + This draws a packets graph +*/ +#define DRAW_PACKETS(args, object, rx_packets, tx_packets) \ + do { \ + DRAW_PACKETS_RX(args, object, rx_packets); \ + DRAW_PACKETS_TX(args, object, tx_packets); \ + } while (0) + +#define DRAW_PACKETS_RX(args, object, rx_packets) \ + __DRAW_PACKETS(args, object, rx_packets, COLOR_RX, "%s", _("Received Packets")) + +#define DRAW_PACKETS_TX(args, object, tx_packets) \ + __DRAW_PACKETS(args, object, tx_packets, COLOR_TX, "%s", _("Sent Packets")) + +#define __DRAW_PACKETS(args, object, packets, color, label, ...) \ + do { \ + DRAW_AREA_WITH_LABEL(args, packets, object, color, 0, label, __VA_ARGS__); \ + PRINT_CAMM(args, packets, object, PPS); \ + } while (0) + /* This draws a temperature graph */ diff --git a/src/daemon/graphs/interface-packets.c b/src/daemon/graphs/interface-packets.c new file mode 100644 index 0000000..1140401 --- /dev/null +++ b/src/daemon/graphs/interface-packets.c @@ -0,0 +1,58 @@ +/*############################################################################# +# # +# 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 "graph.h" +#include "interface-packets.h" + +static int interface_packets_title(td_ctx* ctx, td_graph* graph, + const char* object, char* title, size_t length) { + return __td_string_format(title, length, _("Packets - %s"), object); +} + +static int interface_packets_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, "interface", object); + if (r < 0) + return r; + + // Header + PRINT_HEADER4(args, _("Current"), _("Average"), _("Minimum"), _("Maximum")); + + // Draw the packets + DRAW_PACKETS(args, object, "rx_packets", "tx_packets"); + + return 0; +} + +const td_graph_impl interface_packets_graph = { + .name = "InterfacePackets", + .render = interface_packets_render, + .title = interface_packets_title, + .vlabel = td_graph_vlabel_pps, + + // Limits + .lower_limit = 0, + .upper_limit = LONG_MAX, +}; diff --git a/src/daemon/graphs/interface-packets.h b/src/daemon/graphs/interface-packets.h new file mode 100644 index 0000000..e4b0e92 --- /dev/null +++ b/src/daemon/graphs/interface-packets.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_PACKETS_H +#define TELEMETRY_GRAPH_INTERFACE_PACKETS_H + +#include "../graph.h" + +extern const td_graph_impl interface_packets_graph; + +#endif /* TELEMETRY_GRAPH_INTERFACE_PACKETS_H */