Merge branch 'collectd-5.2'
authorFlorian Forster <octo@collectd.org>
Mon, 14 Jan 2013 09:53:29 +0000 (10:53 +0100)
committerFlorian Forster <octo@collectd.org>
Mon, 14 Jan 2013 09:53:29 +0000 (10:53 +0100)
15 files changed:
README
contrib/collection3/etc/collection.conf
src/Makefile.am
src/apcups.c
src/collectd-tg.pod [new file with mode: 0644]
src/collectd.conf.in
src/collectd.conf.pod
src/dbi.c
src/ethstat.c
src/libcollectdclient/network_buffer.c
src/postgresql.c
src/redis.c
src/types.db
src/varnish.c
src/zfs_arc.c

diff --git a/README b/README
index 67cac04..45dcadb 100644 (file)
--- a/README
+++ b/README
@@ -222,6 +222,9 @@ Features
       write your own plugins in Perl and return arbitrary values using this
       API. See collectd-perl(5).
 
+    - pf
+      Query statistics from BSD's packet filter "pf".
+
     - pinba
       Receive and dispatch timing values from Pinba, a profiling extension for
       PHP.
@@ -458,6 +461,10 @@ Features
 
   * Miscellaneous plugins:
 
+    - aggregation
+      Selects multiple value lists based on patterns or regular expressions
+      and creates new aggregated values lists from those.
+
     - threshold
       Checks values against configured thresholds and creates notifications if
       values are out of bounds. See collectd-threshold(5) for details.
index 3bb3d8b..5d1024f 100644 (file)
@@ -2,7 +2,7 @@
 GraphWidth 400
 #UnixSockAddr "/var/run/collectd-unixsock"
 <Type apache_bytes>
-  DataSources count
+  DataSources value
   DSName "count Bytes/s"
   RRDTitle "Apache Traffic"
   RRDVerticalLabel "Bytes/s"
@@ -10,7 +10,7 @@ GraphWidth 400
   Color count 0000ff
 </Type>
 <Type apache_requests>
-  DataSources count
+  DataSources value
   DSName "count Requests/s"
   RRDTitle "Apache Traffic"
   RRDVerticalLabel "Requests/s"
@@ -19,7 +19,7 @@ GraphWidth 400
 </Type>
 <Type apache_scoreboard>
   Module GenericStacked
-  DataSources count
+  DataSources value
   RRDTitle "Apache scoreboard on {hostname}"
   RRDVerticalLabel "Slots"
   RRDFormat "%6.2lf"
@@ -245,14 +245,14 @@ GraphWidth 400
   RRDFormat "%6.1lf"
 </Type>
 <Type conntrack>
-  DataSources conntrack
+  DataSources value
   DSName conntrack Conntrack count
   RRDTitle "nf_conntrack connections on {hostname}"
   RRDVerticalLabel "Count"
   RRDFormat "%4.0lf"
 </Type>
 <Type entropy>
-  DataSources entropy
+  DataSources value
   DSName entropy Entropy bits
   RRDTitle "Available entropy on {hostname}"
   RRDVerticalLabel "Bits"
@@ -267,7 +267,7 @@ GraphWidth 400
   Color value 00b000
 </Type>
 <Type frequency>
-  DataSources frequency
+  DataSources value
   DSName frequency Frequency
   RRDTitle "Frequency ({type_instance})"
   RRDVerticalLabel "Hertz"
@@ -542,7 +542,7 @@ GraphWidth 400
   Scale 8
 </Type>
 <Type percent>
-  DataSources percent
+  DataSources value
   DSName percent Percent
   RRDTitle "Percent ({type_instance})"
   RRDVerticalLabel "Percent"
@@ -550,7 +550,7 @@ GraphWidth 400
   Color percent 0000ff
 </Type>
 <Type ping>
-  DataSources ping
+  DataSources value
   DSName "ping Latency"
   RRDTitle "Network latency ({type_instance})"
   RRDVerticalLabel "Milliseconds"
@@ -700,7 +700,7 @@ GraphWidth 400
   Scale 0.001
 </Type>
 <Type users>
-  DataSources users
+  DataSources value
   DSName users Users
   RRDTitle "Users ({type_instance}) on {hostname}"
   RRDVerticalLabel "Users"
index 26c2355..73e2df3 100644 (file)
@@ -119,6 +119,9 @@ collectd_tg_LDADD =
 if BUILD_WITH_LIBSOCKET
 collectd_tg_LDADD += -lsocket
 endif
+if BUILD_WITH_LIBRT
+collectd_tg_LDADD += -lrt
+endif
 if BUILD_AIX
 collectd_tg_LDADD += -lm
 endif
@@ -1369,6 +1372,7 @@ dist_man_MANS = collectd.1 \
                collectd-perl.5 \
                collectd-python.5 \
                collectd-snmp.5 \
+               collectd-tg.1 \
                collectd-threshold.5 \
                collectd-unixsock.5 \
                types.db.5
@@ -1388,6 +1392,7 @@ EXTRA_DIST +=   collectd.conf.pod \
                collectd-python.pod \
                collectd.pod \
                collectd-snmp.pod \
+               collectd-tg.pod \
                collectd-threshold.pod \
                collectd-unixsock.pod \
                postgresql_default.conf \
index dd535b1..ee15b14 100644 (file)
@@ -465,7 +465,7 @@ static int apcups_read (void)
        apcups_detail.battv    =   -1.0;
        apcups_detail.loadpct  =   -1.0;
        apcups_detail.bcharge  =   -1.0;
-       apcups_detail.timeleft =   -1.0;
+       apcups_detail.timeleft =    NAN;
        apcups_detail.itemp    = -300.0;
        apcups_detail.linefreq =   -1.0;
 
diff --git a/src/collectd-tg.pod b/src/collectd-tg.pod
new file mode 100644 (file)
index 0000000..5f1b630
--- /dev/null
@@ -0,0 +1,65 @@
+=head1 NAME
+
+collectd-tg - Traffic generator for collectd.
+
+=head1 SYNOPSIS
+
+collectd-tg B<-n> I<num_vl> B<-H> I<num_hosts> B<-p> I<num_plugins> B<-i> I<interval> B<-d> I<dest> B<-D> I<dport>
+
+=head1 DESCRIPTION
+
+B<collectd-tg> generates bogus I<collectd> network traffic. While host, plugin
+and values are generated randomly, the generated traffic tries to mimic "real"
+traffic as closely as possible.
+
+=head1 ARGUMENTS AND OPTIONS
+
+The following options are understood by I<collectd-tg>. The order of the
+arguments generally doesn't matter, as long as no argument is passed more than
+once.
+
+=over 4
+
+=item B<-n> I<num_vl>
+
+Sets the number of unique I<value lists> (VL) to generate. Defaults to 10000.
+
+=item B<-H> I<num_hosts>
+
+Sets the number of unique hosts to simulate. Defaults to 1000.
+
+=item B<-p> I<num_plugins>
+
+Sets the number of unique plugins to simulate. Defaults to 20.
+
+=item B<-i> I<interval>
+
+Sets the interval in which each I<value list> is dispatched. Defaults to 10.0
+seconds.
+
+=item B<-d> I<dest>
+
+Sets the destination to which to send the generated network traffic. Defaults
+to the IPv6 multicast address, C<ff18::efc0:4a42>.
+
+=item B<-D> I<dport>
+
+Sets the destination port or service to which to send the generated network
+traffic. Defaults to I<collectd's> default port, C<25826>.
+
+=item B<-h>
+
+Print usage summary.
+
+=back
+
+=head1 SEE ALSO
+
+L<collectd(1)>,
+L<collectd.conf(5)>
+
+=head1 AUTHOR
+
+Florian Forster E<lt>octoE<nbsp>atE<nbsp>collectd.orgE<gt>
+
+=cut
index a565a57..81d7055 100644 (file)
 #PIDFile     "@localstatedir@/run/@PACKAGE_NAME@.pid"
 #PluginDir   "@libdir@/@PACKAGE_NAME@"
 #TypesDB     "@prefix@/share/@PACKAGE_NAME@/types.db"
+
+#----------------------------------------------------------------------------#
+# Interval at which to query values. This may be overwritten on a per-plugin #
+# base by using the 'Interval' option of the LoadPlugin block:               #
+#   <LoadPlugin foo>                                                         #
+#       Interval 60                                                          #
+#   </LoadPlugin>                                                            #
+#----------------------------------------------------------------------------#
 #Interval     10
+
 #Timeout      2
 #ReadThreads  5
 
 #                      ValuesFrom "count"
 #              </Result>
 #      </Query>
+#      <Writer sqlstore>
+#              # See contrib/postgresql/collectd_insert.sql for details
+#              Statement "SELECT collectd_insert($1, $2, $3, $4, $5, $6, $7, $8, $9);"
+#              StoreRates true
+#      </Writer>
 #      <Database foo>
 #              Host "hostname"
 #              Port "5432"
 #              Query backend # predefined
 #              Query rt36_tickets
 #      </Database>
+#      <Database qux>
+#              Service "collectd_store"
+#              Writer sqlstore
+#              # see collectd.conf(5) for details
+#              CommitInterval 30
+#      </Database>
 #</Plugin>
 
 #<Plugin powerdns>
index b9f9549..c5d7400 100644 (file)
@@ -502,7 +502,7 @@ mode will be used, i.e. delivery is guaranteed. If set to B<false> (the
 default), the I<transient> delivery mode will be used, i.e. messages may be
 lost due to high load, overflowing queues or similar issues.
 
-=item B<Format> B<Command>|B<JSON> (Publish only)
+=item B<Format> B<Command>|B<JSON>|B<Graphite> (Publish only)
 
 Selects the format in which messages are sent to the broker. If set to
 B<Command> (the default), values are sent as C<PUTVAL> commands which are
index caa41ef..e15de3e 100644 (file)
--- a/src/dbi.c
+++ b/src/dbi.c
@@ -193,33 +193,6 @@ static void cdbi_database_free (cdbi_database_t *db) /* {{{ */
  * </Plugin>
  */
 
-static int cdbi_config_set_string (char **ret_string, /* {{{ */
-    oconfig_item_t *ci)
-{
-  char *string;
-
-  if ((ci->values_num != 1)
-      || (ci->values[0].type != OCONFIG_TYPE_STRING))
-  {
-    WARNING ("dbi plugin: The `%s' config option "
-        "needs exactly one string argument.", ci->key);
-    return (-1);
-  }
-
-  string = strdup (ci->values[0].value.string);
-  if (string == NULL)
-  {
-    ERROR ("dbi plugin: strdup failed.");
-    return (-1);
-  }
-
-  if (*ret_string != NULL)
-    free (*ret_string);
-  *ret_string = string;
-
-  return (0);
-} /* }}} int cdbi_config_set_string */
-
 static int cdbi_config_add_database_driver_option (cdbi_database_t *db, /* {{{ */
     oconfig_item_t *ci)
 {
@@ -286,7 +259,7 @@ static int cdbi_config_add_database (oconfig_item_t *ci) /* {{{ */
   }
   memset (db, 0, sizeof (*db));
 
-  status = cdbi_config_set_string (&db->name, ci);
+  status = cf_util_get_string (ci, &db->name);
   if (status != 0)
   {
     sfree (db);
@@ -299,11 +272,11 @@ static int cdbi_config_add_database (oconfig_item_t *ci) /* {{{ */
     oconfig_item_t *child = ci->children + i;
 
     if (strcasecmp ("Driver", child->key) == 0)
-      status = cdbi_config_set_string (&db->driver, child);
+      status = cf_util_get_string (child, &db->driver);
     else if (strcasecmp ("DriverOption", child->key) == 0)
       status = cdbi_config_add_database_driver_option (db, child);
     else if (strcasecmp ("SelectDB", child->key) == 0)
-      status = cdbi_config_set_string (&db->select_db, child);
+      status = cf_util_get_string (child, &db->select_db);
     else if (strcasecmp ("Query", child->key) == 0)
       status = udb_query_pick_from_list (child, queries, queries_num,
           &db->queries, &db->queries_num);
index 08381a8..dec14f3 100644 (file)
@@ -73,7 +73,7 @@ static int ethstat_add_interface (const oconfig_item_t *ci) /* {{{ */
     return (status);
 
   interfaces_num++;
-  INFO("ethstat plugin: Registred interface %s",
+  INFO("ethstat plugin: Registered interface %s",
       interfaces[interfaces_num - 1]);
 
   return (0);
@@ -83,6 +83,7 @@ static int ethstat_add_map (const oconfig_item_t *ci) /* {{{ */
 {
   value_map_t *map;
   int status;
+  char *key;
 
   if ((ci->values_num < 2)
       || (ci->values_num > 3)
@@ -96,9 +97,17 @@ static int ethstat_add_map (const oconfig_item_t *ci) /* {{{ */
     return (-1);
   }
 
+  key = strdup (ci->values[0].value.string);
+  if (key == NULL)
+  {
+    ERROR ("ethstat plugin: strdup(3) failed.");
+    return (ENOMEM);
+  }
+
   map = malloc (sizeof (*map));
   if (map == NULL)
   {
+    sfree (key);
     ERROR ("ethstat plugin: malloc(3) failed.");
     return (ENOMEM);
   }
@@ -115,23 +124,24 @@ static int ethstat_add_map (const oconfig_item_t *ci) /* {{{ */
     if (value_map == NULL)
     {
       sfree (map);
+      sfree (key);
       ERROR ("ethstat plugin: c_avl_create() failed.");
       return (-1);
     }
   }
 
   status = c_avl_insert (value_map,
-      /* key = */ ci->values[0].value.string,
+      /* key = */ key,
       /* value = */ map);
   if (status != 0)
   {
-    sfree (map);
     if (status > 0)
-      ERROR ("ethstat plugin: Multiple mappings for \"%s\".",
-          ci->values[0].value.string);
+      ERROR ("ethstat plugin: Multiple mappings for \"%s\".", key);
     else
-      ERROR ("ethstat plugin: c_avl_insert(\"%s\") failed.",
-          ci->values[0].value.string);
+      ERROR ("ethstat plugin: c_avl_insert(\"%s\") failed.", key);
+
+    sfree (map);
+    sfree (key);
     return (-1);
   }
 
@@ -328,10 +338,31 @@ static int ethstat_read(void)
   return 0;
 }
 
+static int ethstat_shutdown (void)
+{
+  void *key = NULL;
+  void *value = NULL;
+
+  if (value_map == NULL)
+    return (0);
+
+  while (c_avl_pick (value_map, &key, &value) == 0)
+  {
+    sfree (key);
+    sfree (value);
+  }
+
+  c_avl_destroy (value_map);
+  value_map = NULL;
+
+  return (0);
+}
+
 void module_register (void)
 {
   plugin_register_complex_config ("ethstat", ethstat_config);
   plugin_register_read ("ethstat", ethstat_read);
+  plugin_register_shutdown ("ethstat", ethstat_shutdown);
 }
 
 /* vim: set sw=2 sts=2 et fdm=marker : */
index 0b34e1f..acbe93f 100644 (file)
@@ -106,9 +106,11 @@ struct lcc_network_buffer_s
   char *username;
   char *password;
 
+#if HAVE_LIBGCRYPT
   gcry_cipher_hd_t encr_cypher;
   size_t encr_header_len;
   char encr_iv[16];
+#endif
 };
 
 #define SSTRNCPY(dst,src,sz) do { \
@@ -128,6 +130,7 @@ static _Bool have_gcrypt (void) /* {{{ */
     return (result);
   need_init = 0;
 
+#if HAVE_LIBGCRYPT
   gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread);
 
   if (!gcry_check_version (GCRYPT_VERSION))
@@ -138,6 +141,9 @@ static _Bool have_gcrypt (void) /* {{{ */
 
   result = 1;
   return (1);
+#else
+  return(0);
+#endif
 } /* }}} _Bool have_gcrypt */
 
 static uint64_t htonll (uint64_t val) /* {{{ */
@@ -494,6 +500,7 @@ static int nb_add_value_list (lcc_network_buffer_t *nb, /* {{{ */
   return (0);
 } /* }}} int nb_add_value_list */
 
+#if HAVE_LIBGCRYPT
 static int nb_add_signature (lcc_network_buffer_t *nb) /* {{{ */
 {
   char *buffer;
@@ -620,6 +627,7 @@ static int nb_add_encryption (lcc_network_buffer_t *nb) /* {{{ */
 
   return (0);
 } /* }}} int nb_add_encryption */
+#endif
 
 /*
  * Public functions
@@ -720,6 +728,7 @@ int lcc_network_buffer_initialize (lcc_network_buffer_t *nb) /* {{{ */
   nb->ptr = nb->buffer;
   nb->free = nb->size;
 
+#if HAVE_LIBGCRYPT
   if (nb->seclevel == SIGN)
   {
     size_t username_len;
@@ -765,6 +774,7 @@ int lcc_network_buffer_initialize (lcc_network_buffer_t *nb) /* {{{ */
     ADD_GENERIC (nb, hash, sizeof (hash));
     assert ((nb->encr_header_len + nb->free) == nb->size);
   }
+#endif
 
   return (0);
 } /* }}} int lcc_network_buffer_initialize */
@@ -774,10 +784,12 @@ int lcc_network_buffer_finalize (lcc_network_buffer_t *nb) /* {{{ */
   if (nb == NULL)
     return (EINVAL);
 
+#if HAVE_LIBGCRYPT
   if (nb->seclevel == SIGN)
     nb_add_signature (nb);
   else if (nb->seclevel == ENCRYPT)
     nb_add_encryption (nb);
+#endif
 
   return (0);
 } /* }}} int lcc_network_buffer_finalize */
index 15d4666..6c9ab44 100644 (file)
@@ -900,10 +900,10 @@ static int c_psql_write (const data_set_t *ds, const value_list_t *vl,
 
                if ((PGRES_COMMAND_OK != PQresultStatus (res))
                                && (PGRES_TUPLES_OK != PQresultStatus (res))) {
+                       PQclear (res);
+
                        if ((CONNECTION_OK != PQstatus (db->conn))
                                        && (0 == c_psql_check_connection (db))) {
-                               PQclear (res);
-
                                /* try again */
                                res = PQexecParams (db->conn, writer->statement,
                                                STATIC_ARRAY_SIZE (params), NULL,
@@ -912,6 +912,7 @@ static int c_psql_write (const data_set_t *ds, const value_list_t *vl,
 
                                if ((PGRES_COMMAND_OK == PQresultStatus (res))
                                                || (PGRES_TUPLES_OK == PQresultStatus (res))) {
+                                       PQclear (res);
                                        success = 1;
                                        continue;
                                }
@@ -932,6 +933,8 @@ static int c_psql_write (const data_set_t *ds, const value_list_t *vl,
                        pthread_mutex_unlock (&db->db_lock);
                        return -1;
                }
+
+               PQclear (res);
                success = 1;
        }
 
index 439cf4b..85a8354 100644 (file)
@@ -33,6 +33,7 @@
 #endif
 
 #define REDIS_DEF_HOST   "localhost"
+#define REDIS_DEF_PASSWD ""
 #define REDIS_DEF_PORT    6379
 #define REDIS_DEF_TIMEOUT 2000
 #define MAX_REDIS_NODE_NAME 64
@@ -229,8 +230,8 @@ static void redis_submit_d (char *plugin_instance,
 
 static int redis_init (void) /* {{{ */
 {
-  redis_node_t rn = { "default", REDIS_DEF_HOST, REDIS_DEF_PORT,
-    REDIS_DEF_TIMEOUT, /* next = */ NULL };
+  redis_node_t rn = { "default", REDIS_DEF_HOST, REDIS_DEF_PASSWD,
+    REDIS_DEF_PORT, REDIS_DEF_TIMEOUT, /* next = */ NULL };
 
   if (nodes_head == NULL)
     redis_node_add (&rn);
index 25f4d7c..0abab4b 100644 (file)
@@ -158,7 +158,7 @@ tcp_connections             value:GAUGE:0:4294967295
 temperature            value:GAUGE:-273.15:U
 threads                        value:GAUGE:0:U
 time_dispersion                value:GAUGE:-1000000:1000000
-timeleft               value:GAUGE:0:3600
+timeleft               value:GAUGE:0:U
 time_offset            value:GAUGE:-1000000:1000000
 total_bytes            value:DERIVE:0:U
 total_connections      value:DERIVE:0:U
index de60e39..602f47a 100644 (file)
@@ -1,8 +1,8 @@
 /**
  * collectd - src/varnish.c
- * Copyright (C) 2010 Jérôme Renard
- * Copyright (C) 2010 Marc Fournier
- * Copyright (C) 2010 Florian Forster
+ * Copyright (C) 2010      Jérôme Renard
+ * Copyright (C) 2010      Marc Fournier
+ * Copyright (C) 2010-2012 Florian Forster
  *
  * 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
@@ -20,7 +20,7 @@
  * Authors:
  *   Jérôme Renard <jerome.renard at gmail.com>
  *   Marc Fournier <marc.fournier at camptocamp.com>
- *   Florian octo Forster <octo at verplant.org>
+ *   Florian octo Forster <octo at collectd.org>
  **/
 
 /**
@@ -412,11 +412,21 @@ static int varnish_read (user_data_t *ud) /* {{{ */
 
        vd = VSM_New();
        VSC_Setup(vd);
-       if (VSM_n_Arg(vd, conf->instance) == -1)
+
+       if (conf->instance != NULL)
        {
-               ERROR ("Varnish plugin : unable to load statistics from instance");
-               return (-1);
+               int status;
+
+               status = VSM_n_Arg (vd, conf->instance);
+               if (status < 0)
+               {
+                       ERROR ("varnish plugin: VSM_n_Arg (\"%s\") failed "
+                                       "with status %i.",
+                                       conf->instance, status);
+                       return (-1);
+               }
        }
+
        if (VSC_Open (vd, /* diag = */ 1))
        {
                ERROR ("varnish plugin: Unable to load statistics.");
index 046b7b0..aa90019 100644 (file)
@@ -128,7 +128,7 @@ static int za_read (void)
        za_read_derive (ksp, "stolen",   "cache_operation", "stolen");
 
         /* Issue indicators */
-        za_read_derive (ksp, "mutex_miss", "mutex_operation", "miss");
+        za_read_derive (ksp, "mutex_miss", "mutex_operations", "miss");
        za_read_derive (ksp, "hash_collisions", "hash_collisions", "");
        
         /* Evictions */