]> git.ipfire.org Git - telemetry.git/commitdiff
sources: Pass the source itself to the init function
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 28 Nov 2025 17:34:52 +0000 (17:34 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 28 Nov 2025 17:34:52 +0000 (17:34 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/daemon/source.c
src/daemon/source.h
src/daemon/sources/contextswitches.c
src/daemon/sources/interfaces.c
src/daemon/sources/nftables.c

index d1f645e7504ba2b4e2d0afb32a96b8fe093bca4a..6cbbe2ea3466022f1a53d8663e360caade166c85 100644 (file)
@@ -385,7 +385,7 @@ static int td_source_init(td_source* self) {
                return 0;
 
        // Initialize the source
-       r = self->impl->init(self->ctx);
+       r = self->impl->init(self->ctx, self);
        if (r < 0) {
                ERROR(self->ctx, "Failed to initialize %s: %s\n",
                        td_source_name(self), strerror(-r));
index 4696d7e877a21712faca8961527c0113677452fd..e66b881241efaea8b0d44cdbf5ba18d4df4d88d1 100644 (file)
@@ -65,7 +65,7 @@ typedef struct td_source_impl {
        td_rrd_rra rrd_rras[MAX_RRA];
 
        // Init
-       int (*init)(td_ctx* ctx);
+       int (*init)(td_ctx* ctx, td_source* source);
 
        // Free
        int (*free)(td_ctx* ctx);
index 9053ce18e879705afda7867c6c9cf08c5d34f88b..92a5122c81d2b262179c4dcf769bee3496084447 100644 (file)
@@ -36,7 +36,7 @@ static int perf_event_open(struct perf_event_attr* hw_event,
 static unsigned int num_cpus = 0;
 static int* perf_eventfds = NULL;
 
-static int contextswitches_init(td_ctx* ctx) {
+static int contextswitches_init(td_ctx* ctx, td_source* source) {
        struct perf_event_attr event = {
                .type     = PERF_TYPE_SOFTWARE,
                .config   = PERF_COUNT_SW_CONTEXT_SWITCHES,
index f4ea08c37d9724c640cf893970063e3f2dfd36fb..263f990c1c3d25f47ab763e32cd74dbc8f6ba3cd 100644 (file)
@@ -41,7 +41,7 @@ typedef struct interfaces_stats {
        rtnl_link_stat_id_t id;
 }  interfaces_stats;
 
-static int interfaces_init(td_ctx* ctx) {
+static int interfaces_init(td_ctx* ctx, td_source* source) {
        int r;
 
        // Don't open the socket again
index 765d9d7289fb7761fb4d7e7c5aad7ca705fef2e8..aabfe53bde3d29b065b19afc655a4bdbaf0e2fed 100644 (file)
@@ -55,7 +55,7 @@ typedef struct nftables_comments {
        unsigned int num_comments;
 } nftables_comments;
 
-static int nftables_init(td_ctx* ctx) {
+static int nftables_init(td_ctx* ctx, td_source* source) {
        int r;
 
        // Don't create another socket if one is already open