--- /dev/null
+/*#############################################################################
+# #
+# collecty - A system statistics collection daemon for IPFire #
+# 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 "contextswitches.h"
+
+static int contextswitches_title(collecty_ctx* ctx,
+ collecty_graph* graph, const char* object, char** title) {
+ return collecty_format_title(title, "%s", _("Context Switches"));
+}
+
+static int contextswitches_vlabel(collecty_ctx* ctx,
+ collecty_graph* graph, const char* object, char** title) {
+ return collecty_format_title(title, "%s", _("Context Switches/s"));
+}
+
+static int contextswitches_render(collecty_ctx* ctx,
+ collecty_graph* graph, collecty_args* args, const char* object) {
+ int r;
+
+ // This requires the contextswitches source
+ r = collecty_graph_require_source(graph, args, "contextswitches", object);
+ if (r < 0)
+ return r;
+
+ // Context Switches
+ DRAW_AREA_WITH_LABEL(args, "ctxt", GREEN, _("Context Switches"));
+ PRINT_LARGE_INTEGER(args, "ctxt_cur");
+ PRINT_LARGE_INTEGER(args, "ctxt_avg");
+ PRINT_LARGE_INTEGER(args, "ctxt_min");
+ PRINT_LARGE_INTEGER(args, "ctxt_max", EOL);
+
+ // Header
+ PRINT_HEADER4(args, _("Current"), _("Average"), _("Minimum"), _("Maximum"));
+
+ return 0;
+}
+
+const collecty_graph_impl contextswitches_graph = {
+ .name = "ContextSwitches",
+ .render = contextswitches_render,
+ .title = contextswitches_title,
+ .vlabel = contextswitches_vlabel,
+
+ // Limits
+ .lower_limit = 0,
+ .upper_limit = LONG_MAX,
+};
--- /dev/null
+/*#############################################################################
+# #
+# collecty - A system statistics collection daemon for IPFire #
+# 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 COLLECTY_GRAPH_CONTEXTSWITCHES_H
+#define COLLECTY_GRAPH_CONTEXTSWITCHES_H
+
+#include "../graph.h"
+
+extern const collecty_graph_impl contextswitches_graph;
+
+#endif /* COLLECTY_GRAPH_CONTEXTSWITCHES_H */