Merge branch 'collectd-5.3' into collectd-5.4
authorMarc Fournier <marc.fournier@camptocamp.com>
Tue, 19 May 2015 20:44:15 +0000 (22:44 +0200)
committerMarc Fournier <marc.fournier@camptocamp.com>
Tue, 19 May 2015 20:44:15 +0000 (22:44 +0200)
configure.ac
src/curl_xml.c
src/java.c
src/liboconfig/oconfig.c
src/processes.c
src/zfs_arc.c

index 8f7d681..554a58b 100644 (file)
@@ -4954,6 +4954,7 @@ fi
 if test "x$with_kstat" = "xyes"
 then
        plugin_nfs="yes"
+       plugin_processes="yes"
        plugin_uptime="yes"
        plugin_zfs_arc="yes"
 fi
index 7432edf..44e920c 100644 (file)
@@ -341,6 +341,7 @@ static int cx_handle_single_value_xpath (xmlXPathContextPtr xpath_ctx, /* {{{ */
 
   /* free up object */
   xmlXPathFreeObject (values_node_obj);
+  sfree (node_value);
 
   /* We have reached here which means that
    * we have got something to work */
@@ -385,7 +386,7 @@ static int cx_handle_instance_xpath (xmlXPathContextPtr xpath_ctx, /* {{{ */
   /* If the base xpath returns more than one block, the result is assumed to be
    * a table. The `Instance' option is not optional in this case. Check for the
    * condition and inform the user. */
-  if (is_table)
+  if (is_table && (xpath->instance == NULL))
   {
     WARNING ("curl_xml plugin: "
         "Base-XPath %s is a table (more than one result was returned), "
@@ -438,8 +439,12 @@ static int cx_handle_instance_xpath (xmlXPathContextPtr xpath_ctx, /* {{{ */
   if (xpath->instance_prefix != NULL)
   {
     if (instance_node != NULL)
+    {
+      char *node_value = (char *) xmlNodeGetContent(instance_node->nodeTab[0]);
       ssnprintf (vl->type_instance, sizeof (vl->type_instance),"%s%s",
-          xpath->instance_prefix, (char *) xmlNodeGetContent(instance_node->nodeTab[0]));
+          xpath->instance_prefix, node_value);
+      sfree (node_value);
+    }
     else
       sstrncpy (vl->type_instance, xpath->instance_prefix,
           sizeof (vl->type_instance));
@@ -449,8 +454,11 @@ static int cx_handle_instance_xpath (xmlXPathContextPtr xpath_ctx, /* {{{ */
     /* If instance_prefix and instance_node are NULL, then
      * don't set the type_instance */
     if (instance_node != NULL)
-      sstrncpy (vl->type_instance, (char *) xmlNodeGetContent(instance_node->nodeTab[0]),
-          sizeof (vl->type_instance));
+    {
+      char *node_value = (char *) xmlNodeGetContent(instance_node->nodeTab[0]);
+      sstrncpy (vl->type_instance, node_value, sizeof (vl->type_instance));
+      sfree (node_value);
+    }
   }
 
   /* Free `instance_node_obj' this late, because `instance_node' points to
index 83cd353..10d837e 100644 (file)
@@ -3051,10 +3051,8 @@ static int cjni_init (void) /* {{{ */
 
   if (config_block != NULL)
   {
-
     cjni_config_perform (config_block);
     oconfig_free (config_block);
-    config_block = NULL;
   }
 
   if (jvm == NULL)
index 629775a..181eadd 100644 (file)
@@ -187,7 +187,7 @@ oconfig_item_t *oconfig_clone (const oconfig_item_t *ci_orig)
   return (ci_copy);
 } /* oconfig_item_t *oconfig_clone */
 
-void oconfig_free (oconfig_item_t *ci)
+void oconfig_free_all (oconfig_item_t *ci)
 {
   int i;
 
@@ -206,12 +206,19 @@ void oconfig_free (oconfig_item_t *ci)
     free (ci->values);
 
   for (i = 0; i < ci->children_num; i++)
-    oconfig_free (ci->children + i);
+    oconfig_free_all (ci->children + i);
 
   if (ci->children != NULL)
     free (ci->children);
 }
 
+void oconfig_free (oconfig_item_t *ci)
+{
+  oconfig_free_all (ci);
+  free (ci);
+  ci = NULL;
+}
+
 /*
  * vim:shiftwidth=2:tabstop=8:softtabstop=2:fdm=marker
  */
index b978919..e8839df 100644 (file)
 /* #endif HAVE_PROCINFO_H */
 
 #elif KERNEL_SOLARIS
+/* Hack: Avoid #error when building a 32-bit binary with
+ * _FILE_OFFSET_BITS=64. There is a reason for this #error, as one
+ * of the structures in <sys/procfs.h> uses an off_t, but that
+ * isn't relevant to our usage of procfs. */
+#if !defined(_LP64) && _FILE_OFFSET_BITS == 64
+#  define SAVE_FOB_64
+#  undef _FILE_OFFSET_BITS
+#endif
+
 # include <procfs.h>
+
+#ifdef SAVE_FOB_64
+#  define _FILE_OFFSET_BITS 64
+#  undef SAVE_FOB_64
+#endif
+
 # include <dirent.h>
 /* #endif KERNEL_SOLARIS */
 
@@ -1195,17 +1210,17 @@ static int read_fork_rate ()
 #endif /*KERNEL_LINUX */
 
 #if KERNEL_SOLARIS
-static const char *ps_get_cmdline (pid_t pid, /* {{{ */
+static const char *ps_get_cmdline (long pid, /* {{{ */
                char *buffer, size_t buffer_size)
 {
        char path[PATH_MAX];
        psinfo_t info;
        int status;
 
-       snprintf(path, sizeof (path), "/proc/%i/psinfo", pid);
+       snprintf(path, sizeof (path), "/proc/%li/psinfo", pid);
 
        status = read_file_contents (path, (void *) &info, sizeof (info));
-       if (status != ((int) buffer_size))
+       if (status != sizeof (info))
        {
                ERROR ("processes plugin: Unexpected return value "
                                "while reading \"%s\": "
@@ -1226,7 +1241,7 @@ static const char *ps_get_cmdline (pid_t pid, /* {{{ */
  * The values for input and ouput chars are calculated "by hand"
  * Added a few "solaris" specific process states as well
  */
-static int ps_read_process(int pid, procstat_t *ps, char *state)
+static int ps_read_process(long pid, procstat_t *ps, char *state)
 {
        char filename[64];
        char f_psinfo[64], f_usage[64];
@@ -1236,9 +1251,9 @@ static int ps_read_process(int pid, procstat_t *ps, char *state)
        psinfo_t *myInfo;
        prusage_t *myUsage;
 
-       snprintf(filename, sizeof (filename), "/proc/%i/status", pid);
-       snprintf(f_psinfo, sizeof (f_psinfo), "/proc/%i/psinfo", pid);
-       snprintf(f_usage, sizeof (f_usage), "/proc/%i/usage", pid);
+       snprintf(filename, sizeof (filename), "/proc/%li/status", pid);
+       snprintf(f_psinfo, sizeof (f_psinfo), "/proc/%li/psinfo", pid);
+       snprintf(f_usage, sizeof (f_usage), "/proc/%li/usage", pid);
 
 
        buffer = malloc(sizeof (pstatus_t));
@@ -2088,14 +2103,16 @@ static int ps_read (void)
 
        while ((ent = readdir(proc)) != NULL)
        {
-               int pid;
+               long pid;
                struct procstat ps;
                procstat_entry_t pse;
+               char *endptr;
 
                if (!isdigit ((int) ent->d_name[0]))
                        continue;
 
-               if ((pid = atoi (ent->d_name)) < 1)
+               pid = strtol (ent->d_name, &endptr, 10);
+               if (*endptr != 0) /* value didn't completely parse as a number */
                        continue;
 
                status = ps_read_process (pid, &ps, &state);
@@ -2145,8 +2162,7 @@ static int ps_read (void)
 
 
                ps_list_add (ps.name,
-                               ps_get_cmdline ((pid_t) pid,
-                                       cmdline, sizeof (cmdline)),
+                               ps_get_cmdline (pid, cmdline, sizeof (cmdline)),
                                &pse);
        } /* while(readdir) */
        closedir (proc);
index 96ffc54..3a54ad8 100644 (file)
@@ -158,7 +158,14 @@ static int za_read (void)
 
        /* Sizes */
        za_read_gauge (ksp, "size",    "cache_size", "arc");
-       za_read_gauge (ksp, "l2_size", "cache_size", "L2");
+
+       /* The "l2_size" value has disappeared from Solaris some time in
+        * early 2013, and has only reappeared recently in Solaris 11.2.
+        * Stop trying if we ever fail to read it, so we don't spam the log.
+        */
+       static int l2_size_avail = 1;
+       if (l2_size_avail && za_read_gauge (ksp, "l2_size", "cache_size", "L2") != 0)
+               l2_size_avail = 0;
 
        /* Operations */
        za_read_derive (ksp, "deleted",  "cache_operation", "deleted");