From 09c729b88d982db6c0d839cb8d8272af72ebdbea Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Sat, 4 Oct 2025 12:49:49 +0000 Subject: [PATCH] sources: Add PSI for I/O Signed-off-by: Michael Tremer --- Makefile.am | 2 ++ src/daemon/sources.c | 2 ++ src/daemon/sources/pressure-io.c | 62 ++++++++++++++++++++++++++++++++ src/daemon/sources/pressure-io.h | 28 +++++++++++++++ 4 files changed, 94 insertions(+) create mode 100644 src/daemon/sources/pressure-io.c create mode 100644 src/daemon/sources/pressure-io.h diff --git a/Makefile.am b/Makefile.am index 649dcaa..a264ed9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 \ diff --git a/src/daemon/sources.c b/src/daemon/sources.c index 2156ca2..55e4f01 100644 --- a/src/daemon/sources.c +++ b/src/daemon/sources.c @@ -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 index 0000000..a005c28 --- /dev/null +++ b/src/daemon/sources/pressure-io.c @@ -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 . # +# # +#############################################################################*/ + +#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 index 0000000..49b773a --- /dev/null +++ b/src/daemon/sources/pressure-io.h @@ -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 . # +# # +#############################################################################*/ + +#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 */ -- 2.47.3