]> git.ipfire.org Git - collecty.git/commitdiff
sources: Add source for wireless interface stats
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 29 May 2026 08:41:59 +0000 (08:41 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 29 May 2026 08:41:59 +0000 (08:41 +0000)
This is unfinished, but I currently cannot work on this.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
configure.ac
src/daemon/sources.c
src/daemon/sources/wireless.c [new file with mode: 0644]
src/daemon/sources/wireless.h [new file with mode: 0644]

index cf35ce174bebe28d7a9b98634ce9a69ee3ccc68e..fccdcb16178c7c611b896eae4ec5a9e4d714d2ba 100644 (file)
@@ -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 \
index 03849b5f359f92f6c13d18900e55004666b49e1c..863c9c56559d8dbabdd4220678a1d2ab57c3326c 100644 (file)
@@ -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}
 ])
index 81d93d05ec34d01bd6cfb286fb1c2c26517a33ae..0dfb0fab77f5835f119bbc21308f639625670a03 100644 (file)
@@ -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 (file)
index 0000000..d116a76
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.       #
+#                                                                             #
+#############################################################################*/
+
+#ifdef BUILD_SOURCE_WIRELESS
+
+#include <errno.h>
+
+#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 (file)
index 0000000..ab0a69d
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.       #
+#                                                                             #
+#############################################################################*/
+
+#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 */