]> git.ipfire.org Git - collecty.git/commitdiff
sources: Add PSI for I/O
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 4 Oct 2025 12:49:49 +0000 (12:49 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 4 Oct 2025 12:50:15 +0000 (12:50 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
src/daemon/sources.c
src/daemon/sources/pressure-io.c [new file with mode: 0644]
src/daemon/sources/pressure-io.h [new file with mode: 0644]

index 649dcaa60e4c7941b0da4b3e750981b0d3127326..a264ed97b179e738172998700b7d0a5d5c4031f6 100644 (file)
@@ -134,6 +134,8 @@ dist_collectyd_SOURCES = \
        src/daemon/sources/loadavg.h \
        src/daemon/sources/pressure-cpu.c \
        src/daemon/sources/pressure-cpu.h \
+       src/daemon/sources/pressure-io.c \
+       src/daemon/sources/pressure-io.h \
        src/daemon/sources/pressure-memory.c \
        src/daemon/sources/pressure-memory.h \
        src/daemon/sources/processor.c \
index 2156ca2ff79cd6f1928058625bb03f1b69064770..55e4f011f8fbd82ad49172ef2eca26b3f1ef4d3b 100644 (file)
@@ -32,6 +32,7 @@
 #include "sources/contextswitches.h"
 #include "sources/loadavg.h"
 #include "sources/pressure-cpu.h"
+#include "sources/pressure-io.h"
 #include "sources/pressure-memory.h"
 #include "sources/processor.h"
 
@@ -41,6 +42,7 @@ static const collecty_source_impl* source_impls[] = {
        &contextswitches_source,
        &loadavg_source,
        &pressure_cpu_source,
+       &pressure_io_source,
        &pressure_memory_source,
        &processor_source,
        NULL,
diff --git a/src/daemon/sources/pressure-io.c b/src/daemon/sources/pressure-io.c
new file mode 100644 (file)
index 0000000..a005c28
--- /dev/null
@@ -0,0 +1,62 @@
+/*#############################################################################
+#                                                                             #
+# 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 "../ctx.h"
+#include "../proc.h"
+#include "../source.h"
+#include "pressure-io.h"
+
+static int pressure_io_collect(collecty_ctx* ctx, collecty_source* source) {
+       collecty_pressure_stats stats = {};
+       int r;
+
+       // Read all values from /proc/pressure/io
+       r = collecty_proc_read_pressure(ctx, "io", &stats);
+       if (r < 0)
+               return r;
+
+       // Submit the values
+       return collecty_source_submit(source, NULL, "%.2f:%.2f:%.2f:%lu:%.2f:%.2f:%.2f:%lu",
+               stats.some.avg10, stats.some.avg60, stats.some.avg300, stats.some.total,
+               stats.full.avg10, stats.full.avg60, stats.full.avg300, stats.full.total);
+}
+
+const collecty_source_impl pressure_io_source = {
+       .name    = "pressure-io",
+
+       // RRD Data Sources
+       .rrd_dss = {
+               // some
+               { "some_avg10",  "GAUGE", 0, 100, },
+               { "some_avg60",  "GAUGE", 0, 100, },
+               { "some_avg300", "GAUGE", 0, 100, },
+               { "some_total",  "DERIVE", 0, -1, },
+
+               // full
+               { "full_avg10",  "GAUGE", 0, 100, },
+               { "full_avg60",  "GAUGE", 0, 100, },
+               { "full_avg300", "GAUGE", 0, 100, },
+               { "full_total",  "DERIVE", 0, -1, },
+               { NULL },
+       },
+
+       // Methods
+       .collect = pressure_io_collect,
+};
diff --git a/src/daemon/sources/pressure-io.h b/src/daemon/sources/pressure-io.h
new file mode 100644 (file)
index 0000000..49b773a
--- /dev/null
@@ -0,0 +1,28 @@
+/*#############################################################################
+#                                                                             #
+# 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_SOURCE_PRESSURE_IO_H
+#define COLLECTY_SOURCE_PRESSURE_IO_H
+
+#include "../source.h"
+
+extern const collecty_source_impl pressure_io_source;
+
+#endif /* COLLECTY_SOURCE_PRESSURE_IO_H */