Code

Changed modules `cpu' through `sensors' to compile in `read-only' mode if dependencie...
[collectd.git] / src / load.c
index d082816aee1a2598d8167819ba21f203c57e132a..2c02d8be0d7890933c35b9d6ebc3d18c889d8f5b 100644 (file)
  *   Florian octo Forster <octo at verplant.org>
  **/
 
-#include "load.h"
+#include "collectd.h"
+#include "common.h"
+#include "plugin.h"
 
-#if COLLECT_LOAD
 #define MODULE_NAME "load"
 
-#include "plugin.h"
-#include "common.h"
+#if defined(HAVE_GETLOADAVG) || defined(KERNEL_LINUX) || defined(HAVE_LIBSTATGRAB)
+# define LOAD_HAVE_READ 1
+#else
+# define LOAD_HAVE_READ 0
+#endif
 
 #ifdef HAVE_SYS_LOADAVG_H
 #include <sys/loadavg.h>
@@ -74,6 +78,7 @@ void load_submit (double snum, double mnum, double lnum)
 }
 #undef BUFSIZE
 
+#if LOAD_HAVE_READ
 void load_read (void)
 {
 #if defined(HAVE_GETLOADAVG)
@@ -134,11 +139,17 @@ void load_read (void)
        load_submit (snum, mnum, lnum);
 #endif /* HAVE_LIBSTATGRAB */
 }
+#endif /* LOAD_HAVE_READ */
 
 void module_register (void)
 {
-       plugin_register (MODULE_NAME, load_init, load_read, load_write);
+       plugin_register (MODULE_NAME, load_init,
+#if LOAD_HAVE_READ
+                       load_read,
+#else
+                       NULL,
+#endif
+                       load_write);
 }
 
 #undef MODULE_NAME
-#endif /* COLLECT_LOAD */