Xinqi Bao's Git

entropy: Port to OpenBSD
[slstatus.git] / components / load_avg.c
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(const char *fmt)
9 {
10 double avgs[3];
11
12 if (getloadavg(avgs, 3) < 0) {
13 fprintf(stderr, "getloadavg: Could not obtain load average.\n");
14 return NULL;
15 }
16
17 return bprintf(fmt, avgs[0], avgs[1], avgs[2]);
18 }