From: Michael Tremer Date: Mon, 29 Sep 2025 17:03:47 +0000 (+0000) Subject: daemon: Add a basic dbus interfaces for graphs X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=aebc8ca29e28a64e945d539813fe0bdea08a9af1;p=collecty.git daemon: Add a basic dbus interfaces for graphs Signed-off-by: Michael Tremer --- diff --git a/Makefile.am b/Makefile.am index 01bd52f..e03cbdb 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 \ diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c index 34eec36..bb3358f 100644 --- a/src/daemon/daemon.c +++ b/src/daemon/daemon.c @@ -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 index 0000000..156498e --- /dev/null +++ b/src/daemon/graph-bus.c @@ -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 . # +# # +#############################################################################*/ + +#include + +#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 index 0000000..5761b0c --- /dev/null +++ b/src/daemon/graph-bus.h @@ -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 . # +# # +#############################################################################*/ + +#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 */