From: Michael Tremer Date: Fri, 29 May 2026 08:41:59 +0000 (+0000) Subject: sources: Add source for wireless interface stats X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=85e3f8618028de8866bcbeed6e2d16748db56490;p=telemetry.git sources: Add source for wireless interface stats This is unfinished, but I currently cannot work on this. Signed-off-by: Michael Tremer --- diff --git a/Makefile.am b/Makefile.am index cf35ce1..fccdcb1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -240,6 +240,8 @@ dist_telemetryd_SOURCES = \ src/daemon/sources/unbound.h \ src/daemon/sources/uptime.c \ src/daemon/sources/uptime.h \ + src/daemon/sources/wireless.c \ + src/daemon/sources/wireless.h \ src/daemon/string.h \ src/daemon/time.c \ src/daemon/time.h \ diff --git a/configure.ac b/configure.ac index 03849b5..863c9c5 100644 --- a/configure.ac +++ b/configure.ac @@ -241,6 +241,7 @@ AC_SOURCE([softirq]) AC_SOURCE([suricata]) AC_SOURCE([unbound]) AC_SOURCE([uptime]) +AC_SOURCE([wireless], [$have_libnl3 $have_libnl3_genl $have_libnl3_route]) # ------------------------------------------------------------------------------ have_manpages=no @@ -355,4 +356,5 @@ AC_MSG_RESULT([ suricata: ${build_source_suricata} unbound: ${build_source_unbound} uptime: ${build_source_uptime} + wireless: ${build_source_wireless} ]) diff --git a/src/daemon/sources.c b/src/daemon/sources.c index 81d93d0..0dfb0fa 100644 --- a/src/daemon/sources.c +++ b/src/daemon/sources.c @@ -52,6 +52,7 @@ #include "sources/suricata.h" #include "sources/unbound.h" #include "sources/uptime.h" +#include "sources/wireless.h" // Load test sources #if ENABLE_TESTS @@ -159,6 +160,10 @@ static const td_source_impl* source_impls[] = { &uptime_source, #endif /* BUILD_SOURCE_UPTIME */ +#ifdef BUILD_SOURCE_WIRELESS + &wireless_source, +#endif /* BUILD_SOURCE_WIRELESS */ + #if ENABLE_TESTS // Tests &test_error_source, diff --git a/src/daemon/sources/wireless.c b/src/daemon/sources/wireless.c new file mode 100644 index 0000000..d116a76 --- /dev/null +++ b/src/daemon/sources/wireless.c @@ -0,0 +1,77 @@ +/*############################################################################# +# # +# telemetryd - The IPFire Telemetry Collection Service # +# Copyright (C) 2026 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 . # +# # +#############################################################################*/ + +#ifdef BUILD_SOURCE_WIRELESS + +#include + +#include "../ctx.h" +#include "../source.h" +#include "wireless.h" + +static int wireless_link_callback(td_ctx* ctx, const char* name, + struct rtnl_link* link, void* data) { + td_source* source = data; + + DEBUG(ctx, "Wireless interface callback fired for %s\n", name); + +#warning TODO I currently don't have access to wireless hardware to test this + + return 0; +} + +static int wireless_heartbeat(td_ctx* ctx, td_source* source) { + td_netlink* netlink = NULL; + int r; + + // Fetch access to Netlink + netlink = td_source_get_netlink(source); + if (!netlink) { + r = -errno; + goto ERROR; + } + + // Enumerate all wireless interfaces + r = td_netlink_enumerate_wireless_interfaces( + netlink, wireless_link_callback, source); + if (r < 0) + goto ERROR; + +ERROR: + if (netlink) + td_netlink_unref(netlink); + + return r; +} + +const td_source_impl wireless_source = { + .name = "wireless", + + // RRD Data Sources + .rrd_dss = { + { "uptime", "GAUGE", 0, -1, }, + { NULL }, + }, + + // Methods + .heartbeat = wireless_heartbeat, +}; + +#endif /* BUILD_SOURCE_WIRELESS */ diff --git a/src/daemon/sources/wireless.h b/src/daemon/sources/wireless.h new file mode 100644 index 0000000..ab0a69d --- /dev/null +++ b/src/daemon/sources/wireless.h @@ -0,0 +1,30 @@ +/*############################################################################# +# # +# telemetryd - The IPFire Telemetry Collection Service # +# Copyright (C) 2026 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_SOURCE_WIRELESS_H +#define TELEMETRY_SOURCE_WIRELESS_H +#ifdef BUILD_SOURCE_WIRELESS + +#include "../source.h" + +extern const td_source_impl wireless_source; + +#endif /* BUILD_SOURCE_WIRELESS */ +#endif /* TELEMETRY_SOURCE_WIRELESS_H */