summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: bbd258a)
raw | patch | inline | side by side (parent: bbd258a)
author | octo <octo> | |
Wed, 7 Jun 2006 17:11:52 +0000 (17:11 +0000) | ||
committer | octo <octo> | |
Wed, 7 Jun 2006 17:11:52 +0000 (17:11 +0000) |
Maybe this should be the default?
src/swap.c | patch | blob | history |
diff --git a/src/swap.c b/src/swap.c
index 7dd8d680cc3b68dbe5cc4d82bebe5fed4dcf3fe2..1d284f39059238728d731d628484af4bf3289b47 100644 (file)
--- a/src/swap.c
+++ b/src/swap.c
/* #endif HAVE_LIBKSTAT */
#elif HAVE_SYS_SYSCTL_H
- int mib[2];
+ int mib[3];
+ size_t mib_len;
struct xsw_usage sw_usage;
size_t sw_usage_len;
+ int status;
- mib[0] = CTL_VM;
- mib[1] = VM_SWAPUSAGE;
+#if defined(VM_SWAPUSAGE)
+ mib_len = 2;
+ mib[0] = CTL_VM;
+ mib[1] = VM_SWAPUSAGE;
+#else
+ mib_len = 3;
+ if ((status = sysctlnametomib ("vm.swap_info", mib, &mib_len)) < 0)
+ {
+ syslog (LOG_WARN, "swap plugin: sysctlnametomib failed: %s",
+ strerror (errno));
+ return;
+ }
+#endif
sw_usage_len = sizeof (struct xsw_usage);
- if (sysctl (mib, 2, &sw_usage, &sw_usage_len, NULL, 0) != 0)
+ if (sysctl (mib, mib_len, &sw_usage, &sw_usage_len, NULL, 0) != 0)
return;
/* The returned values are bytes. */