Cleaned up all the modules, unified define order and the like..
[collectd.git] / src / processes.c
index 94e86dd..d1fe696 100644 (file)
@@ -1,14 +1,37 @@
-#include "processes.h"
-
-/*
- * Originally written by Lyonel Vincent
- */
+/**
+ * collectd - src/processes.c
+ * Copyright (C) 2005  Lyonel Vincent
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ *
+ * Authors:
+ *   Lyonel Vincent <lyonel at ezix.org>
+ *   Florian octo Forster <octo at verplant.org>
+ **/
+
+#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
 
 static char *ps_file = "processes.rrd";
 
@@ -24,19 +47,17 @@ static char *ds_def[] =
 };
 static int ds_num = 6;
 
-extern time_t curtime;
-
-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,
+static void ps_submit (unsigned int running,
                unsigned int sleeping,
                unsigned int zombies,
                unsigned int stopped,
@@ -54,7 +75,8 @@ void ps_submit (unsigned int running,
        plugin_submit (MODULE_NAME, "-", buf);
 }
 
-void ps_read (void)
+#if PROCESSES_HAVE_READ
+static void ps_read (void)
 {
 #ifdef KERNEL_LINUX
        unsigned int running, sleeping, zombies, stopped, paging, blocked;
@@ -75,8 +97,6 @@ void ps_read (void)
                return;
        }
 
-       int strsplit (char *string, char **fields, size_t size);
-
        while ((ent = readdir (proc)) != NULL)
        {
                if (!isdigit (ent->d_name[0]))
@@ -118,6 +138,9 @@ void ps_read (void)
        ps_submit (running, sleeping, zombies, stopped, paging, blocked);
 #endif /* defined(KERNEL_LINUX) */
 }
+#else
+# define ps_read NULL
+#endif /* PROCESSES_HAVE_READ */
 #undef BUFSIZE
 
 void module_register (void)
@@ -126,4 +149,3 @@ void module_register (void)
 }
 
 #undef MODULE_NAME
-#endif /* COLLECT_PROCESSES */