]> arthur.barton.de Git - netdata.git/blobdiff - src/plugin_freebsd.h
added compile option NETDATA_VERIFY_LOCKS to enable the locks
[netdata.git] / src / plugin_freebsd.h
index e4767a091310399a39eeade063c6d446e501ad75..3a1ac39100ff884171bfcb5bdb0a7b3b7afa6e96 100644 (file)
@@ -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 */