From 83c98554ed39f37921152804e9fda7f4b0da0527 Mon Sep 17 00:00:00 2001 From: Aaron Marcher Date: Thu, 18 Aug 2016 13:30:45 +0200 Subject: load avg --- slstatus.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'slstatus.c') diff --git a/slstatus.c b/slstatus.c index 9884aaa..87e705d 100644 --- a/slstatus.c +++ b/slstatus.c @@ -342,6 +342,22 @@ ip(const char *interface) return smprintf(unknowntext); } +/* load avg */ +char * +load_avg(const char *null) +{ + double avgs[3]; + + /* try to get load avg */ + if (getloadavg(avgs, 3) < 0) { + fprintf(stderr, "Error getting load avg.\n"); + return smprintf(unknowntext); + } + + /* return it */ + return smprintf("%.2f %.2f %.2f", avgs[0], avgs[1], avgs[2]); +} + /* ram free */ char * ram_free(const char *null) -- cgit v1.2.3