X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fcontextswitch.c;h=76e2a6c0b935c9225d50e96e7c2405554f459476;hb=5523a080010dcb7a61dc0dccc3969a2a048e52f9;hp=c207318f9d62425fbfb18e7e86727bce62b65bcb;hpb=3904b4b9fd1a53c93f31d8fec709a7b7b8300513;p=collectd.git diff --git a/src/contextswitch.c b/src/contextswitch.c index c207318f..76e2a6c0 100644 --- a/src/contextswitch.c +++ b/src/contextswitch.c @@ -22,6 +22,7 @@ **/ #include "collectd.h" + #include "common.h" #include "plugin.h" @@ -37,6 +38,11 @@ /* no global variables */ /* #endif KERNEL_LINUX */ +#elif HAVE_PERFSTAT +# include +# include +/* #endif HAVE_PERFSTAT */ + #else # error "No applicable input method." #endif @@ -121,7 +127,24 @@ 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; + + 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); + status = 0; +#endif /* defined(HAVE_PERFSTAT) */ return status; }