2 * "THE BEER-WARE LICENSE" (Revision 42):
3 * <tobias.rehbein@web.de> wrote this file. As long as you retain this notice
4 * you can do whatever you want with this stuff. If we meet some day, and you
5 * think this stuff is worth it, you can buy me a beer in return.
20 char load_str
[LOAD_BUFFLEN
];
26 struct load_context
*ctx
;
28 if ((ctx
= malloc(sizeof(*ctx
))) == NULL
)
29 err(EX_SOFTWARE
, "malloc(%d) load_context", sizeof(*ctx
));
35 load_context_close(struct load_context
*ctx
)
43 load_str(struct load_context
*ctx
)
49 if (getloadavg(la
, 3) == -1)
50 errx(EX_SOFTWARE
, "getloadavg");
52 snprintf(ctx
->load_str
, sizeof(ctx
->load_str
), "%.2f %.2f %.2f", la
[0], la
[1], la
[2]);
54 return (ctx
->load_str
);