diff --git a/src/cpu.c b/src/cpu.c
index 67db5bcc4d7b2f8d8ab5a10d8e885ff771879051..6832b5239a1b9bad95d931b5061636e1fa01118c 100644 (file)
--- a/src/cpu.c
+++ b/src/cpu.c
**/
#include "collectd.h"
-#include "plugin.h"
#include "common.h"
+#include "plugin.h"
+
+#define MODULE_NAME "cpu"
+
+#if defined(KERNEL_LINUX) || defined(HAVE_LIBKSTAT) || defined(HAVE_SYSCTLBYNAME)
+# define CPU_HAVE_READ 1
+#else
+# define CPU_HAVE_READ 0
+#endif
#ifdef HAVE_LIBKSTAT
# include <sys/sysinfo.h>
static int numcpu;
#endif /* HAVE_SYSCTLBYNAME */
-#define MODULE_NAME "cpu"
-
static char *cpu_filename = "cpu-%s.rrd";
static char *ds_def[] =
}
#undef BUFSIZE
+#if CPU_HAVE_READ
static void cpu_read (void)
{
#ifdef KERNEL_LINUX
}
/* #endif defined(HAVE_LIBKSTAT) */
-#elif defined (HAVE_SYSCTLBYNAME)
+#elif defined(HAVE_SYSCTLBYNAME)
long cpuinfo[CPUSTATES];
size_t cpuinfo_size;
return;
}
+#endif /* CPU_HAVE_READ */
void module_register (void)
{
- plugin_register (MODULE_NAME, cpu_init, cpu_read, cpu_write);
+ plugin_register (MODULE_NAME, cpu_init,
+#if CPU_HAVE_READ
+ cpu_read,
+#else
+ NULL,
+#endif
+ cpu_write);
}
#undef MODULE_NAME