projects
/
collectd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
d748379
)
Avoid using sysctl on linux
author
Zebity Spring
<zebity@yahoo.com>
Sat, 9 Nov 2019 12:05:22 +0000
(23:05 +1100)
committer
Zebity Spring
<zebity@yahoo.com>
Sat, 9 Nov 2019 12:05:22 +0000
(23:05 +1100)
src/cpu.c
patch
|
blob
|
history
src/swap.c
patch
|
blob
|
history
diff --git
a/src/cpu.c
b/src/cpu.c
index
92ebfd8
..
8c1d4cb
100644
(file)
--- a/
src/cpu.c
+++ b/
src/cpu.c
@@
-58,7
+58,7
@@
#include <sys/sysinfo.h>
#endif /* HAVE_LIBKSTAT */
#include <sys/sysinfo.h>
#endif /* HAVE_LIBKSTAT */
-#if
defined(HAVE_SYSCTL) && defined(HAVE_SYSCTLBYNAME
)
+#if
(defined(HAVE_SYSCTL) && defined(HAVE_SYSCTLBYNAME)) || defined(__OpenBSD__
)
/* Implies BSD variant */
#include <sys/sysctl.h>
#endif
/* Implies BSD variant */
#include <sys/sysctl.h>
#endif
@@
-79,13
+79,13
@@
#endif /* HAVE_SYS_DKSTAT_H */
#define CAN_USE_SYSCTL 0
#endif /* HAVE_SYS_DKSTAT_H */
#define CAN_USE_SYSCTL 0
-#if
defined(HAVE_SYSCTL) && defined(HAVE_SYSCTLBYNAME
)
+#if
(defined(HAVE_SYSCTL) && defined(HAVE_SYSCTLBYNAME)) || defined(__OpenBSD__
)
/* Implies BSD variant */
#if defined(CTL_HW) && defined(HW_NCPU) && defined(CTL_KERN) && \
defined(KERN_CPTIME) && defined(CPUSTATES)
#define CAN_USE_SYSCTL 1
#endif
/* Implies BSD variant */
#if defined(CTL_HW) && defined(HW_NCPU) && defined(CTL_KERN) && \
defined(KERN_CPTIME) && defined(CPUSTATES)
#define CAN_USE_SYSCTL 1
#endif
-#endif /* HAVE_SYSCTL_H && HAVE_SYSCTLBYNAME */
+#endif /* HAVE_SYSCTL_H && HAVE_SYSCTLBYNAME
|| __OpenBSD__
*/
#define COLLECTD_CPU_STATE_USER 0
#define COLLECTD_CPU_STATE_SYSTEM 1
#define COLLECTD_CPU_STATE_USER 0
#define COLLECTD_CPU_STATE_SYSTEM 1
@@
-143,7
+143,7
@@
static int numcpu;
/* #endif HAVE_LIBKSTAT */
#elif CAN_USE_SYSCTL
/* #endif HAVE_LIBKSTAT */
#elif CAN_USE_SYSCTL
-/* Only possible for BSD variant */
+/* Only possible for
(Open)
BSD variant */
static int numcpu;
/* #endif CAN_USE_SYSCTL */
static int numcpu;
/* #endif CAN_USE_SYSCTL */
@@
-269,7
+269,7
@@
static int init(void) {
/* #endif HAVE_LIBKSTAT */
#elif CAN_USE_SYSCTL
/* #endif HAVE_LIBKSTAT */
#elif CAN_USE_SYSCTL
- /* Only on BSD variant */
+ /* Only on
(Open)
BSD variant */
size_t numcpu_size;
int mib[2] = {CTL_HW, HW_NCPU};
int status;
size_t numcpu_size;
int mib[2] = {CTL_HW, HW_NCPU};
int status;
@@
-733,7
+733,7
@@
static int cpu_read(void) {
/* }}} #endif defined(HAVE_LIBKSTAT) */
#elif CAN_USE_SYSCTL /* {{{ */
/* }}} #endif defined(HAVE_LIBKSTAT) */
#elif CAN_USE_SYSCTL /* {{{ */
- /* Only on BSD variant */
+ /* Only on
(Open)
BSD variant */
uint64_t cpuinfo[numcpu][CPUSTATES];
size_t cpuinfo_size;
int status;
uint64_t cpuinfo[numcpu][CPUSTATES];
size_t cpuinfo_size;
int status;
diff --git
a/src/swap.c
b/src/swap.c
index
0a86632
..
ee5afa0
100644
(file)
--- a/
src/swap.c
+++ b/
src/swap.c
@@
-49,7
+49,7
@@
#if HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#if HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
-#if
defined(HAVE_SYS_SYSCTL_H) && defined(HAVE_SYSCTLBYNAME
)
+#if
(defined(HAVE_SYS_SYSCTL_H) && defined(HAVE_SYSCTLBYNAME)) || defined(__OpenBSD__
)
/* implies BSD variant */
#include <sys/sysctl.h>
#endif
/* implies BSD variant */
#include <sys/sysctl.h>
#endif