src/daemon/graphs/contextswitches.c \
src/daemon/graphs/contextswitches.h \
src/daemon/graphs/graph.h \
+ src/daemon/graphs/hostapd-station-bandwidth.c \
+ src/daemon/graphs/hostapd-station-bandwidth.h \
src/daemon/graphs/hostapd-station-signal.c \
src/daemon/graphs/hostapd-station-signal.h \
src/daemon/graphs/loadavg.c \
// Load all graphs
#include "graphs/conntrack.h"
#include "graphs/contextswitches.h"
+#include "graphs/hostapd-station-bandwidth.h"
#include "graphs/hostapd-station-signal.h"
#include "graphs/loadavg.h"
#include "graphs/memory.h"
static const td_graph_impl* graph_impls[] = {
&conntrack_graph,
&contextswitches_graph,
+ &hostapd_station_bandwidth_graph,
&hostapd_station_signal_graph,
&loadavg_graph,
&memory_graph,
#define FLOAT "%%14.2lf"
#define FLOAT_WITH_UNIT "%%10.2lf %3s"
#define LARGE_FLOAT "%%14.2lf %%s"
+#define BPS "%%9.2lf %%s%3s"
// Macro to terminate a line
#define EOL "\\j"
#define FIELD_PERCENT(field) field "_p"
#define FIELD_INF(field) field "_inf"
#define FIELD_NEGINF(field) field "_neginf"
+#define FIELD_BITS(field) field "_bits"
#define VALUE_CURRENT(args, field, object) SCRIPT(args, "VDEF:" FIELD_CURRENT(FIELD) "=" FIELD ",LAST", FIELD_AND_OBJECT(field, object), FIELD_AND_OBJECT(field, object))
#define VALUE_AVERAGE(args, field, object) SCRIPT(args, "VDEF:" FIELD_AVERAGE(FIELD) "=" FIELD ",AVERAGE", FIELD_AND_OBJECT(field, object), FIELD_AND_OBJECT(field, object))
VALUE_ALL(args, difference, object); \
} while (0)
+#define COMPUTE_MULTIPLY(args, product, object1, factor1, object2, factor2) \
+ do { \
+ COMPUTE_CDEF(args, FIELD "=" FIELD "," TOSTRING(factor2) ",*", \
+ FIELD_AND_OBJECT(product, object1), \
+ FIELD_AND_OBJECT(factor1, object2) \
+ ); \
+ VALUE_ALL(args, product, object1); \
+ } while (0)
+
+// Converts bytes to bits
+#define COMPUTE_BITS(args, bits, object, bytes) \
+ COMPUTE_MULTIPLY(args, bits, object, bytes, object, 8)
+
#define COMPUTE_DIVIDE(args, fraction, object1, dividend, object2, divisor) \
do { \
COMPUTE_CDEF(args, FIELD "=" FIELD "," TOSTRING(divisor) ",/", \
); \
} while (0)
+/*
+ This draws a bandwidth graph
+*/
+#define DRAW_BANDWIDTH(args, object, rx_bytes, tx_bytes) \
+ do { \
+ DRAW_BANDWIDTH_INCOMING(args, object, rx_bytes); \
+ DRAW_BANDWIDTH_OUTGOING(args, object, tx_bytes); \
+ } while (0)
+
+#define DRAW_BANDWIDTH_INCOMING(args, object, rx_bytes) \
+ __DRAW_BANDWIDTH(args, object, rx_bytes, GREEN, _("Incoming Traffic"))
+
+#define DRAW_BANDWIDTH_OUTGOING(args, object, tx_bytes) \
+ __DRAW_BANDWIDTH(args, object, tx_bytes, RED, _("Outgoing Traffic"))
+
+#define __DRAW_BANDWIDTH(args, object, bytes, color, label) \
+ do { \
+ COMPUTE_BITS(args, FIELD_BITS(bytes), object, bytes); \
+ DRAW_AREA_WITH_LABEL(args, FIELD_BITS(bytes), object, color, label); \
+ PRINT_CAMM(args, bytes, object, BPS, _("Bps")); \
+ } while (0)
+
#endif /* TELEMETRY_GRAPHS_GRAPH_H */
--- /dev/null
+/*#############################################################################
+# #
+# 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-bandwidth.h"
+
+static int hostapd_station_bandwidth_title(td_ctx* ctx, td_graph* graph,
+ const char* object, char* title, size_t length) {
+ return __td_string_format(title, length, _("Station %s - Bandwidth"), object);
+}
+
+static int hostapd_station_bandwidth_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_bandwidth_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"));
+
+ // Draw the bandwidth graph
+ DRAW_BANDWIDTH(args, object, "rx_bytes", "tx_bytes");
+
+ return 0;
+}
+
+const td_graph_impl hostapd_station_bandwidth_graph = {
+ .name = "HostapdStationBandwidth",
+ .render = hostapd_station_bandwidth_render,
+ .title = hostapd_station_bandwidth_title,
+ .vlabel = hostapd_station_bandwidth_vlabel,
+
+ // Limits
+ .lower_limit = 0,
+ .upper_limit = LONG_MAX,
+};
--- /dev/null
+/*#############################################################################
+# #
+# 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_BANDWIDTH_H
+#define TELEMETRY_GRAPH_HOSTAPD_STATION_BANDWIDTH_H
+
+#include "../graph.h"
+
+extern const td_graph_impl hostapd_station_bandwidth_graph;
+
+#endif /* TELEMETRY_GRAPH_HOSTAPD_STATION_BANDWIDTH_H */