summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8cccaeb)
raw | patch | inline | side by side (parent: 8cccaeb)
author | Manuel Luis SanmartĂn Rozada <manuel.luis@gmail.com> | |
Wed, 5 Sep 2012 11:48:03 +0000 (13:48 +0200) | ||
committer | Florian Forster <octo@collectd.org> | |
Tue, 2 Oct 2012 19:58:58 +0000 (21:58 +0200) |
configure.in | patch | blob | history | |
src/contextswitch.c | patch | blob | history |
diff --git a/configure.in b/configure.in
index 50f5fd5a124c87b5aa411be265a19748112224d2..fec588da49952e176f3b0d7e3b098ccd8ce9a1a0 100644 (file)
--- a/configure.in
+++ b/configure.in
if test "x$with_perfstat" = "xyes"
then
plugin_cpu="yes"
+ plugin_contextswitch="yes"
plugin_disk="yes"
plugin_memory="yes"
plugin_swap="yes"
diff --git a/src/contextswitch.c b/src/contextswitch.c
index c207318f9d62425fbfb18e7e86727bce62b65bcb..d3e6fe63fd0ae4167106faada1df850b7ed25b49 100644 (file)
--- a/src/contextswitch.c
+++ b/src/contextswitch.c
/* no global variables */
/* #endif KERNEL_LINUX */
+#elif HAVE_PERFSTAT
+# include <sys/protosw.h>
+# include <libperfstat.h>
+/* #endif HAVE_PERFSTAT */
+
#else
# error "No applicable input method."
#endif
if (status == -2)
ERROR ("contextswitch plugin: Unable to find context switch value.");
-#endif /* KERNEL_LINUX */
+/* #endif KERNEL_LINUX */
+
+#elif HAVE_PERFSTAT
+ int status = 0;
+ perfstat_cpu_total_t perfcputotal;
+
+ status = perfstat_cpu_total(NULL, &perfcputotal, sizeof(perfstat_cpu_total_t), 1);
+ if (status < 0);
+ {
+ char errbuf[1024];
+ ERROR ("contextswitch plugin: perfstat_cpu_total: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
+ return (-1);
+ }
+
+ cs_submit(perfcputotal.pswitch);
+ return (0);
+#endif /* defined(HAVE_PERFSTAT) */
return status;
}