Merge branch 'collectd-5.5'
authorFlorian Forster <octo@collectd.org>
Thu, 18 Jun 2015 14:55:53 +0000 (16:55 +0200)
committerFlorian Forster <octo@collectd.org>
Thu, 18 Jun 2015 14:55:53 +0000 (16:55 +0200)
1  2 
src/Makefile.am
src/daemon/configfile.c
src/modbus.c
src/snmp.c
src/tail.c

diff --combined src/Makefile.am
@@@ -954,7 -954,7 +954,7 @@@ pkglib_LTLIBRARIES += statsd.l
  statsd_la_SOURCES = statsd.c \
                      utils_latency.h utils_latency.c
  statsd_la_LDFLAGS = $(PLUGIN_LDFLAGS)
- statsd_la_LIBADD = -lpthread
+ statsd_la_LIBADD = -lpthread -lm
  endif
  
  if BUILD_PLUGIN_SWAP
@@@ -1288,13 -1288,6 +1288,13 @@@ endi
  
  BUILT_SOURCES += $(dist_man_MANS)
  
 +if BUILD_PLUGIN_ZONE
 +pkglib_LTLIBRARIES += zone.la
 +zone_la_SOURCES = zone.c
 +zone_la_CFLAGS = $(AM_CFLAGS)
 +zone_la_LDFLAGS = $(PLUGIN_LDFLAGS)
 +endif
 +
  dist_man_MANS = collectd.1 \
                collectd.conf.5 \
                collectd-email.5 \
diff --combined src/daemon/configfile.c
@@@ -156,9 -156,12 +156,12 @@@ static int cf_dispatch (const char *typ
        int ret;
        int i;
  
+       if (orig_key == NULL)
+               return (EINVAL);
        DEBUG ("type = %s, key = %s, value = %s",
                        ESCAPE_NULL(type),
-                       ESCAPE_NULL(orig_key),
+                       orig_key,
                        ESCAPE_NULL(orig_value));
  
        if ((cf_cb = cf_search (type)) == NULL)
        free (key);
        free (value);
  
-       DEBUG ("cf_dispatch: return (%i)", ret);
        return (ret);
  } /* int cf_dispatch */
  
@@@ -289,25 -290,20 +290,25 @@@ static int dispatch_loadplugin (oconfig
        /* default to the global interval set before loading this plugin */
        memset (&ctx, 0, sizeof (ctx));
        ctx.interval = cf_get_default_interval ();
 +      ctx.flush_interval = 0;
 +      ctx.flush_timeout = 0;
  
 -      for (i = 0; i < ci->children_num; ++i) {
 -              if (strcasecmp("Globals", ci->children[i].key) == 0)
 -                      cf_util_get_flag (ci->children + i, &flags, PLUGIN_FLAGS_GLOBAL);
 -              else if (strcasecmp ("Interval", ci->children[i].key) == 0) {
 -                      if (cf_util_get_cdtime (ci->children + i, &ctx.interval) != 0) {
 -                              /* cf_util_get_cdtime will log an error */
 -                              continue;
 -                      }
 -              }
 +      for (i = 0; i < ci->children_num; ++i)
 +      {
 +              oconfig_item_t *child = ci->children + i;
 +
 +              if (strcasecmp("Globals", child->key) == 0)
 +                      cf_util_get_flag (child, &flags, PLUGIN_FLAGS_GLOBAL);
 +              else if (strcasecmp ("Interval", child->key) == 0)
 +                      cf_util_get_cdtime (child, &ctx.interval);
 +              else if (strcasecmp ("FlushInterval", child->key) == 0)
 +                      cf_util_get_cdtime (child, &ctx.flush_interval);
 +              else if (strcasecmp ("FlushTimeout", child->key) == 0)
 +                      cf_util_get_cdtime (child, &ctx.flush_timeout);
                else {
                        WARNING("Ignoring unknown LoadPlugin option \"%s\" "
                                        "for plugin \"%s\"",
 -                                      ci->children[i].key, ci->values[0].value.string);
 +                                      child->key, ci->values[0].value.string);
                }
        }
  
@@@ -759,6 -755,9 +760,9 @@@ static oconfig_item_t *cf_read_dir (con
                filenames[filenames_num - 1] = sstrdup (name);
        }
  
+       if (filenames == NULL)
+               return (root);
        qsort ((void *) filenames, filenames_num, sizeof (*filenames),
                        cf_compare_string);
  
diff --combined src/modbus.c
@@@ -426,7 -426,7 +426,7 @@@ static int mb_read_data (mb_host_t *hos
    uint16_t values[2];
    int values_num;
    const data_set_t *ds;
-   int status;
+   int status = 0;
  
    if ((host == NULL) || (slave == NULL) || (data == NULL))
      return (EINVAL);
@@@ -1014,15 -1014,18 +1014,15 @@@ static int mb_config_add_host (oconfig_
    {
      user_data_t ud;
      char name[1024];
 -    struct timespec interval = { 0, 0 };
  
      ud.data = host;
      ud.free_func = host_free;
  
      ssnprintf (name, sizeof (name), "modbus-%s", host->host);
  
 -    CDTIME_T_TO_TIMESPEC (host->interval, &interval);
 -
      plugin_register_complex_read (/* group = */ NULL, name,
          /* callback = */ mb_read,
 -        /* interval = */ (host->interval > 0) ? &interval : NULL,
 +        /* interval = */ host->interval,
          &ud);
    }
    else
diff --combined src/snmp.c
@@@ -645,6 -645,7 +645,6 @@@ static int csnmp_config_add_host (oconf
    /* Registration stuff. */
    char cb_name[DATA_MAX_NAME_LEN];
    user_data_t cb_data;
 -  struct timespec cb_interval;
  
    hd = (host_definition_t *) malloc (sizeof (host_definition_t));
    if (hd == NULL)
    cb_data.data = hd;
    cb_data.free_func = csnmp_host_definition_destroy;
  
 -  CDTIME_T_TO_TIMESPEC (hd->interval, &cb_interval);
 -
    status = plugin_register_complex_read (/* group = */ NULL, cb_name,
 -      csnmp_read_host, /* interval = */ &cb_interval,
 -      /* user_data = */ &cb_data);
 +      csnmp_read_host, hd->interval, /* user_data = */ &cb_data);
    if (status != 0)
    {
      ERROR ("snmp plugin: Registering complex read function failed.");
@@@ -1419,6 -1423,7 +1419,7 @@@ static int csnmp_read_table (host_defin
          data->type, ds->ds_num, data->values_len);
      return (-1);
    }
+   assert (data->values_len > 0);
  
    /* We need a copy of all the OIDs, because GETNEXT will destroy them. */
    memcpy (oid_list, data->values, data->values_len * sizeof (oid_t));
diff --combined src/tail.c
@@@ -243,7 -243,7 +243,7 @@@ static int ctail_config_add_file (oconf
    for (i = 0; i < ci->children_num; i++)
    {
      oconfig_item_t *option = ci->children + i;
-     int status;
+     int status = 0;
  
      if (strcasecmp ("Instance", option->key) == 0)
        status = cf_util_get_string (option, &plugin_instance);
@@@ -330,6 -330,7 +330,6 @@@ static int ctail_read (user_data_t *ud
  
  static int ctail_init (void)
  {
 -  struct timespec cb_interval;
    char str[255];
    user_data_t ud;
    size_t i;
    {
      ud.data = (void *)tail_match_list[i];
      ssnprintf(str, sizeof(str), "tail-%zu", i);
 -    CDTIME_T_TO_TIMESPEC (tail_match_list_intervals[i], &cb_interval);
 -    plugin_register_complex_read (NULL, str, ctail_read, &cb_interval, &ud);
 +    plugin_register_complex_read (NULL, str, ctail_read, tail_match_list_intervals[i], &ud);
    }
  
    return (0);