X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fcontextswitch.c;h=344f76e76f0c29242ac20821d8efb25f83f12871;hb=204cf4f8f68cadeac474a75584f27b7339aca4c4;hp=c207318f9d62425fbfb18e7e86727bce62b65bcb;hpb=d0bb20feb1c5915e8b8af24cc2d46c4ac82d6704;p=collectd.git diff --git a/src/contextswitch.c b/src/contextswitch.c index c207318f..344f76e7 100644 --- a/src/contextswitch.c +++ b/src/contextswitch.c @@ -37,6 +37,11 @@ /* no global variables */ /* #endif KERNEL_LINUX */ +#elif HAVE_PERFSTAT +# include +# include +/* #endif HAVE_PERFSTAT */ + #else # error "No applicable input method." #endif @@ -121,7 +126,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; }