Added apache.c/libcurl to configure.in and src/Makefile.am
[collectd.git] / src / processes.c
index 821472b..3a73189 100644 (file)
  *   Florian octo Forster <octo at verplant.org>
  **/
 
-#include "processes.h"
+#include "collectd.h"
+#include "common.h"
+#include "plugin.h"
 
-#if COLLECT_PROCESSES
 #define MODULE_NAME "processes"
 
-#include "common.h"
-#include "plugin.h"
+#ifdef KERNEL_LINUX
+# define PROCESSES_HAVE_READ 1
+#else
+# define PROCESSES_HAVE_READ 0
+#endif
+
+#define BUFSIZE 256
 
 static char *ps_file = "processes.rrd";
 
@@ -43,17 +49,17 @@ static char *ds_def[] =
 };
 static int ds_num = 6;
 
-void ps_init (void)
+static void ps_init (void)
 {
 }
 
-void ps_write (char *host, char *inst, char *val)
+static void ps_write (char *host, char *inst, char *val)
 {
        rrd_update_file (host, ps_file, val, ds_def, ds_num);
 }
 
-#define BUFSIZE 256
-void ps_submit (unsigned int running,
+#if PROCESSES_HAVE_READ
+static void ps_submit (unsigned int running,
                unsigned int sleeping,
                unsigned int zombies,
                unsigned int stopped,
@@ -71,14 +77,14 @@ void ps_submit (unsigned int running,
        plugin_submit (MODULE_NAME, "-", buf);
 }
 
-void ps_read (void)
+static void ps_read (void)
 {
 #ifdef KERNEL_LINUX
        unsigned int running, sleeping, zombies, stopped, paging, blocked;
 
        char buf[BUFSIZE];
        char filename[20]; /* need 17 bytes */
-       char *fields[256];
+       char *fields[BUFSIZE];
 
        struct dirent *ent;
        DIR *proc;
@@ -114,7 +120,7 @@ void ps_read (void)
 
                fclose (fh);
 
-               if (strsplit (buf, fields, 256) < 3)
+               if (strsplit (buf, fields, BUFSIZE) < 3)
                        continue;
 
                switch (fields[2][0])
@@ -133,12 +139,14 @@ void ps_read (void)
        ps_submit (running, sleeping, zombies, stopped, paging, blocked);
 #endif /* defined(KERNEL_LINUX) */
 }
-#undef BUFSIZE
+#else
+# define ps_read NULL
+#endif /* PROCESSES_HAVE_READ */
 
 void module_register (void)
 {
        plugin_register (MODULE_NAME, ps_init, ps_read, ps_write);
 }
 
+#undef BUFSIZE
 #undef MODULE_NAME
-#endif /* COLLECT_PROCESSES */