summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d54a1b8)
raw | patch | inline | side by side (parent: d54a1b8)
author | Florian Forster <octo@huhu.verplant.org> | |
Wed, 15 Dec 2010 06:51:40 +0000 (07:51 +0100) | ||
committer | Florian Forster <octo@huhu.verplant.org> | |
Wed, 15 Dec 2010 06:51:40 +0000 (07:51 +0100) |
Also, the string handling function has been simplified. The obscure and
hardly documented sub-request for incomplete keys feature has been
removed.
hardly documented sub-request for incomplete keys feature has been
removed.
src/collectd.conf.pod | patch | blob | history | |
src/curl_json.c | patch | blob | history |
diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod
index 5d10b24ad2972e180ffcd1a9da9f6b89e5e64156..7579664ba1b146112722d6023dc074c35e8f2236 100644 (file)
--- a/src/collectd.conf.pod
+++ b/src/collectd.conf.pod
</URL>
</Plugin>
-Another CouchDB example:
-The following example will collect the status values from each database:
-
- <URL "http://localhost:5984/_all_dbs">
- Instance "dbs"
- <Key "*/doc_count">
- Type "gauge"
- </Key>
- <Key "*/doc_del_count">
- Type "counter"
- </Key>
- <Key "*/disk_size">
- Type "bytes"
- </Key>
- </URL>
-
In the B<Plugin> block, there may be one or more B<URL> blocks, each defining
a URL to be fetched via HTTP (using libcurl) and one or more B<Key> blocks.
The B<Key> string argument must be in a path format, which is used to collect a
diff --git a/src/curl_json.c b/src/curl_json.c
index f6bc512d9b86caea96331d90d7f14437e2237515..442cfcf97e36375b7b6fcc1b066fc00181dee12c 100644 (file)
--- a/src/curl_json.c
+++ b/src/curl_json.c
unsigned int len)
{
cj_t *db = (cj_t *)ctx;
- c_avl_tree_t *tree;
- char *ptr;
-
- if (db->depth != 1) /* e.g. _all_dbs */
- return (CJ_CB_CONTINUE);
+ char str[len + 1];
- cj_cb_map_key (ctx, val, len); /* same logic */
+ /* Create a null-terminated version of the string. */
+ memcpy (str, val, len);
+ str[len] = 0;
- tree = db->state[db->depth].tree;
+ /* No configuration for this string -> simply return. */
+ if (db->state[db->depth].key == NULL)
+ return (CJ_CB_CONTINUE);
- if ((tree != NULL) && (ptr = rindex (db->url, '/')))
+ if (!CJ_IS_KEY (db->state[db->depth].key))
{
- char url[PATH_MAX];
- CURL *curl;
-
- /* url =~ s,[^/]+$,$name, */
- len = (ptr - db->url) + 1;
- ptr = url;
- sstrncpy (ptr, db->url, sizeof (url));
- sstrncpy (ptr + len, db->state[db->depth].name, sizeof (url) - len);
-
- curl = curl_easy_duphandle (db->curl);
- curl_easy_setopt (curl, CURLOPT_URL, url);
- cj_curl_perform (db, curl);
- curl_easy_cleanup (curl);
+ NOTICE ("curl_json plugin: Found string \"%s\", but the configuration "
+ "expects a map here.", str);
+ return (CJ_CB_CONTINUE);
}
- return (CJ_CB_CONTINUE);
-}
+
+ /* Handle the string as if it was a number. */
+ return (cj_cb_number (ctx, (const char *) val, len));
+} /* int cj_cb_string */
static int cj_cb_start (void *ctx)
{