]> git.ipfire.org Git - collecty.git/commitdiff
graphs: Add graphs for PSI
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 29 Oct 2025 17:45:02 +0000 (17:45 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 29 Oct 2025 17:45:02 +0000 (17:45 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
src/daemon/graphs.c
src/daemon/graphs/pressure.c [new file with mode: 0644]
src/daemon/graphs/pressure.h [new file with mode: 0644]

index e7ad419661f5e4ed45ef692b0bc1a834970683f7..2c74008d978cd9b1ba1fdc948da60c36f9e9f083 100644 (file)
@@ -130,6 +130,8 @@ dist_telemetryd_SOURCES = \
        src/daemon/graphs/loadavg.h \
        src/daemon/graphs/memory.c \
        src/daemon/graphs/memory.h \
+       src/daemon/graphs/pressure.c \
+       src/daemon/graphs/pressure.h \
        src/daemon/graphs/processor.c \
        src/daemon/graphs/processor.h \
        src/daemon/graphs/uptime.c \
index d7d2b4115a6d0de3d265053b936dc71d6a5203ba..6c8df9ad0bd048e5005af5af6d324c84cf9abab3 100644 (file)
@@ -36,6 +36,7 @@
 #include "graphs/hostapd-station-signal.h"
 #include "graphs/loadavg.h"
 #include "graphs/memory.h"
+#include "graphs/pressure.h"
 #include "graphs/processor.h"
 #include "graphs/uptime.h"
 
@@ -51,6 +52,12 @@ static const td_graph_impl* graph_impls[] = {
        &memory_graph,
        &processor_graph,
        &uptime_graph,
+
+       // Pressure (PSI)
+       &pressure_cpu_graph,
+       &pressure_io_graph,
+       &pressure_memory_graph,
+
        NULL,
 };
 
diff --git a/src/daemon/graphs/pressure.c b/src/daemon/graphs/pressure.c
new file mode 100644 (file)
index 0000000..cb6203b
--- /dev/null
@@ -0,0 +1,145 @@
+/*#############################################################################
+#                                                                             #
+# 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 "../string.h"
+#include "graph.h"
+#include "pressure.h"
+
+// Set some colors
+#define COLOR_LOAD300  RED
+#define COLOR_LOAD60   ORANGE
+#define COLOR_LOAD10   YELLOW
+
+static int pressure_render(td_ctx* ctx,
+               td_graph* graph, td_args* args, const char* source) {
+       int r;
+
+       // This requires the source
+       r = td_graph_require_source(graph, args, source, NULL);
+       if (r < 0)
+               return r;
+
+       // Compute the difference
+       COMPUTE_CDEF(args, "delta_avg60=some_avg60,some_avg300,-");
+       COMPUTE_CDEF(args, "delta_avg10=some_avg10,some_avg60,-");
+
+       // Compute the area where some10/some60 is larger than some60/some300 respectively
+       COMPUTE_CDEF(args, "delta_avg60+=delta_avg60,0,delta_avg60,LIMIT");
+       COMPUTE_CDEF(args, "delta_avg10+=delta_avg10,0,delta_avg10,LIMIT");
+
+       // Draw the area backgrouns
+       DRAW_AREA_BACKGROUND(args, "some_avg300", NULL, COLOR_LOAD300, 0);
+       DRAW_AREA_BACKGROUND(args, "delta_avg60+", NULL, COLOR_LOAD60, STACKED);
+       DRAW_AREA_BACKGROUND(args, "delta_avg10+", NULL, COLOR_LOAD10, STACKED);
+
+       DRAW_AREA_OUTLINE_WITH_LABEL(args, "some_avg300", NULL, COLOR_LOAD300, 0, _("5 Minutes"));
+       PRINT_CAMM(args, "some_avg300", NULL, FLOAT);
+
+       DRAW_AREA_OUTLINE_WITH_LABEL(args, "some_avg60", NULL, COLOR_LOAD60, 0, _("One Minute"));
+       PRINT_CAMM(args, "some_avg60", NULL, FLOAT);
+
+       DRAW_AREA_OUTLINE_WITH_LABEL(args, "some_avg10", NULL, COLOR_LOAD10, 0, _("10 Seconds"));
+       PRINT_CAMM(args, "some_avg10", NULL, FLOAT);
+
+       // Header
+       PRINT_HEADER4(args, _("Current"), _("Average"), _("Minimum"), _("Maximum"));
+
+       return 0;
+}
+
+// Processor
+
+static int pressure_cpu_title(td_ctx* ctx, td_graph* graph,
+               const char* object, char* title, size_t length) {
+       return __td_string_format(title, length,
+                       "%s - %s", _("Pressure Stall Information"), _("Processor"));
+}
+
+static int pressure_cpu_render(td_ctx* ctx,
+               td_graph* graph, td_args* args, const char* object) {
+       return pressure_render(ctx, graph, args, "pressure-cpu");
+}
+
+const td_graph_impl pressure_cpu_graph = {
+       .name    = "PressureCPU",
+       .render  = pressure_cpu_render,
+       .title   = pressure_cpu_title,
+
+       // Flags
+       .flags   = TELEMETRY_GRAPH_REVERSE,
+
+       // Limits
+       .lower_limit = 0,
+       .upper_limit = LONG_MAX,
+};
+
+// IO
+
+static int pressure_io_title(td_ctx* ctx, td_graph* graph,
+               const char* object, char* title, size_t length) {
+       return __td_string_format(title, length,
+                       "%s - %s", _("Pressure Stall Information"), _("Input/Output"));
+}
+
+static int pressure_io_render(td_ctx* ctx,
+               td_graph* graph, td_args* args, const char* object) {
+       return pressure_render(ctx, graph, args, "pressure-io");
+}
+
+const td_graph_impl pressure_io_graph = {
+       .name    = "PressureIO",
+       .render  = pressure_io_render,
+       .title   = pressure_io_title,
+
+       // Flags
+       .flags   = TELEMETRY_GRAPH_REVERSE,
+
+       // Limits
+       .lower_limit = 0,
+       .upper_limit = LONG_MAX,
+};
+
+// Memory
+
+static int pressure_memory_title(td_ctx* ctx, td_graph* graph,
+               const char* object, char* title, size_t length) {
+       return __td_string_format(title, length,
+                       "%s - %s", _("Pressure Stall Information"), _("Memory"));
+}
+
+static int pressure_memory_render(td_ctx* ctx,
+               td_graph* graph, td_args* args, const char* object) {
+       return pressure_render(ctx, graph, args, "pressure-memory");
+}
+
+const td_graph_impl pressure_memory_graph = {
+       .name    = "PressureMemory",
+       .render  = pressure_memory_render,
+       .title   = pressure_memory_title,
+
+       // Flags
+       .flags   = TELEMETRY_GRAPH_REVERSE,
+
+       // Limits
+       .lower_limit = 0,
+       .upper_limit = LONG_MAX,
+};
diff --git a/src/daemon/graphs/pressure.h b/src/daemon/graphs/pressure.h
new file mode 100644 (file)
index 0000000..4a63be9
--- /dev/null
@@ -0,0 +1,30 @@
+/*#############################################################################
+#                                                                             #
+# 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_PRESSURE_H
+#define TELEMETRY_GRAPH_PRESSURE_H
+
+#include "../graph.h"
+
+extern const td_graph_impl pressure_cpu_graph;
+extern const td_graph_impl pressure_io_graph;
+extern const td_graph_impl pressure_memory_graph;
+
+#endif /* TELEMETRY_GRAPH_PRESSURE_H */