all repos — slstatus @ 83c98554ed39f37921152804e9fda7f4b0da0527

my build of slstatus (tools.suckless.org/slstatus/)

load avg
Aaron Marcher info@nulltime.net
Thu, 18 Aug 2016 13:30:45 +0200
commit

83c98554ed39f37921152804e9fda7f4b0da0527

parent

1d43e2f2b2a31caa48f16d0042d56e57545b2b48

4 files changed, 19 insertions(+), 0 deletions(-)

jump to
M README.mdREADME.md

@@ -17,6 +17,7 @@ - disk numbers (free storage, percentage, total storage and used storage)

- available entropy - hostname - ip addresses +- load avg - ram numbers (free ram, percentage, total ram and used ram) - temperature - volume percentage (alsa)
M config.def.hconfig.def.h

@@ -26,6 +26,7 @@ - entropy (available entropy) [argument: NULL]

- 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]
M slstatus.cslstatus.c

@@ -342,6 +342,22 @@

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)
M slstatus.hslstatus.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 *);