From 7f28a5bc90ffb5f2c39edd3b7ce66fcf376638da Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Mon, 17 Jun 2013 13:54:09 +0200 Subject: [PATCH] statsd plugin: Add configuration for Host and Port. --- src/collectd.conf.in | 5 +++++ src/collectd.conf.pod | 22 ++++++++++++++++++++++ src/statsd.c | 26 ++++++++++++++++++++++++++ 3 files changed, 53 insertions(+) diff --git a/src/collectd.conf.in b/src/collectd.conf.in index 7717bc34..8b616946 100644 --- a/src/collectd.conf.in +++ b/src/collectd.conf.in @@ -928,6 +928,11 @@ # # +# +# Host "::" +# Port "8125" +# + # # ReportByDevice false # ReportBytes true diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod index 541af4ce..c98b5f10 100644 --- a/src/collectd.conf.pod +++ b/src/collectd.conf.pod @@ -5103,6 +5103,28 @@ Since the configuration of the C is a little more complicated than other plugins, its documentation has been moved to an own manpage, L. Please see there for details. +=head2 Plugin C + +The I listens to a UDP socket, reads "events" in the statsd +protocol and dispatches rates or other aggregates of these numbers +periodically. + +The following configuration options are valid: + +=over 4 + +=item B I + +Bind to the hostname / address I. By default, the plugin will bind to the +"any" address, i.e. accept packets sent to any of the hosts addresses. + +=item B I + +UDP port to listen to. This can be either a service name or a port number. +Defaults to C<8125>. + +=back + =head2 Plugin C The I collects information about used and available swap space. On diff --git a/src/statsd.c b/src/statsd.c index 896fb619..5fac8d47 100644 --- a/src/statsd.c +++ b/src/statsd.c @@ -459,6 +459,27 @@ static void *statsd_network_thread (void *args) /* {{{ */ return ((void *) 0); } /* }}} void *statsd_network_thread */ +static int statsd_config (oconfig_item_t *ci) /* {{{ */ +{ + int i; + + for (i = 0; i < ci->children_num; i++) + { + oconfig_item_t *child = ci->children + i; + + if (strcasecmp ("Host", child->key) == 0) + cf_util_get_string (child, &conf_node); + else if (strcasecmp ("Port", child->key) == 0) + cf_util_get_service (child, &conf_service); + /* TODO: Add configuration for Delete{Counters,Timers,Gauges} */ + else + ERROR ("statsd plugin: The \"%s\" config option is not valid.", + child->key); + } + + return (0); +} /* }}} int statsd_config */ + static int statsd_init (void) /* {{{ */ { pthread_mutex_lock (&metrics_lock); @@ -532,6 +553,7 @@ static int statsd_read (void) /* {{{ */ } i = c_avl_get_iterator (metrics_tree); + /* TODO: Delete legacy metrics */ while (c_avl_iterator_next (i, (void *) &name, (void *) &metric) == 0) statsd_metric_submit (name, metric); c_avl_iterator_destroy (i); @@ -564,6 +586,9 @@ static int statsd_shutdown (void) /* {{{ */ c_avl_destroy (metrics_tree); metrics_tree = NULL; + sfree (conf_node); + sfree (conf_service); + pthread_mutex_unlock (&metrics_lock); return (0); @@ -571,6 +596,7 @@ static int statsd_shutdown (void) /* {{{ */ void module_register (void) { + plugin_register_complex_config ("statsd", statsd_config); plugin_register_init ("statsd", statsd_init); plugin_register_read ("statsd", statsd_read); plugin_register_shutdown ("statsd", statsd_shutdown); -- 2.30.2