From: Michael Tremer Date: Tue, 21 Oct 2025 14:10:10 +0000 (+0000) Subject: graphs: Add a graph to show rate information X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=21c3787494dc0a18a246366c4c0b2adb0b2252fe;p=telemetry.git graphs: Add a graph to show rate information Signed-off-by: Michael Tremer --- diff --git a/Makefile.am b/Makefile.am index 005ffd6..071b288 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 \ diff --git a/src/daemon/graphs.c b/src/daemon/graphs.c index a101c91..829a11c 100644 --- a/src/daemon/graphs.c +++ b/src/daemon/graphs.c @@ -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 index 0000000..a94c93f --- /dev/null +++ b/src/daemon/graphs/hostapd-station-rate-info.c @@ -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 . # +# # +#############################################################################*/ + +#include + +#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 index 0000000..087c787 --- /dev/null +++ b/src/daemon/graphs/hostapd-station-rate-info.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_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 */