load_avg.c 336 B

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