]> git.ipfire.org Git - collecty.git/commitdiff
daemon: Add a basic dbus interfaces for graphs
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 29 Sep 2025 17:03:47 +0000 (17:03 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 29 Sep 2025 17:03:47 +0000 (17:03 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
src/daemon/daemon.c
src/daemon/graph-bus.c [new file with mode: 0644]
src/daemon/graph-bus.h [new file with mode: 0644]

index 01bd52f8b660f44231867a41bcc519eec1842c90..e03cbdb15b1b9286f4143f6bddc857675b8b8825 100644 (file)
@@ -98,6 +98,8 @@ dist_collectyd_SOURCES = \
        src/daemon/ctx.h \
        src/daemon/daemon.c \
        src/daemon/daemon.h \
+       src/daemon/graph-bus.c \
+       src/daemon/graph-bus.h \
        src/daemon/logging.c \
        src/daemon/logging.h \
        src/daemon/main.c \
index 34eec36268a20cd59e2dc3001fa6a59277421bf6..bb3358fca66c9608b4327a2f584e65c60cb0e2e7 100644 (file)
@@ -28,6 +28,7 @@
 #include "bus.h"
 #include "ctx.h"
 #include "daemon.h"
+#include "graph-bus.h"
 #include "module.h"
 #include "modules.h"
 #include "queue.h"
@@ -258,4 +259,5 @@ const collecty_bus_implementation daemon_bus_impl = {
        .path = "/org/ipfire/collecty1",
        .interface = "org.ipfire.collecty1",
        .vtables = BUS_VTABLES(daemon_vtable),
+       .children = BUS_IMPLEMENTATIONS(&collecty_graph_bus_impl),
 };
diff --git a/src/daemon/graph-bus.c b/src/daemon/graph-bus.c
new file mode 100644 (file)
index 0000000..156498e
--- /dev/null
@@ -0,0 +1,73 @@
+/*#############################################################################
+#                                                                             #
+# collecty - A system statistics collection daemon for IPFire                 #
+# 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 <systemd/sd-bus.h>
+
+#include "graph-bus.h"
+
+static int collecty_graph_node_enumerator(sd_bus* bus,
+               const char* path, void* data, char*** nodes, sd_bus_error* error) {
+       //collecty_daemon* daemon = data;
+
+       // XXX TODO
+
+       return 0;
+}
+
+static int collecty_graph_object_find(sd_bus* bus, const char* path,
+               const char* interface, void* data, void** found, sd_bus_error* error) {
+#if 0
+       collecty_daemon* daemon = data;
+       collecty_graph* graph = NULL;
+       char* name = NULL;
+       int r;
+
+       // Decode the path of the requested object
+       r = sd_bus_path_decode(path, "/org/ipfire/collecty1/graph", &name);
+       if (r <= 0)
+               return 0;
+
+       // Find the graph
+       graph = collecty_daemon_get_graph_by_name(daemon, name);
+       if (!graph)
+               return 0;
+
+       // Match!
+       *found = collecy_graph_unref(graph);
+#endif
+
+       return 1;
+}
+
+static const sd_bus_vtable collecty_graph_vtable[] = {
+       SD_BUS_VTABLE_START(0),
+
+       // Operations
+       //XXX TODO
+
+       SD_BUS_VTABLE_END
+};
+
+const collecty_bus_implementation collecty_graph_bus_impl = {
+       "/org/ipfire/collecty1/graph",
+       "org.ipfire.collecty1.Graph",
+       .fallback_vtables = BUS_FALLBACK_VTABLES({collecty_graph_vtable, collecty_graph_object_find}),
+       .node_enumerator = collecty_graph_node_enumerator,
+};
diff --git a/src/daemon/graph-bus.h b/src/daemon/graph-bus.h
new file mode 100644 (file)
index 0000000..5761b0c
--- /dev/null
@@ -0,0 +1,28 @@
+/*#############################################################################
+#                                                                             #
+# collecty - A system statistics collection daemon for IPFire                 #
+# 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 COLLECTY_GRAPH_BUS_H
+#define COLLECTY_GRAPH_BUS_H
+
+#include "bus.h"
+
+extern const collecty_bus_implementation collecty_graph_bus_impl;
+
+#endif /* COLLECTY_GRAPH_BUS_H */