]> git.ipfire.org Git - people/ms/telemetry.git/commitdiff
graphs: unbound: Add a memory usage graph
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 28 Nov 2025 13:27:25 +0000 (13:27 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 28 Nov 2025 13:27:25 +0000 (13:27 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/daemon/colors.h
src/daemon/graphs.c
src/daemon/graphs/unbound.c
src/daemon/graphs/unbound.h

index b8f7148b33382d22f2db2e5bdbea4046eb8f2528..6faaf30dd3d19426064dbf659477c3ed87ec73b5 100644 (file)
@@ -93,6 +93,9 @@
 #define COLOR_DNS_INFRA                        COLOR_GREY
 #define COLOR_DNS_RRSETS               COLOR_BLUE
 #define COLOR_DNS_MSGS                 COLOR_GREEN
+#define COLOR_DNS_RPZ                  COLOR_RED
+#define COLOR_DNS_ITERATOR             COLOR_ORANGE
+#define COLOR_DNS_VALIDATOR            COLOR_PINK
 
 // CPU Colors
 
index e6253a48316179cb2f8416ff751ee536d464647b..c61dfeb07709ef38af4563818c043744e4f57adc 100644 (file)
@@ -71,6 +71,7 @@ static const td_graph_impl* graph_impls[] = {
        // Unbound
        &unbound_cache_performance_graph,
        &unbound_cache_usage_graph,
+       &unbound_memory_usage_graph,
        &unbound_recursion_time_graph,
 
        // Legacy
index 33db5ab3a03e7c2a6dfbba2523869dcfbbf1d755..00961799309077a9fd4e5d798d5da0ecf8fb5c63 100644 (file)
@@ -132,6 +132,70 @@ const td_graph_impl unbound_cache_usage_graph = {
        .upper_limit = LONG_MAX,
 };
 
+static int unbound_memory_usage_title(td_ctx* ctx, td_graph* graph,
+               const char* object, char* title, size_t length) {
+       return __td_string_set(title, length, _("DNS Memory Usage"));
+}
+
+static int unbound_memory_usage_render(td_ctx* ctx, td_graph* graph,
+               const td_graph_render_options* options, 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;
+
+       // Draw the stacked background first
+       DRAW_AREA_BACKGROUND(args, "mem_mod_respip",    NULL, COLOR_DNS_RPZ, 0);
+       DRAW_AREA_BACKGROUND(args, "mem_mod_validator", NULL, COLOR_DNS_VALIDATOR, STACKED);
+       DRAW_AREA_BACKGROUND(args, "mem_mod_iterator",  NULL, COLOR_DNS_ITERATOR, STACKED);
+       DRAW_AREA_BACKGROUND(args, "mem_cache_rrset",   NULL, COLOR_DNS_RRSETS, STACKED);
+       DRAW_AREA_BACKGROUND(args, "mem_cache_message", NULL, COLOR_DNS_MSGS, STACKED);
+
+       // Draw the area outlines afterwards
+       DRAW_AREA_OUTLINE_WITH_LABEL(args, "mem_mod_respip", NULL,
+               COLOR_DNS_RPZ, 0, _("Request Policy Zones"));
+       PRINT_CAMM(args, "mem_mod_respip", NULL, BYTES);
+
+       DRAW_AREA_OUTLINE_WITH_LABEL(args, "mem_mod_validator", NULL,
+               COLOR_DNS_VALIDATOR, STACKED, _("Validator"));
+       PRINT_CAMM(args, "mem_mod_validator", NULL, BYTES);
+
+       DRAW_AREA_OUTLINE_WITH_LABEL(args, "mem_mod_iterator", NULL,
+               COLOR_DNS_ITERATOR, STACKED, _("Iterator"));
+       PRINT_CAMM(args, "mem_mod_iterator", NULL, BYTES);
+
+       DRAW_AREA_OUTLINE_WITH_LABEL(args, "mem_cache_rrset", NULL,
+               COLOR_DNS_RRSETS, STACKED, _("RRSet Objects"));
+       PRINT_CAMM(args, "mem_cache_rrset", NULL, BYTES);
+
+       DRAW_AREA_OUTLINE_WITH_LABEL(args, "mem_cache_message", NULL,
+               COLOR_DNS_MSGS, STACKED, _("Message Objects"));
+       PRINT_CAMM(args, "mem_cache_message", NULL, BYTES);
+
+       PRINT_EMPTY_LINE(args);
+
+       // Header
+       PRINT_HEADER4(args, _("Current"), _("Average"), _("Minimum"), _("Maximum"));
+
+       return 0;
+}
+
+const td_graph_impl unbound_memory_usage_graph = {
+       .name    = "UnboundMemoryUsage",
+       .render  = unbound_memory_usage_render,
+       .title   = unbound_memory_usage_title,
+       .vlabel  = td_graph_vlabel_bytes,
+
+       // Flags
+       .flags   = TELEMETRY_GRAPH_REVERSE,
+
+       // Limits
+       .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"));
index 669e352c69dedf48d140f08e521d4cb44b180ee8..41cdc4163c62c4696a2ebc18ddc5442c7617e13e 100644 (file)
@@ -25,6 +25,7 @@
 
 extern const td_graph_impl unbound_cache_performance_graph;
 extern const td_graph_impl unbound_cache_usage_graph;
+extern const td_graph_impl unbound_memory_usage_graph;
 extern const td_graph_impl unbound_recursion_time_graph;
 
 #endif /* TELEMETRY_GRAPH_UNBOUND_H */