Merge branch 'collectd-3.9'
[collectd.git] / src / processes.c
index 22d8c04..dba29ef 100644 (file)
@@ -1,6 +1,7 @@
 /**
  * collectd - src/processes.c
  * Copyright (C) 2005  Lyonel Vincent
+ * Copyright (C) 2006  Florian Forster (Mach code)
  *
  * 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
@@ -69,7 +70,7 @@
 
 #define MODULE_NAME "processes"
 
-#if HAVE_THREAD_INFO || defined(KERNEL_LINUX)
+#if HAVE_THREAD_INFO || KERNEL_LINUX
 # define PROCESSES_HAVE_READ 1
 #else
 # define PROCESSES_HAVE_READ 0
@@ -160,6 +161,9 @@ static void ps_submit (int running,
                                blocked) >= BUFSIZE)
                return;
 
+       DBG ("running = %i; sleeping = %i; zombies = %i; stopped = %i; paging = %i; blocked = %i;",
+                       running, sleeping, zombies, stopped, paging, blocked);
+
        plugin_submit (MODULE_NAME, "-", buf);
 }
 
@@ -330,6 +334,8 @@ static void ps_read (void)
                                        mach_error_string (status));
                }
        } /* for (pset_list) */
+
+       ps_submit (running, sleeping, zombies, stopped, -1, blocked);
 /* #endif HAVE_THREAD_INFO */
 
 #elif KERNEL_LINUX
@@ -366,12 +372,15 @@ static void ps_read (void)
 
                if ((fh = fopen (filename, "r")) == NULL)
                {
-                       syslog (LOG_ERR, "Cannot open `%s': %s", filename, strerror (errno));
+                       syslog (LOG_NOTICE, "Cannot open `%s': %s", filename,
+                                       strerror (errno));
                        continue;
                }
 
                if (fgets (buf, BUFSIZE, fh) == NULL)
                {
+                       syslog (LOG_NOTICE, "Unable to read from `%s': %s",
+                                       filename, strerror (errno));
                        fclose (fh);
                        continue;
                }
@@ -379,7 +388,10 @@ static void ps_read (void)
                fclose (fh);
 
                if (strsplit (buf, fields, BUFSIZE) < 3)
+               {
+                       DBG ("Line has less than three fields.");
                        continue;
+               }
 
                switch (fields[2][0])
                {
@@ -392,7 +404,7 @@ static void ps_read (void)
                }
        }
 
-       closedir(proc);
+       closedir (proc);
 
        ps_submit (running, sleeping, zombies, stopped, paging, blocked);
 #endif /* KERNEL_LINUX */