From: Florian Forster Date: Mon, 14 Jan 2013 09:53:29 +0000 (+0100) Subject: Merge branch 'collectd-5.2' X-Git-Tag: collectd-5.3.0~65 X-Git-Url: https://git.octo.it/?a=commitdiff_plain;h=33e60ef35f745c56b1a5936272b1dd8b0cf63d12;hp=1633a3ea44885c3d09f2b43f26956adee2fbb4a4;p=collectd.git Merge branch 'collectd-5.2' --- diff --git a/README b/README index 67cac046..45dcadb8 100644 --- 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. diff --git a/contrib/collection3/etc/collection.conf b/contrib/collection3/etc/collection.conf index 3bb3d8b1..5d1024fb 100644 --- a/contrib/collection3/etc/collection.conf +++ b/contrib/collection3/etc/collection.conf @@ -2,7 +2,7 @@ GraphWidth 400 #UnixSockAddr "/var/run/collectd-unixsock" - DataSources count + DataSources value DSName "count Bytes/s" RRDTitle "Apache Traffic" RRDVerticalLabel "Bytes/s" @@ -10,7 +10,7 @@ GraphWidth 400 Color count 0000ff - DataSources count + DataSources value DSName "count Requests/s" RRDTitle "Apache Traffic" RRDVerticalLabel "Requests/s" @@ -19,7 +19,7 @@ GraphWidth 400 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" - DataSources conntrack + DataSources value DSName conntrack Conntrack count RRDTitle "nf_conntrack connections on {hostname}" RRDVerticalLabel "Count" RRDFormat "%4.0lf" - DataSources entropy + DataSources value DSName entropy Entropy bits RRDTitle "Available entropy on {hostname}" RRDVerticalLabel "Bits" @@ -267,7 +267,7 @@ GraphWidth 400 Color value 00b000 - DataSources frequency + DataSources value DSName frequency Frequency RRDTitle "Frequency ({type_instance})" RRDVerticalLabel "Hertz" @@ -542,7 +542,7 @@ GraphWidth 400 Scale 8 - DataSources percent + DataSources value DSName percent Percent RRDTitle "Percent ({type_instance})" RRDVerticalLabel "Percent" @@ -550,7 +550,7 @@ GraphWidth 400 Color percent 0000ff - DataSources ping + DataSources value DSName "ping Latency" RRDTitle "Network latency ({type_instance})" RRDVerticalLabel "Milliseconds" @@ -700,7 +700,7 @@ GraphWidth 400 Scale 0.001 - DataSources users + DataSources value DSName users Users RRDTitle "Users ({type_instance}) on {hostname}" RRDVerticalLabel "Users" diff --git a/src/Makefile.am b/src/Makefile.am index 26c2355e..73e2df38 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -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 \ diff --git a/src/apcups.c b/src/apcups.c index dd535b15..ee15b14f 100644 --- a/src/apcups.c +++ b/src/apcups.c @@ -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 index 00000000..5f1b630d --- /dev/null +++ b/src/collectd-tg.pod @@ -0,0 +1,65 @@ +=head1 NAME + +collectd-tg - Traffic generator for collectd. + +=head1 SYNOPSIS + +collectd-tg B<-n> I B<-H> I B<-p> I B<-i> I B<-d> I B<-D> I + +=head1 DESCRIPTION + +B generates bogus I 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. 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 + +Sets the number of unique I (VL) to generate. Defaults to 10000. + +=item B<-H> I + +Sets the number of unique hosts to simulate. Defaults to 1000. + +=item B<-p> I + +Sets the number of unique plugins to simulate. Defaults to 20. + +=item B<-i> I + +Sets the interval in which each I is dispatched. Defaults to 10.0 +seconds. + +=item B<-d> I + +Sets the destination to which to send the generated network traffic. Defaults +to the IPv6 multicast address, C. + +=item B<-D> I + +Sets the destination port or service to which to send the generated network +traffic. Defaults to I default port, C<25826>. + +=item B<-h> + +Print usage summary. + +=back + +=head1 SEE ALSO + +L, +L + +=head1 AUTHOR + +Florian Forster EoctoEatEcollectd.orgE + +=cut diff --git a/src/collectd.conf.in b/src/collectd.conf.in index a565a579..81d70552 100644 --- a/src/collectd.conf.in +++ b/src/collectd.conf.in @@ -16,7 +16,16 @@ #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: # +# # +# Interval 60 # +# # +#----------------------------------------------------------------------------# #Interval 10 + #Timeout 2 #ReadThreads 5 @@ -753,6 +762,11 @@ # ValuesFrom "count" # # +# +# # See contrib/postgresql/collectd_insert.sql for details +# Statement "SELECT collectd_insert($1, $2, $3, $4, $5, $6, $7, $8, $9);" +# StoreRates true +# # # Host "hostname" # Port "5432" @@ -768,6 +782,12 @@ # Query backend # predefined # Query rt36_tickets # +# +# Service "collectd_store" +# Writer sqlstore +# # see collectd.conf(5) for details +# CommitInterval 30 +# # # diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod index b9f9549d..c5d7400a 100644 --- a/src/collectd.conf.pod +++ b/src/collectd.conf.pod @@ -502,7 +502,7 @@ mode will be used, i.e. delivery is guaranteed. If set to B (the default), the I delivery mode will be used, i.e. messages may be lost due to high load, overflowing queues or similar issues. -=item B B|B (Publish only) +=item B B|B|B (Publish only) Selects the format in which messages are sent to the broker. If set to B (the default), values are sent as C commands which are diff --git a/src/dbi.c b/src/dbi.c index caa41ef6..e15de3e8 100644 --- a/src/dbi.c +++ b/src/dbi.c @@ -193,33 +193,6 @@ static void cdbi_database_free (cdbi_database_t *db) /* {{{ */ * */ -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); diff --git a/src/ethstat.c b/src/ethstat.c index 08381a82..dec14f3d 100644 --- a/src/ethstat.c +++ b/src/ethstat.c @@ -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 : */ diff --git a/src/libcollectdclient/network_buffer.c b/src/libcollectdclient/network_buffer.c index 0b34e1f4..acbe93f5 100644 --- a/src/libcollectdclient/network_buffer.c +++ b/src/libcollectdclient/network_buffer.c @@ -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 */ diff --git a/src/postgresql.c b/src/postgresql.c index 15d4666b..6c9ab44e 100644 --- a/src/postgresql.c +++ b/src/postgresql.c @@ -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; } diff --git a/src/redis.c b/src/redis.c index 439cf4b8..85a83546 100644 --- a/src/redis.c +++ b/src/redis.c @@ -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); diff --git a/src/types.db b/src/types.db index 25f4d7ca..0abab4bb 100644 --- a/src/types.db +++ b/src/types.db @@ -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 diff --git a/src/varnish.c b/src/varnish.c index de60e39c..602f47af 100644 --- a/src/varnish.c +++ b/src/varnish.c @@ -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 * Marc Fournier - * Florian octo Forster + * Florian octo Forster **/ /** @@ -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."); diff --git a/src/zfs_arc.c b/src/zfs_arc.c index 046b7b02..aa900193 100644 --- a/src/zfs_arc.c +++ b/src/zfs_arc.c @@ -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 */