4 const char *get_load() {
9 slurp("/proc/loadavg", part, sizeof(part));
10 *skip_character(part, ' ', 3) = '\0';
12 /* TODO: correctly check for NetBSD, check if it works the same on *BSD */
14 size_t length = sizeof(struct loadavg);
15 int mib[2] = { CTL_VM, VM_LOADAVG };
16 if (sysctl(mib, 2, &load, &length, NULL, 0) < 0)
17 die("Could not sysctl({ CTL_VM, VM_LOADAVG })\n");
18 double scale = load.fscale;
19 (void)snprintf(part, sizeof(part), "%.02f %.02f %.02f",
20 (double)load.ldavg[0] / scale,
21 (double)load.ldavg[1] / scale,
22 (double)load.ldavg[2] / scale);