From 1f26ef61390810d9b1ed3405624f74f6dd3f90f9 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Sat, 27 Sep 2025 14:48:49 +0000 Subject: [PATCH] loadavg: Actually read the loadavg Signed-off-by: Michael Tremer --- src/daemon/modules/loadavg.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/daemon/modules/loadavg.c b/src/daemon/modules/loadavg.c index 276ea37..dcd463a 100644 --- a/src/daemon/modules/loadavg.c +++ b/src/daemon/modules/loadavg.c @@ -18,9 +18,27 @@ # # #############################################################################*/ +#include + #include "../ctx.h" +#include "../module.h" #include "loadavg.h" +static int loadavg_collect(collecty_ctx* ctx, collecty_module* module) { + double loadavg[3]; + int r; + + // Fetch the current loadavg + r = getloadavg(loadavg, 3); + if (r < 0) + return r; + + // Submit the values + return collecty_module_submit(module, NULL, + "%f:%f:%f", loadavg[0], loadavg[1], loadavg[2]); +} + const collecty_module_methods loadavg_module = { - .name = "loadavg", + .name = "loadavg", + .collect = loadavg_collect, }; -- 2.47.3