load_avg.c 441 B

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