]> arthur.barton.de Git - netdata.git/blob - src/plugin_freebsd.h
properly name the expectations chart
[netdata.git] / src / plugin_freebsd.h
1 #ifndef NETDATA_PLUGIN_FREEBSD_H
2 #define NETDATA_PLUGIN_FREEBSD_H 1
3
4 #include <sys/sysctl.h>
5
6 #define GETSYSCTL(name, var) getsysctl(name, &(var), sizeof(var))
7
8 void *freebsd_main(void *ptr);
9
10 extern int do_freebsd_sysctl(int update_every, usec_t dt);
11
12 static inline int getsysctl(const char *name, void *ptr, size_t len)
13 {
14     size_t nlen = len;
15
16     if (unlikely(sysctlbyname(name, ptr, &nlen, NULL, 0) == -1)) {
17         error("FREEBSD: sysctl(%s...) failed: %s", name, strerror(errno));
18         return 1;
19     }
20     if (unlikely(nlen != len)) {
21         error("FREEBSD: sysctl(%s...) expected %lu, got %lu", name, (unsigned long)len, (unsigned long)nlen);
22         return 1;
23     }
24     return 0;
25 }
26
27 #endif /* NETDATA_PLUGIN_FREEBSD_H */