summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d1c3baa)
raw | patch | inline | side by side (parent: d1c3baa)
author | Kimo Rosenbaum <kimo@Kimo-Rosenbaums-MacBook-Pro.local> | |
Tue, 24 Aug 2010 20:27:03 +0000 (13:27 -0700) | ||
committer | Kimo Rosenbaum <kimo@Kimo-Rosenbaums-MacBook-Pro.local> | |
Tue, 24 Aug 2010 20:27:03 +0000 (13:27 -0700) |
configure.in | patch | blob | history | |
src/contextswitch.c | patch | blob | history |
diff --git a/configure.in b/configure.in
index 8ebf124447cd89225c894dd392f43999dcfae226..d00ac98ed9b6e6e1bead6cf8caf95887f7ec84b0 100644 (file)
--- a/configure.in
+++ b/configure.in
fi
if test "x$have_sysctlbyname" = "xyes"
then
+ plugin_contextswitch="yes"
plugin_cpu="yes"
plugin_memory="yes"
plugin_tcpconns="yes"
diff --git a/src/contextswitch.c b/src/contextswitch.c
index 06055ca59372299616a6f8b1bf105d30e34760f4..56d8bf09ee490f79bf148eaff6d67947ad98d1f2 100644 (file)
--- a/src/contextswitch.c
+++ b/src/contextswitch.c
#include "common.h"
#include "plugin.h"
-#if !KERNEL_LINUX
+#ifdef HAVE_SYS_SYSCTL_H
+# include <sys/sysctl.h>
+#endif
+
+#if HAVE_SYSCTLBYNAME
+/* no global variables */
+/* #endif HAVE_SYSCTLBYNAME */
+
+#elif KERNEL_LINUX
+/* no global variables */
+/* #endif KERNEL_LINUX */
+
+#else
# error "No applicable input method."
#endif
static int cs_read (void)
{
+ int status = -2;
+#if HAVE_SYSCTLBYNAME
+ int value;
+ size_t value_len = sizeof (value);
+
+ if (sysctlbyname ("vm.stats.sys.v_swtch", (void *) &value, &value_len,
+ NULL, 0) == 0)
+ {
+ cs_submit(value);
+ status = 0;
+ }
+ else
+ {
+ ERROR("contextswitch plugin: sysctlbyname failed");
+ }
+
+/* #endif HAVE_SYSCTLBYNAME */
+#elif KERNEL_LINUX
FILE *fh;
char buffer[64];
int numfields;
char *fields[3];
derive_t result = 0;
- int status = -2;
fh = fopen ("/proc/stat", "r");
if (fh == NULL) {
if (status == -2)
ERROR ("contextswitch plugin: Unable to find context switch value.");
+#endif /* KERNEL_LINUX */
return status;
}