summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3259a9b)
raw | patch | inline | side by side (parent: 3259a9b)
author | Pavel Rochnyack <pavel2000@ngs.ru> | |
Sun, 24 Apr 2016 14:16:21 +0000 (20:16 +0600) | ||
committer | Pavel Rochnyack <pavel2000@ngs.ru> | |
Mon, 10 Jul 2017 09:18:41 +0000 (16:18 +0700) |
src/collectd.conf.pod | patch | blob | history | |
src/curl.c | patch | blob | history |
diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod
index 4bd8423b2d70cc27b1d0e1a1527b8ad4a8962a0f..f99fe77f2d9328fdec702f7d365a86e5344adfa7 100644 (file)
--- a/src/collectd.conf.pod
+++ b/src/collectd.conf.pod
<Plugin curl>
<Page "stock_quotes">
+ PluginName "quotes"
URL "http://finance.google.com/finance?q=NYSE%3AAMD"
User "foo"
Password "bar"
=over 4
+=item B<PluginName> I<PluginName>
+
+Use I<PluginName> as the plugin name when submitting values.
+Defaults to 'curl'.
+
=item B<URL> I<URL>
URL of the web site to retrieve. Since a regular expression will be used to
diff --git a/src/curl.c b/src/curl.c
index cde383d38a277283e9a59a735957d61285edb5db..d1957d2d027087c7d3f508993c6f6a19933d181a 100644 (file)
--- a/src/curl.c
+++ b/src/curl.c
typedef struct web_page_s web_page_t;
struct web_page_s /* {{{ */
{
+ char *plugin_name;
char *instance;
char *url;
curl_easy_cleanup(wp->curl);
wp->curl = NULL;
+ sfree(wp->plugin_name);
sfree(wp->instance);
sfree(wp->url);
ERROR("curl plugin: calloc failed.");
return -1;
}
+ page->plugin_name = NULL;
page->url = NULL;
page->user = NULL;
page->pass = NULL;
for (int i = 0; i < ci->children_num; i++) {
oconfig_item_t *child = ci->children + i;
- if (strcasecmp("URL", child->key) == 0)
+ if (strcasecmp("PluginName", child->key) == 0)
+ status = cf_util_get_string(child, &page->plugin_name);
+ else if (strcasecmp("URL", child->key) == 0)
status = cf_util_get_string(child, &page->url);
else if (strcasecmp("User", child->key) == 0)
status = cf_util_get_string(child, &page->user);
vl.values = &value;
vl.values_len = 1;
- sstrncpy(vl.plugin, "curl", sizeof(vl.plugin));
+ sstrncpy(vl.plugin, (wp->plugin_name != NULL) ? wp->plugin_name : "curl",
+ sizeof(vl.plugin));
sstrncpy(vl.plugin_instance, wp->instance, sizeof(vl.plugin_instance));
sstrncpy(vl.type, wm->type, sizeof(vl.type));
if (wm->instance != NULL)
vl.values = &(value_t){.gauge = (gauge_t)code};
vl.values_len = 1;
- sstrncpy(vl.plugin, "curl", sizeof(vl.plugin));
+ sstrncpy(vl.plugin, (wp->plugin_name != NULL) ? wp->plugin_name : "curl",
+ sizeof(vl.plugin));
sstrncpy(vl.plugin_instance, wp->instance, sizeof(vl.plugin_instance));
sstrncpy(vl.type, "response_code", sizeof(vl.type));
vl.values = &(value_t){.gauge = response_time};
vl.values_len = 1;
- sstrncpy(vl.plugin, "curl", sizeof(vl.plugin));
+ sstrncpy(vl.plugin, (wp->plugin_name != NULL) ? wp->plugin_name : "curl",
+ sizeof(vl.plugin));
sstrncpy(vl.plugin_instance, wp->instance, sizeof(vl.plugin_instance));
sstrncpy(vl.type, "response_time", sizeof(vl.type));