diff options
author | Aaron Marcher <info@nulltime.net> | 2016-08-18 13:30:45 +0200 |
---|---|---|
committer | Aaron Marcher (drkhsh) <info@nulltime.net> | 2016-08-18 13:30:45 +0200 |
commit | 83c98554ed39f37921152804e9fda7f4b0da0527 (patch) | |
tree | 10374aa9c70bb0cee967ef6ab17e135f34279ca5 /slstatus.c | |
parent | 1d43e2f2b2a31caa48f16d0042d56e57545b2b48 (diff) |
load avg
Diffstat (limited to 'slstatus.c')
-rw-r--r-- | slstatus.c | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -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) |