summaryrefslogtreecommitdiff
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
parent1d43e2f2b2a31caa48f16d0042d56e57545b2b48 (diff)
load avg
-rw-r--r--README.md1
-rw-r--r--config.def.h1
-rw-r--r--slstatus.c16
-rw-r--r--slstatus.h1
4 files changed, 19 insertions, 0 deletions
diff --git a/README.md b/README.md
index 555a6b8..feb63f5 100644
--- a/README.md
+++ b/README.md
@@ -17,6 +17,7 @@ The following information is included:
- available entropy
- hostname
- ip addresses
+- load avg
- ram numbers (free ram, percentage, total ram and used ram)
- temperature
- volume percentage (alsa)
diff --git a/config.def.h b/config.def.h
index 3cbbedf..2dd05de 100644
--- a/config.def.h
+++ b/config.def.h
@@ -26,6 +26,7 @@ static const char unknowntext[] = "n/a";
- gid (gid of current user) [argument: NULL]
- hostname [argument: NULL]
- ip (ip address) [argument: interface]
+- load_avg (load average) [argument: NULL]
- ram_free (ram usage in percent) [argument: NULL]
- ram_perc (ram usage in percent) [argument: NULL]
- ram_total (ram usage in percent) [argument: NULL]
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)
diff --git a/slstatus.h b/slstatus.h
index f09b3bc..5efc5f2 100644
--- a/slstatus.h
+++ b/slstatus.h
@@ -25,6 +25,7 @@ char *entropy(const char*);
char *gid(const char*);
char *hostname(const char *);
char *ip(const char *);
+char *load_avg(const char *);
char *ram_free(const char *);
char *ram_perc(const char *);
char *ram_used(const char *);