From 5d23b99d24806a53f8b8b16d662cac245fbf1c3e Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Thu, 4 Dec 2025 16:54:50 +0000 Subject: [PATCH] graph: Show the hostname at the bottom of the image Signed-off-by: Michael Tremer --- src/daemon/graph.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/daemon/graph.c b/src/daemon/graph.c index cfbe998..4d9b008 100644 --- a/src/daemon/graph.c +++ b/src/daemon/graph.c @@ -22,6 +22,7 @@ #include #include #include +#include #include @@ -83,9 +84,6 @@ const char* DEFAULT_RENDER_ARGS[] = { // Show nicer labels "--dynamic-labels", - // Add a watermark - "--watermark=" PACKAGE_NAME, - // Honour upper/lower limit "--rigid", @@ -284,6 +282,7 @@ static void td_graph_reset_locale(td_ctx* ctx, char* locale) { int td_graph_render(td_graph* self, const char* object, const td_graph_render_options* options, char** buffer, size_t* length) { td_args* args = NULL; + char hostname[HOST_NAME_MAX] = ""; char vlabel[VLABEL_MAX] = ""; char** data = NULL; FILE* f = NULL; @@ -343,6 +342,19 @@ int td_graph_render(td_graph* self, const char* object, if (r < 0) goto ERROR; + // Fetch the system's hostname + r = gethostname(hostname, sizeof(hostname)); + if (r < 0) { + ERROR(self->ctx, "Failed to fetch the hostname: %m\n"); + r = -errno; + goto ERROR; + } + + // Add a watermark + r = td_args_push(args, "--watermark=%s - %s", PACKAGE_NAME, hostname); + if (r < 0) + goto ERROR; + // Select the output format if (options->format) { r = td_args_push(args, "--imgformat=%s", options->format); -- 2.47.3