]> git.ipfire.org Git - collecty.git/commitdiff
graphs: unbound: Add recursion time graph
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 30 Oct 2025 21:56:33 +0000 (21:56 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 30 Oct 2025 21:56:33 +0000 (21:56 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/daemon/graph.c
src/daemon/graph.h
src/daemon/graphs.c
src/daemon/graphs/graph.h
src/daemon/graphs/unbound.c
src/daemon/graphs/unbound.h

index 81522cafb332221c2d5a5918d7905aed5e5327c5..8d328b3eddb9694ad973258d332cbe9f17bf2cae 100644 (file)
@@ -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"));
+}
index 183b3f1c7fc5c27e98308580d4f7808aac1049ca..959da3e4f832314f199d6309a0d93377c4aa504d 100644 (file)
@@ -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 */
index ab9d6ffb5ae0dc01d2179313f7b169b21da6307f..373f761b08813c040f21eebb75809f50e1208df7 100644 (file)
@@ -64,6 +64,7 @@ static const td_graph_impl* graph_impls[] = {
 
        // Unbound
        &unbound_queries_graph,
+       &unbound_recursion_time_graph,
 
        // Legacy
        &legacy_suricata_graph,
index 720594f86297ba52800cc6d604b10802f91aee95..95d70b7a9a000031ca35e88900d402d19e13410b 100644 (file)
@@ -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"
index 2e4aa4c3b742c64c253d27456d9701633ae2a106..0ac04795951165a420d7c3448773b61cf03a1096 100644 (file)
@@ -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,
+};
index c4d262ecc4de3c5be9f33f641114a4a41377ba8d..39573af77b93a6ee5ce9d620b3d0ea7c5819073a 100644 (file)
@@ -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 */