blob: 83896b299b1110e212b2202603a0e172b03df9b6 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
#include "detection/loadavg/loadavg.h"
#include <sys/sysctl.h>
#if __FreeBSD__ || __OpenBSD__ || __NetBSD__
#include <sys/types.h>
#include <sys/resource.h>
#if __FreeBSD__
#include <vm/vm_param.h>
#endif
#endif
const char* ffDetectLoadavg(double result[3]) {
struct loadavg load;
size_t size = sizeof(load);
if (sysctl((int[]) { CTL_VM, VM_LOADAVG }, 2, &load, &size, NULL, 0) < 0) {
return "sysctl({CTL_VM, VM_LOADAVG}) failed";
}
for (int i = 0; i < 3; i++) {
result[i] = (double) load.ldavg[i] / (double) load.fscale;
}
return NULL;
}
|