Code

Merge branch 'collectd-4.6' into collectd-4.7
authorFlorian Forster <octo@leeloo.lan.home.verplant.org>
Mon, 4 May 2009 14:57:10 +0000 (16:57 +0200)
committerFlorian Forster <octo@leeloo.lan.home.verplant.org>
Mon, 4 May 2009 14:57:10 +0000 (16:57 +0200)
Conflicts:
src/filter_chain.c
src/meta_data.c
src/target_notification.c
src/target_replace.c
src/target_set.c

1  2 
src/bind.c
src/memory.c

diff --combined src/bind.c
index 783d2b057bfad46aed9ee7dbd0b82b362e4e4117,44efcfd55ba58982d6fdb2244a54ecac3b4e19b1..3d46e51e043846cf160298973d391727f56b2371
   *   Florian Forster <octo at verplant.org>
   **/
  
- /* Set to C99 and POSIX code */
- #ifndef _ISOC99_SOURCE
- # define _ISOC99_SOURCE
- #endif
- #ifndef _POSIX_SOURCE
- # define _POSIX_SOURCE
- #endif
- #ifndef _POSIX_C_SOURCE
- # define _POSIX_C_SOURCE 200112L
- #endif
- #ifndef _REENTRANT
- # define _REENTRANT
- #endif
- #ifndef _XOPEN_SOURCE
- # define _XOPEN_SOURCE 600
- #endif
- #ifndef _BSD_SOURCE
- # define _BSD_SOURCE
- #endif
+ #define _XOPEN_SOURCE 600 /* glibc2 needs this for strptime */
  
  #include "collectd.h"
  #include "common.h"
  #include "plugin.h"
  #include "configfile.h"
  
+ /* Some versions of libcurl don't include this themselves and then don't have
+  * fd_set available. */
+ #if HAVE_SYS_SELECT_H
+ # include <sys/select.h>
+ #endif
  #include <curl/curl.h>
  #include <libxml/parser.h>
  #include <libxml/xpath.h>
@@@ -239,6 -227,19 +227,6 @@@ static int memsummary_translation_table
    STATIC_ARRAY_SIZE (memsummary_translation_table);
  /* }}} */
  
 -static void remove_special (char *buffer, size_t buffer_size) /* {{{ */
 -{
 -  size_t i;
 -
 -  for (i = 0; i < buffer_size; i++)
 -  {
 -    if (buffer[i] == 0)
 -      return;
 -    if ((!isalnum ((int) buffer[i])) && (buffer[i] != '-'))
 -      buffer[i] = '_';
 -  }
 -} /* }}} void remove_special */
 -
  static void submit (time_t ts, const char *plugin_instance, /* {{{ */
      const char *type, const char *type_instance, value_t value)
  {
    if (plugin_instance) {
      sstrncpy(vl.plugin_instance, plugin_instance,
          sizeof(vl.plugin_instance));
 -    remove_special (vl.plugin_instance, sizeof (vl.plugin_instance));
 +    replace_special (vl.plugin_instance, sizeof (vl.plugin_instance));
    }
    sstrncpy(vl.type, type, sizeof(vl.type));
    if (type_instance) {
      sstrncpy(vl.type_instance, type_instance,
          sizeof(vl.type_instance));
 -    remove_special (vl.plugin_instance, sizeof (vl.plugin_instance));
 +    replace_special (vl.plugin_instance, sizeof (vl.plugin_instance));
    }
    plugin_dispatch_values(&vl);
  } /* }}} void submit */
@@@ -465,7 -466,7 +453,7 @@@ static int bind_xml_read_timestamp (con
      return (-1);
    }
  
-   *ret_value = timegm(&tm);
+   *ret_value = mktime(&tm);
  
    xmlXPathFreeObject (xpathObj);
    return (0);
diff --combined src/memory.c
index 6f0e466570e482a556f432c405cc6305c9d1f42d,6ea6205e1ca51a72569bc352294e441cb3e6aed6..799a80c31684c963172fa89363e9f931c24f4886
@@@ -1,7 -1,6 +1,7 @@@
  /**
   * collectd - src/memory.c
   * Copyright (C) 2005-2008  Florian octo Forster
 + * Copyright (C) 2009       Simon Kuhnle
   *
   * 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
@@@ -18,7 -17,6 +18,7 @@@
   *
   * Authors:
   *   Florian octo Forster <octo at verplant.org>
 + *   Simon Kuhnle <simon at blarzwurst.de>
   **/
  
  #include "collectd.h"
@@@ -68,10 -66,6 +68,10 @@@ static int pagesize
  static kstat_t *ksp;
  /* #endif HAVE_LIBKSTAT */
  
 +#elif HAVE_SYSCTL
 +static int pagesize;
 +/* #endif HAVE_SYSCTL */
 +
  #elif HAVE_LIBSTATGRAB
  /* no global variables */
  /* endif HAVE_LIBSTATGRAB */
@@@ -103,20 -97,7 +103,20 @@@ static int memory_init (void
                ksp = NULL;
                return (-1);
        }
 -#endif /* HAVE_LIBKSTAT */
 +/* #endif HAVE_LIBKSTAT */
 +
 +#elif HAVE_SYSCTL
 +      pagesize = getpagesize ();
 +      if (pagesize <= 0)
 +      {
 +              ERROR ("memory plugin: Invalid pagesize: %i", pagesize);
 +              return (-1);
 +      }
 +/* #endif HAVE_SYSCTL */
 +
 +#elif HAVE_LIBSTATGRAB
 +/* no init stuff */
 +#endif /* HAVE_LIBSTATGRAB */
  
        return (0);
  } /* int memory_init */
@@@ -227,7 -208,7 +227,7 @@@ static int memory_read (void
                                        NULL, 0) == 0)
                {
                        sysctl_vals[i] = value;
-                       DEBUG ("memory plugin: %26s: %6i", sysctl_keys[i], sysctl_vals[i]);
+                       DEBUG ("memory plugin: %26s: %g", sysctl_keys[i], sysctl_vals[i]);
                }
                else
                {
        memory_submit ("locked", mem_lock);
  /* #endif HAVE_LIBKSTAT */
  
 +#elif HAVE_SYSCTL
 +      int mib[] = {CTL_VM, VM_METER};
 +      struct vmtotal vmtotal;
 +      size_t size;
 +
 +      memset (&vmtotal, 0, sizeof (vmtotal));
 +      size = sizeof (vmtotal);
 +
 +      if (sysctl (mib, 2, &vmtotal, &size, NULL, 0) < 0) {
 +              char errbuf[1024];
 +              WARNING ("memory plugin: sysctl failed: %s",
 +                      sstrerror (errno, errbuf, sizeof (errbuf)));
 +              return (-1);
 +      }
 +
 +      assert (pagesize > 0);
 +      memory_submit ("active",   vmtotal.t_arm * pagesize);
 +      memory_submit ("inactive", (vmtotal.t_rm - vmtotal.t_arm) * pagesize);
 +      memory_submit ("free",     vmtotal.t_free * pagesize);
 +/* #endif HAVE_SYSCTL */
 +
  #elif HAVE_LIBSTATGRAB
        sg_mem_stats *ios;