#ifndef TELEMETRY_COLORS_H
#define TELEMETRY_COLORS_H
+#include "util.h"
+
#define BLACK "#000000"
#define WHITE "#ffffff"
#define GREY "#9e9e9e"
// Default - If something does not need to have a special meaning
#define DEFAULT GREY
-// Limit - When there is a ceiling to resource usage
-#define LIMIT RED
+// Limits - When there is a floor/ceiling to resource usage
+#define MINIMUM GREEN
+#define MAXIMUM RED
+#define LIMIT MAXIMUM
// Define colors for incoming/outgoing traffic
#define COLOR_RX GREEN
#define COLOR_TX RED
+// CPU Colors
+
+static inline const char* COLOR_CPU(long i) {
+ const char* cpu_colors[] = {
+ RED,
+ YELLOW,
+ GREEN,
+ ORANGE,
+ NULL,
+ };
+
+ return (cpu_colors[i % STATIC_ARRAY_SIZE(cpu_colors)]);
+}
+
// Macro to make colours transparent
#define COLOR_WITH_ALPHA(base, alpha) base alpha
// Load all graphs
#include "graphs/conntrack.h"
#include "graphs/contextswitches.h"
+#include "graphs/cpufreq.h"
#include "graphs/hostapd-station-bandwidth.h"
#include "graphs/hostapd-station-rate-info.h"
#include "graphs/hostapd-station-signal.h"
static const td_graph_impl* graph_impls[] = {
&conntrack_graph,
&contextswitches_graph,
+ &cpufreq_graph,
&hostapd_station_bandwidth_graph,
&hostapd_station_rate_info_graph,
&hostapd_station_signal_graph,
--- /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 "cpufreq.h"
+#include "graph.h"
+
+static int cpufreq_title(td_ctx* ctx,
+ td_graph* graph, const char* object, char* title, size_t length) {
+ return __td_string_set(title, length, _("CPU Frequency"));
+}
+
+static int cpufreq_vlabel(td_ctx* ctx,
+ td_graph* graph, const char* object, char* vlabel, size_t length) {
+ return __td_string_set(vlabel, length, _("Hz"));
+}
+
+static int cpufreq_render(td_ctx* ctx,
+ td_graph* graph, td_args* args, const char* _object) {
+ char object[NAME_MAX];
+ int r;
+
+ // Header
+ PRINT_HEADER4(args, _("Current"), _("Average"), _("Minimum"), _("Maximum"));
+
+ // Fetch the number of available processors
+ long num = sysconf(_SC_NPROCESSORS_CONF);
+
+ // This requires the sources for all CPU cores
+ for (long i = 0; i < num; i++) {
+ // Format the object
+ r = td_string_format(object, "%ld", i);
+ if (r < 0)
+ return r;
+
+ // Require the source
+ r = td_graph_require_source(graph, args, "cpufreq", object);
+ if (r < 0)
+ return r;
+
+ // Draw the line
+ DRAW_LINE1_WITH_LABEL(args, "freq_cur", object, COLOR_CPU(i), _("CPU Core %ld"));
+ PRINT_CAMM(args, "freq_cur", object, HZ, _("Hz"));
+
+ // Draw the minimum
+ DRAW_LINE2(args, "freq_min", object, MINIMUM);
+
+ // Draw the maximum
+ DRAW_LINE2(args, "freq_max", object, MAXIMUM);
+ }
+
+ return 0;
+}
+
+const td_graph_impl cpufreq_graph = {
+ .name = "CPUFreq",
+ .render = cpufreq_render,
+ .title = cpufreq_title,
+ .vlabel = cpufreq_vlabel,
+
+ // Limits
+ .lower_limit = 0,
+ .upper_limit = LONG_MAX,
+};
--- /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/>. #
+# #
+#############################################################################*/
+
+#ifndef TELEMETRY_GRAPH_CPUFREQ_H
+#define TELEMETRY_GRAPH_CPUFREQ_H
+
+#include "../graph.h"
+
+extern const td_graph_impl cpufreq_graph;
+
+#endif /* TELEMETRY_GRAPH_CPUFREQ_H */