]> git.ipfire.org Git - telemetry.git/commitdiff
graphs: Add a graph to show rate information
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 21 Oct 2025 14:10:10 +0000 (14:10 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 21 Oct 2025 14:10:10 +0000 (14:10 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
src/daemon/graphs.c
src/daemon/graphs/hostapd-station-rate-info.c [new file with mode: 0644]
src/daemon/graphs/hostapd-station-rate-info.h [new file with mode: 0644]

index 005ffd61d4c99c09d765033c4fe12eb0d0c1c6ee..071b2888cbfdd5a69b86cc9ec4c91b0be5e0c514 100644 (file)
@@ -119,6 +119,8 @@ dist_telemetryd_SOURCES = \
        src/daemon/graphs/graph.h \
        src/daemon/graphs/hostapd-station-bandwidth.c \
        src/daemon/graphs/hostapd-station-bandwidth.h \
+       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/loadavg.c \
index a101c91f431c9002b83c6a5b48e15cbfc01f0b87..829a11c9b2d01985b368180eb5fb8eacc859ca3b 100644 (file)
@@ -31,6 +31,7 @@
 #include "graphs/conntrack.h"
 #include "graphs/contextswitches.h"
 #include "graphs/hostapd-station-bandwidth.h"
+#include "graphs/hostapd-station-rate-info.h"
 #include "graphs/hostapd-station-signal.h"
 #include "graphs/loadavg.h"
 #include "graphs/memory.h"
@@ -42,6 +43,7 @@ static const td_graph_impl* graph_impls[] = {
        &conntrack_graph,
        &contextswitches_graph,
        &hostapd_station_bandwidth_graph,
+       &hostapd_station_rate_info_graph,
        &hostapd_station_signal_graph,
        &loadavg_graph,
        &memory_graph,
diff --git a/src/daemon/graphs/hostapd-station-rate-info.c b/src/daemon/graphs/hostapd-station-rate-info.c
new file mode 100644 (file)
index 0000000..a94c93f
--- /dev/null
@@ -0,0 +1,69 @@
+/*#############################################################################
+#                                                                             #
+# 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 "../string.h"
+#include "graph.h"
+#include "hostapd-station-rate-info.h"
+
+static int hostapd_station_rate_info_title(td_ctx* ctx, td_graph* graph,
+               const char* object, char* title, size_t length) {
+       return __td_string_format(title, length, _("Station %s - Rate Information"), object);
+}
+
+static int hostapd_station_rate_info_vlabel(td_ctx* ctx, td_graph* graph,
+               const char* object, char* vlabel, size_t length) {
+       return __td_string_set(vlabel, length, _("Bits Per Second"));
+}
+
+static int hostapd_station_rate_info_render(td_ctx* ctx,
+               td_graph* graph, td_args* args, const char* object) {
+       int r;
+
+       // Require the source
+       r = td_graph_require_source(graph, args, "hostapd", object);
+       if (r < 0)
+               return r;
+
+       // Header
+       PRINT_HEADER4(args, _("Current"), _("Average"), _("Minimum"), _("Maximum"));
+
+       // Receive Rate
+       DRAW_LINE2_WITH_LABEL(args, "rx_rate", object, GREEN, _("Receive Rate"));
+       PRINT_CAMM(args, "rx_rate", object, BPS, _("Bps"));
+
+       // Transmit Rate
+       DRAW_LINE2_WITH_LABEL(args, "tx_rate", object, RED, _("Transmit Rate"));
+       PRINT_CAMM(args, "tx_rate", object, BPS, _("Bps"));
+
+       return 0;
+}
+
+const td_graph_impl hostapd_station_rate_info_graph = {
+       .name    = "HostapdStationRateInfo",
+       .render  = hostapd_station_rate_info_render,
+       .title   = hostapd_station_rate_info_title,
+       .vlabel  = hostapd_station_rate_info_vlabel,
+
+       // Limits
+       .lower_limit = 0,
+       .upper_limit = LONG_MAX,
+};
diff --git a/src/daemon/graphs/hostapd-station-rate-info.h b/src/daemon/graphs/hostapd-station-rate-info.h
new file mode 100644 (file)
index 0000000..087c787
--- /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_HOSTAPD_STATION_RATE_INFO_H
+#define TELEMETRY_GRAPH_HOSTAPD_STATION_RATE_INFO_H
+
+#include "../graph.h"
+
+extern const td_graph_impl hostapd_station_rate_info_graph;
+
+#endif /* TELEMETRY_GRAPH_HOSTAPD_STATION_RATE_INFO_H */