]> git.ipfire.org Git - telemetry.git/commitdiff
graphs: Create a graph for interface packets
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 3 Dec 2025 13:42:17 +0000 (13:42 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 3 Dec 2025 13:42:35 +0000 (13:42 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
po/POTFILES.in
po/telemetry.pot
src/daemon/graph.c
src/daemon/graph.h
src/daemon/graphs.c
src/daemon/graphs/graph.h
src/daemon/graphs/interface-packets.c [new file with mode: 0644]
src/daemon/graphs/interface-packets.h [new file with mode: 0644]

index 2a2601e5c65516d513b0594c0c46621eb5b63c2c..6171b7934786ab5d491a2f5e3b2200e102671ceb 100644 (file)
@@ -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 \
index f6a266b86f44568fc7d016e8974250aa2f3fabae..d82ce1e4653f4da889dffc434fa3c4991d503258 100644 (file)
@@ -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
index 10a33364d5b6c64f9cfb6e81d9b22883bbbf742d..e195236fa758aedbca154b24e8ecceb77164cb7e 100644 (file)
@@ -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 <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\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 ""
index f9c6a517c1ab1e6b631d95d054aa672207741242..cfbe998eb99334740384d450c1e136f05e85df30 100644 (file)
@@ -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"));
index 76f5debd43936e44e51fd7cc3bf65b6dbb35dfef..cdc412326bdca475f66c90dd710a916a588470ae 100644 (file)
@@ -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);
 
index 5d4901e5722e57ec7e2eb4941ea02f8b71976a9b..b13bfd5979ee78e3a133775b346c5bbc41c019f6 100644 (file)
@@ -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,
index 88a0800dc2237b967521d52aea8872b35166ea60..3fe4735f66575c7ef43aeedeb946fe36f6eb6be3 100644 (file)
@@ -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 (file)
index 0000000..1140401
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.       #
+#                                                                             #
+#############################################################################*/
+
+#include <limits.h>
+
+#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 (file)
index 0000000..e4b0e92
--- /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_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 */