--- /dev/null
+/*#############################################################################
+# #
+# 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,
+};