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