X-Git-Url: https://arthur.barton.de/gitweb/?a=blobdiff_plain;f=src%2Fplugin_freebsd.h;h=3a1ac39100ff884171bfcb5bdb0a7b3b7afa6e96;hb=6fb372b18909cedbd8b7018caa9ed863928aff55;hp=ee432bfc6d1af78f36c57f8eff2bf4665f0b4488;hpb=594e6f11190cea1de1d9b9f6b255753689ba5aeb;p=netdata.git diff --git a/src/plugin_freebsd.h b/src/plugin_freebsd.h index ee432bfc..3a1ac391 100644 --- a/src/plugin_freebsd.h +++ b/src/plugin_freebsd.h @@ -1,12 +1,27 @@ #ifndef NETDATA_PLUGIN_FREEBSD_H #define NETDATA_PLUGIN_FREEBSD_H 1 +#include + #define GETSYSCTL(name, var) getsysctl(name, &(var), sizeof(var)) void *freebsd_main(void *ptr); -int getsysctl(const char *name, void *ptr, size_t len); +extern int do_freebsd_sysctl(int update_every, usec_t dt); + +static inline int getsysctl(const char *name, void *ptr, size_t len) +{ + size_t nlen = len; -extern int do_freebsd_sysctl(int update_every, unsigned long long dt); + if (unlikely(sysctlbyname(name, ptr, &nlen, NULL, 0) == -1)) { + error("FREEBSD: sysctl(%s...) failed: %s", name, strerror(errno)); + return 1; + } + if (unlikely(nlen != len)) { + error("FREEBSD: sysctl(%s...) expected %lu, got %lu", name, (unsigned long)len, (unsigned long)nlen); + return 1; + } + return 0; +} #endif /* NETDATA_PLUGIN_FREEBSD_H */