From: Michael Tremer Date: Thu, 2 Oct 2025 10:08:25 +0000 (+0000) Subject: graph: Fix calling rrd_graph() X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=13e42e72ac31c78bb8f42cddfc93c25619f04d85;p=collecty.git graph: Fix calling rrd_graph() There is pretty much no documenation of librrd and the API has been changed multiple times. Initially, various arguments have been labeled optional, but that does not seem to be true for at least the implementation I am testing against. So we pass all variables that we function has, and we might as well include them in the debugging output. Signed-off-by: Michael Tremer --- diff --git a/src/daemon/graph.c b/src/daemon/graph.c index 3b6b076..d798937 100644 --- a/src/daemon/graph.c +++ b/src/daemon/graph.c @@ -146,9 +146,12 @@ ERROR: int collecty_graph_render(collecty_graph* self, const char* object, char** buffer, size_t* length) { collecty_args* args = NULL; + char** data = NULL; FILE* f = NULL; int w = 0; int h = 0; + double ymin = 0; + double ymax = 0; int r; // Log action @@ -183,7 +186,7 @@ int collecty_graph_render(collecty_graph* self, // Render the graph r = rrd_graph(collecty_args_argc(args), (char**)collecty_args_argv(args), - NULL, &w, &h, f, NULL, NULL); + &data, &w, &h, f, &ymin, &ymax); if (r < 0) { ERROR(self->ctx, "Failed to generate the graph: %s\n", rrd_get_error()); rrd_clear_error(); @@ -193,10 +196,23 @@ int collecty_graph_render(collecty_graph* self, // Log action DEBUG(self->ctx, "Rendered graph %s:\n", collecty_graph_get_name(self)); - DEBUG(self->ctx, " Width : %d\n", w); - DEBUG(self->ctx, " Height : %d\n", h); + DEBUG(self->ctx, " width : %d\n", w); + DEBUG(self->ctx, " height : %d\n", h); + DEBUG(self->ctx, " ymin : %.2f\n", ymin); + DEBUG(self->ctx, " ymax : %.2f\n", ymax); + + // Print all content of the data array + if (data) { + for (unsigned int i = 0; data[i]; i++) + DEBUG(self->ctx, " data[%2d]: %s\n", i, data[i]); + } ERROR: + if (data) { + for (unsigned int i = 0; data[i]; i++) + free(data[i]); + free(data); + } if (args) collecty_args_unref(args); if (f)