summaryrefslogtreecommitdiff
path: root/slstatus.c
diff options
context:
space:
mode:
authorAaron Marcher <info@nulltime.net>2016-08-18 13:30:45 +0200
committerAaron Marcher (drkhsh) <info@nulltime.net>2016-08-18 13:30:45 +0200
commit83c98554ed39f37921152804e9fda7f4b0da0527 (patch)
tree10374aa9c70bb0cee967ef6ab17e135f34279ca5 /slstatus.c
parent1d43e2f2b2a31caa48f16d0042d56e57545b2b48 (diff)
load avg
Diffstat (limited to 'slstatus.c')
-rw-r--r--slstatus.c16
1 files changed, 16 insertions, 0 deletions
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)