# #
#############################################################################*/
+#include <stdlib.h>
+
#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,
};