diff options
author | Vladimir Kobal <vlad@prokk.net> | 2017-01-31 23:48:58 +0200 |
---|---|---|
committer | Vladimir Kobal <vlad@prokk.net> | 2017-01-31 23:48:58 +0200 |
commit | 54dcdaf6856c180420b5a186c9efb3e6b24ce837 (patch) | |
tree | a0d09f41c7605ddae12704f88266d07cd8b1a5f6 /src/plugin_freebsd.h | |
parent | 299e3cc11db21e13a7bb3dbb138c36ac2dd2d51e (diff) |
Fix processors and pid_max for FreeBSD
Diffstat (limited to 'src/plugin_freebsd.h')
-rw-r--r-- | src/plugin_freebsd.h | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/plugin_freebsd.h b/src/plugin_freebsd.h index e4767a0913..3a1ac39100 100644 --- a/src/plugin_freebsd.h +++ b/src/plugin_freebsd.h @@ -7,8 +7,21 @@ 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; + + 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 */ |