[collectd] [PATCH 1/1] contextswitch plugin: add support for AIX

Manuel Luis Sanmartín Rozada manuel.luis at gmail.com
Mon Jun 6 17:28:35 CEST 2011


---
 configure.in        |    1 +
 src/Makefile.am     |    4 ++++
 src/contextswitch.c |   23 ++++++++++++++++++++++-
 3 files changed, 27 insertions(+), 1 deletions(-)

diff --git a/configure.in b/configure.in
index 4fd08ce..08e9535 100644
--- a/configure.in
+++ b/configure.in
@@ -4375,6 +4375,7 @@ then
 	plugin_swap="yes"
 	plugin_interface="yes"
 	plugin_load="yes"
+	plugin_contextswitch="yes"
 fi

 if test "x$with_procinfo" = "xyes"
diff --git a/src/Makefile.am b/src/Makefile.am
index 795de57..51a6d4d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -213,7 +213,11 @@ if BUILD_PLUGIN_CONTEXTSWITCH
 pkglib_LTLIBRARIES += contextswitch.la
 contextswitch_la_SOURCES = contextswitch.c
 contextswitch_la_LDFLAGS = -module -avoid-version
+contextswitch_la_LIBADD =
 collectd_LDADD += "-dlopen" contextswitch.la
+if BUILD_WITH_PERFSTAT
+contextswitch_la_LIBADD += -lperfstat
+endif
 collectd_DEPENDENCIES += contextswitch.la
 endif

diff --git a/src/contextswitch.c b/src/contextswitch.c
index c207318..49cb63f 100644
--- a/src/contextswitch.c
+++ b/src/contextswitch.c
@@ -37,6 +37,11 @@
 /* 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
@@ -121,7 +126,23 @@ static int cs_read (void)

 	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;
+
+        if (perfstat_cpu_total(NULL, &perfcputotal,
sizeof(perfstat_cpu_total_t), 1) < 0)
+        {
+                char errbuf[1024];
+                WARNING ("contextswitch plugin: perfstat_cpu_total: %s",
+                        sstrerror (errno, errbuf, sizeof (errbuf)));
+                return (-1);
+        }
+
+        cs_submit(perfcputotal.pswitch);
+
+#endif /* HAVE_PERFSTAT */

 	return status;
 }
-- 
1.7.1.1



More information about the collectd mailing list