From 4e2dfc0593d5fc3f28a096cd94f592758eace039 Mon Sep 17 00:00:00 2001 From: Pavel Rochnyack Date: Wed, 4 Jul 2018 14:20:54 +0700 Subject: [PATCH] curl_xml plugin: Added 'Interval' option --- src/collectd.conf.pod | 5 +++++ src/curl_xml.c | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod index ccc69491..61aeff14 100644 --- a/src/collectd.conf.pod +++ b/src/collectd.conf.pod @@ -2104,6 +2104,11 @@ Use I as the plugin instance when submitting values. May be overridden by B option inside B blocks. Defaults to an empty string (no plugin instance). +=item B I + +Sets the interval (in seconds) in which the values will be collected from this +URL. By default the global B setting will be used. + =item B I I If an XPath expression references namespaces, they must be specified diff --git a/src/curl_xml.c b/src/curl_xml.c index 654bb671..0bed05a5 100644 --- a/src/curl_xml.c +++ b/src/curl_xml.c @@ -823,6 +823,8 @@ static int cx_config_add_url(oconfig_item_t *ci) /* {{{ */ return status; } + cdtime_t interval = 0; + /* Fill the `cx_t' structure.. */ for (int i = 0; i < ci->children_num; i++) { oconfig_item_t *child = ci->children + i; @@ -853,6 +855,8 @@ static int cx_config_add_url(oconfig_item_t *ci) /* {{{ */ status = cf_util_get_string(child, &db->post_body); else if (strcasecmp("Namespace", child->key) == 0) status = cx_config_add_namespace(db, child); + else if (strcasecmp("Interval", child->key) == 0) + status = cf_util_get_cdtime(child, &interval); else if (strcasecmp("Timeout", child->key) == 0) status = cf_util_get_int(child, &db->timeout); else if (strcasecmp("Statistics", child->key) == 0) { @@ -891,7 +895,7 @@ static int cx_config_add_url(oconfig_item_t *ci) /* {{{ */ char *cb_name = ssnprintf_alloc("curl_xml-%s-%s", db->instance, db->url); plugin_register_complex_read(/* group = */ "curl_xml", cb_name, cx_read, - /* interval = */ 0, + /* interval = */ interval, &(user_data_t){ .data = db, .free_func = cx_free, }); -- 2.11.0