From 55457187d18221e76bd12f0fb2cfab65c49b92fb Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Tue, 5 Mar 2019 01:09:01 +0100 Subject: Initial commit --- slstatus/components/load_avg.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 slstatus/components/load_avg.c (limited to 'slstatus/components/load_avg.c') diff --git a/slstatus/components/load_avg.c b/slstatus/components/load_avg.c new file mode 100644 index 0000000..5c2e252 --- /dev/null +++ b/slstatus/components/load_avg.c @@ -0,0 +1,18 @@ +/* See LICENSE file for copyright and license details. */ +#include +#include + +#include "../util.h" + +const char * +load_avg(void) +{ + double avgs[3]; + + if (getloadavg(avgs, 3) < 0) { + warn("getloadavg: Failed to obtain load average"); + return NULL; + } + + return bprintf("%.2f %.2f %.2f", avgs[0], avgs[1], avgs[2]); +} -- cgit v1.2.3