X-Git-Url: https://git.xinqibao.xyz/slstatus.git/blobdiff_plain/8e25af7dc33bdcc0df6f4f173da7a2f883141d70..6820631175868c277effa7cc05f9cb3197b72654:/load_avg.c?ds=inline diff --git a/load_avg.c b/load_avg.c new file mode 100644 index 0000000..7342ae9 --- /dev/null +++ b/load_avg.c @@ -0,0 +1,17 @@ +#include +#include + +#include "util.h" + +const char * +load_avg(const char *fmt) +{ + double avgs[3]; + + if (getloadavg(avgs, 3) < 0) { + warnx("Failed to get the load avg"); + return NULL; + } + + return bprintf(fmt, avgs[0], avgs[1], avgs[2]); +}