slstatus

My fork of https://tools.suckless.org/slstatus/
git clone https://git.inz.fi/slstatus
Log | Files | Refs | README | LICENSE

load_avg.c (336B)


      1 /* See LICENSE file for copyright and license details. */
      2 #include <stdio.h>
      3 #include <stdlib.h>
      4 
      5 #include "../util.h"
      6 
      7 const char *
      8 load_avg(void)
      9 {
     10 	double avgs[3];
     11 
     12 	if (getloadavg(avgs, 3) < 0) {
     13 		warn("getloadavg: Failed to obtain load average");
     14 		return NULL;
     15 	}
     16 
     17 	return bprintf("%.2f %.2f %.2f", avgs[0], avgs[1], avgs[2]);
     18 }