From: Michael Tremer Date: Thu, 30 Oct 2025 21:56:33 +0000 (+0000) Subject: graphs: unbound: Add recursion time graph X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=afcc7f814d0fd1f4c7567943d206d0b4558ecaa4;p=collecty.git graphs: unbound: Add recursion time graph Signed-off-by: Michael Tremer --- diff --git a/src/daemon/graph.c b/src/daemon/graph.c index 81522ca..8d328b3 100644 --- a/src/daemon/graph.c +++ b/src/daemon/graph.c @@ -523,3 +523,8 @@ int td_graph_vlabel_qps(td_ctx* ctx, td_graph* graph, const char* object, char* vlabel, size_t length) { return __td_string_set(vlabel, length, _("Queries Per Second")); } + +int td_graph_vlabel_seconds(td_ctx* ctx, td_graph* graph, + const char* object, char* vlabel, size_t length) { + return __td_string_set(vlabel, length, _("Seconds")); +} diff --git a/src/daemon/graph.h b/src/daemon/graph.h index 183b3f1..959da3e 100644 --- a/src/daemon/graph.h +++ b/src/daemon/graph.h @@ -115,4 +115,7 @@ int td_graph_vlabel_days(td_ctx* ctx, td_graph* graph, int td_graph_vlabel_qps(td_ctx* ctx, td_graph* graph, const char* object, char* vlabel, size_t length); +int td_graph_vlabel_seconds(td_ctx* ctx, td_graph* graph, + const char* object, char* vlabel, size_t length); + #endif /* TELEMETRY_GRAPH_H */ diff --git a/src/daemon/graphs.c b/src/daemon/graphs.c index ab9d6ff..373f761 100644 --- a/src/daemon/graphs.c +++ b/src/daemon/graphs.c @@ -64,6 +64,7 @@ static const td_graph_impl* graph_impls[] = { // Unbound &unbound_queries_graph, + &unbound_recursion_time_graph, // Legacy &legacy_suricata_graph, diff --git a/src/daemon/graphs/graph.h b/src/daemon/graphs/graph.h index 720594f..95d70b7 100644 --- a/src/daemon/graphs/graph.h +++ b/src/daemon/graphs/graph.h @@ -71,6 +71,8 @@ typedef enum flags { #define BPS "%%9.2lf %%s%3s", _("bps") #define QPS "%%14.2lf %3s", _("qps") #define HZ "%%10.2lf %%s%2s", _("Hz") +#define SECONDS_HIGHRES "%%12.2lf%%ss" +#define SECONDS "%%13.2lfs" // Macro to terminate a line #define EOL "\\j" diff --git a/src/daemon/graphs/unbound.c b/src/daemon/graphs/unbound.c index 2e4aa4c..0ac0479 100644 --- a/src/daemon/graphs/unbound.c +++ b/src/daemon/graphs/unbound.c @@ -72,3 +72,38 @@ const td_graph_impl unbound_queries_graph = { .lower_limit = 0, .upper_limit = LONG_MAX, }; + +static int unbound_recursion_time_title(td_ctx* ctx, td_graph* graph, + const char* object, char* title, size_t length) { + return __td_string_set(title, length, _("DNS Recursion Time")); +} + +static int unbound_recursion_time_render(td_ctx* ctx, + td_graph* graph, td_args* args, const char* object) { + int r; + + // Load all sources + r = td_graph_require_source(graph, args, "unbound", NULL); + if (r < 0) + return r; + + // Header + PRINT_HEADER4(args, _("Current"), _("Average"), _("Minimum"), _("Maximum")); + + // Draw the average + DRAW_LINE_WITH_LABEL(args, 1, "rec_time_avg", NULL, COLOR_DEFAULT, 0, _("Recursion Time")); + PRINT_CAMM(args, "rec_time_avg", NULL, SECONDS_HIGHRES); + + return 0; +} + +const td_graph_impl unbound_recursion_time_graph = { + .name = "UnboundRecursionTime", + .render = unbound_recursion_time_render, + .title = unbound_recursion_time_title, + .vlabel = td_graph_vlabel_seconds, + + // Limits + .lower_limit = 0, + .upper_limit = LONG_MAX, +}; diff --git a/src/daemon/graphs/unbound.h b/src/daemon/graphs/unbound.h index c4d262e..39573af 100644 --- a/src/daemon/graphs/unbound.h +++ b/src/daemon/graphs/unbound.h @@ -24,5 +24,6 @@ #include "../graph.h" extern const td_graph_impl unbound_queries_graph; +extern const td_graph_impl unbound_recursion_time_graph; #endif /* TELEMETRY_GRAPH_UNBOUND_H */