From 4a2ec3e0f8dcc94ca9f05bfd0b02645c309e4430 Mon Sep 17 00:00:00 2001 From: Zebity Spring Date: Sat, 9 Nov 2019 23:41:38 +1100 Subject: [PATCH 1/1] Avoid using sysctl on linux & allow for OpenBSD case --- src/memory.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/memory.c b/src/memory.c index 8d2de762..85986516 100644 --- a/src/memory.c +++ b/src/memory.c @@ -28,7 +28,7 @@ #include "plugin.h" #include "utils/common/common.h" -#if defined(HAVE_SYS_SYSCTL_H) && defined(HAVE_SYSCTLBYNAME) +#if (defined(HAVE_SYS_SYSCTL_H) && defined(HAVE_SYSCTLBYNAME)) || defined(__OpenBSD__) /* Implies BSD variant */ #include #endif @@ -81,10 +81,10 @@ static kstat_t *ksp; static kstat_t *ksz; /* #endif HAVE_LIBKSTAT */ -#elif HAVE_SYSCTL && HAVE_SYSCTLBYNAME -/* force BSD variant take HAVE_SYSCTLBYNAME conditional path above */ +#elif HAVE_SYSCTL && __OpenBSD__ +/* OpenBSD variant does not have sysctlbyname */ static int pagesize; -/* #endif HAVE_SYSCTL && HAVE_SYSCTLBYNAME */ +/* #endif HAVE_SYSCTL && __OpenBSD__ */ #elif HAVE_LIBSTATGRAB /* no global variables */ @@ -144,14 +144,14 @@ static int memory_init(void) { /* #endif HAVE_LIBKSTAT */ -#elif HAVE_SYSCTL && HAVE_SYSCTLBYNAME -/* force BSD variant take HAVE_SYSCTLBYNAME conditional path above */ +#elif HAVE_SYSCTL && __OpenBSD__ +/* OpenBSD variant does not have sysctlbyname */ pagesize = getpagesize(); if (pagesize <= 0) { ERROR("memory plugin: Invalid pagesize: %i", pagesize); return -1; } - /* #endif HAVE_SYSCTL */ + /* #endif HAVE_SYSCTL && __OpenBSD__ */ #elif HAVE_LIBSTATGRAB /* no init stuff */ @@ -411,8 +411,8 @@ static int memory_read_internal(value_list_t *vl) { (gauge_t)arcsize, "unusable", (gauge_t)mem_unus); /* #endif HAVE_LIBKSTAT */ -#elif HAVE_SYSCTL && HAVE_SYSCTLBYNAME -/* force BSD variant take HAVE_SYSCTLBYNAME conditional path above */ +#elif HAVE_SYSCTL && __OpenBSD__ +/* OpenBSD variant does not have HAVE_SYSCTLBYNAME */ int mib[] = {CTL_VM, VM_METER}; struct vmtotal vmtotal = {0}; gauge_t mem_active; @@ -434,7 +434,7 @@ static int memory_read_internal(value_list_t *vl) { MEMORY_SUBMIT("active", mem_active, "inactive", mem_inactive, "free", mem_free); - /* #endif HAVE_SYSCTL */ + /* #endif HAVE_SYSCTL && __OpenBSD__ */ #elif HAVE_LIBSTATGRAB sg_mem_stats *ios; -- 2.11.0