]> git.ipfire.org Git - oddments/collecty.git/commitdiff
graphs: Add a graph for Unbound queries
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 30 Oct 2025 18:02:21 +0000 (18:02 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 30 Oct 2025 18:02:21 +0000 (18:02 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
src/daemon/colors.h
src/daemon/graphs.c
src/daemon/graphs/unbound.c [new file with mode: 0644]
src/daemon/graphs/unbound.h [new file with mode: 0644]

index 8ed0355bbf261a0699783a4286582c229a55b998..d251e324dfce6d7d327ca03e6b0c4b2ce7d88c9b 100644 (file)
@@ -136,6 +136,8 @@ dist_telemetryd_SOURCES = \
        src/daemon/graphs/pressure.h \
        src/daemon/graphs/processor.c \
        src/daemon/graphs/processor.h \
+       src/daemon/graphs/unbound.c \
+       src/daemon/graphs/unbound.h \
        src/daemon/graphs/uptime.c \
        src/daemon/graphs/uptime.h \
        src/daemon/i18n.h \
index 1d4f6821e4aa5acfd8840c7a784dcf6dd810ffd5..c4898bd5912f88d87b26a580e08146cf13fe2074 100644 (file)
@@ -54,6 +54,9 @@
 #define COLOR_RX                               COLOR_GREEN
 #define COLOR_TX                               COLOR_RED
 
+#define COLOR_CACHE_HIT                        COLOR_GREEN
+#define COLOR_CACHE_MISS               COLOR_RED
+
 // CPU Colors
 
 static inline const char* COLOR_CPU(long i) {
index cee8f56798b8b693bab8f3a97c911d277edbe5a4..ab9d6ffb5ae0dc01d2179313f7b169b21da6307f 100644 (file)
@@ -38,6 +38,7 @@
 #include "graphs/memory.h"
 #include "graphs/pressure.h"
 #include "graphs/processor.h"
+#include "graphs/unbound.h"
 #include "graphs/uptime.h"
 
 // Legacy graphs
@@ -61,6 +62,9 @@ static const td_graph_impl* graph_impls[] = {
        &pressure_io_graph,
        &pressure_memory_graph,
 
+       // Unbound
+       &unbound_queries_graph,
+
        // Legacy
        &legacy_suricata_graph,
 
diff --git a/src/daemon/graphs/unbound.c b/src/daemon/graphs/unbound.c
new file mode 100644 (file)
index 0000000..11220df
--- /dev/null
@@ -0,0 +1,79 @@
+/*#############################################################################
+#                                                                             #
+# 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 <http://www.gnu.org/licenses/>.       #
+#                                                                             #
+#############################################################################*/
+
+#include <limits.h>
+
+#include "graph.h"
+#include "unbound.h"
+
+static int unbound_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 unbound_queries_vlabel(td_ctx* ctx, td_graph* graph,
+               const char* object, char* vlabel, size_t length) {
+       return __td_string_set(vlabel, length, _("Queries Per Second"));
+}
+
+static int unbound_queries_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"));
+
+       // Show the total queries
+       PRINT_LABEL(args, _("Total"));
+       PRINT_CAMM(args, "queries", NULL, QPS);
+
+       PRINT_EMPTY_LINE(args);
+
+       // Draw the stacked background first
+       DRAW_AREA_BACKGROUND(args, "cachehits", NULL, COLOR_CACHE_HIT, 0);
+       DRAW_AREA_BACKGROUND(args, "cachemiss", NULL, COLOR_CACHE_MISS, STACKED);
+
+       // Draw the area outlines afterwards
+       DRAW_AREA_OUTLINE_WITH_LABEL(args, "cachehits", NULL,
+               COLOR_CACHE_HIT, 0, _("Cache Hits"));
+       PRINT_CAMM(args, "cachehits", NULL, QPS);
+
+       DRAW_AREA_OUTLINE_WITH_LABEL(args, "cachemiss", NULL,
+               COLOR_CACHE_MISS, STACKED, _("Cache Miss"));
+       PRINT_CAMM(args, "cachemiss", NULL, QPS);
+
+       return 0;
+}
+
+const td_graph_impl unbound_queries_graph = {
+       .name    = "UnboundQueries",
+       .render  = unbound_queries_render,
+       .title   = unbound_queries_title,
+       .vlabel  = unbound_queries_vlabel,
+
+       // Limits
+       .lower_limit = 0,
+       .upper_limit = LONG_MAX,
+};
diff --git a/src/daemon/graphs/unbound.h b/src/daemon/graphs/unbound.h
new file mode 100644 (file)
index 0000000..c4d262e
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.       #
+#                                                                             #
+#############################################################################*/
+
+#ifndef TELEMETRY_GRAPH_UNBOUND_H
+#define TELEMETRY_GRAPH_UNBOUND_H
+
+#include "../graph.h"
+
+extern const td_graph_impl unbound_queries_graph;
+
+#endif /* TELEMETRY_GRAPH_UNBOUND_H */