load_avg.c 375 B

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