From: Michael Tremer Date: Fri, 28 Nov 2025 13:27:25 +0000 (+0000) Subject: graphs: unbound: Add a memory usage graph X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ec344c542879ed363083a55f515bf79a06c07f9f;p=telemetry.git graphs: unbound: Add a memory usage graph Signed-off-by: Michael Tremer --- diff --git a/src/daemon/colors.h b/src/daemon/colors.h index b8f7148..6faaf30 100644 --- a/src/daemon/colors.h +++ b/src/daemon/colors.h @@ -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 diff --git a/src/daemon/graphs.c b/src/daemon/graphs.c index e6253a4..c61dfeb 100644 --- a/src/daemon/graphs.c +++ b/src/daemon/graphs.c @@ -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 diff --git a/src/daemon/graphs/unbound.c b/src/daemon/graphs/unbound.c index 33db5ab..0096179 100644 --- a/src/daemon/graphs/unbound.c +++ b/src/daemon/graphs/unbound.c @@ -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")); diff --git a/src/daemon/graphs/unbound.h b/src/daemon/graphs/unbound.h index 669e352..41cdc41 100644 --- a/src/daemon/graphs/unbound.h +++ b/src/daemon/graphs/unbound.h @@ -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 */