From: Michael Tremer Date: Wed, 29 Oct 2025 17:45:02 +0000 (+0000) Subject: graphs: Add graphs for PSI X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=da876b74723082f7a6338fcebf33d73c7e64d5c5;p=collecty.git graphs: Add graphs for PSI Signed-off-by: Michael Tremer --- diff --git a/Makefile.am b/Makefile.am index e7ad419..2c74008 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 \ diff --git a/src/daemon/graphs.c b/src/daemon/graphs.c index d7d2b41..6c8df9a 100644 --- a/src/daemon/graphs.c +++ b/src/daemon/graphs.c @@ -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 index 0000000..cb6203b --- /dev/null +++ b/src/daemon/graphs/pressure.c @@ -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 . # +# # +#############################################################################*/ + +#include + +#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 index 0000000..4a63be9 --- /dev/null +++ b/src/daemon/graphs/pressure.h @@ -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 . # +# # +#############################################################################*/ + +#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 */