From e9f15bac48370598a5dfe4bd5aeeb7a1b15b4110 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Fri, 29 May 2026 11:40:22 +0000 Subject: [PATCH] graphs: Add a graph for Knot Resolver's queries Signed-off-by: Michael Tremer --- Makefile.am | 2 + src/daemon/graphs.c | 4 ++ src/daemon/graphs/knot-resolver-queries.c | 59 +++++++++++++++++++++++ src/daemon/graphs/knot-resolver-queries.h | 28 +++++++++++ 4 files changed, 93 insertions(+) create mode 100644 src/daemon/graphs/knot-resolver-queries.c create mode 100644 src/daemon/graphs/knot-resolver-queries.h diff --git a/Makefile.am b/Makefile.am index 851a354..ba161e4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -130,6 +130,8 @@ dist_telemetryd_SOURCES = \ src/daemon/graphs/interface-throughput.h \ src/daemon/graphs/interface-packets.c \ src/daemon/graphs/interface-packets.h \ + src/daemon/graphs/knot-resolver-queries.c \ + src/daemon/graphs/knot-resolver-queries.h \ src/daemon/graphs/legacy-gateway-latency4.c \ src/daemon/graphs/legacy-gateway-latency4.h \ src/daemon/graphs/legacy-hostile-drops.c \ diff --git a/src/daemon/graphs.c b/src/daemon/graphs.c index a498b64..554a9c7 100644 --- a/src/daemon/graphs.c +++ b/src/daemon/graphs.c @@ -37,6 +37,7 @@ #include "graphs/hostapd-station-signal.h" #include "graphs/interface-throughput.h" #include "graphs/interface-packets.h" +#include "graphs/knot-resolver-queries.h" #include "graphs/loadavg.h" #include "graphs/memory.h" #include "graphs/pressure.h" @@ -92,6 +93,9 @@ static const td_graph_impl* graph_impls[] = { // Power Consumption &processor_power_consumption_graph, + // Knot Resolver + &knot_resolver_queries_graph, + // Unbound &unbound_cache_performance_graph, &unbound_cache_usage_graph, diff --git a/src/daemon/graphs/knot-resolver-queries.c b/src/daemon/graphs/knot-resolver-queries.c new file mode 100644 index 0000000..cb0971d --- /dev/null +++ b/src/daemon/graphs/knot-resolver-queries.c @@ -0,0 +1,59 @@ +/*############################################################################# +# # +# telemetryd - The IPFire Telemetry Collection Service # +# Copyright (C) 2025 IPFire Development Team # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +#############################################################################*/ + +#include + +#include "graph.h" +#include "knot-resolver-queries.h" + +static int knot_resolver_queries_title(td_ctx* ctx, td_graph* graph, + const char* object, char* title, size_t length) { + return __td_string_set(title, length, _("DNS Queries")); +} + +static int knot_resolver_queries_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, "knot-resolver", NULL); + if (r < 0) + return r; + + // Header + PRINT_HEADER4(args, _("Current"), _("Average"), _("Minimum"), _("Maximum")); + + // Draw the average + DRAW_AREA_WITH_LABEL(args, "request_total", NULL, COLOR_DEFAULT, 0, _("DNS Queries")); + PRINT_CAMM(args, "request_total", NULL, QPS, QPS_UNIT); + + return 0; +} + +const td_graph_impl knot_resolver_queries_graph = { + .name = "KnotResolverQueries", + .render = knot_resolver_queries_render, + .title = knot_resolver_queries_title, + .vlabel = td_graph_vlabel_qps, + + // Limits + .lower_limit = 0, + .upper_limit = LONG_MAX, +}; diff --git a/src/daemon/graphs/knot-resolver-queries.h b/src/daemon/graphs/knot-resolver-queries.h new file mode 100644 index 0000000..3f96510 --- /dev/null +++ b/src/daemon/graphs/knot-resolver-queries.h @@ -0,0 +1,28 @@ +/*############################################################################# +# # +# telemetryd - The IPFire Telemetry Collection Service # +# Copyright (C) 2025 IPFire Development Team # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +#############################################################################*/ + +#ifndef TELEMETRY_GRAPH_KNOT_RESOLVER_QUERIES_H +#define TELEMETRY_GRAPH_KNOT_RESOLVER_QUERIES_H + +#include "../graph.h" + +extern const td_graph_impl knot_resolver_queries_graph; + +#endif /* TELEMETRY_GRAPH_KNOT_RESOLVER_QUERIES_H */ -- 2.47.3