summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6701199)
raw | patch | inline | side by side (parent: 6701199)
author | Aman Gupta <aman@tmm1.net> | |
Mon, 14 Sep 2009 13:03:57 +0000 (15:03 +0200) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Mon, 14 Sep 2009 13:03:57 +0000 (15:03 +0200) |
It measures response times. Yes, really! ;)
Signed-off-by: Florian Forster <octo@leeloo.lan.home.verplant.org>
Signed-off-by: Florian Forster <octo@leeloo.lan.home.verplant.org>
src/collectd.conf.pod | patch | blob | history | |
src/curl.c | patch | blob | history | |
src/types.db | patch | blob | history |
diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod
index 69f7308befe716923dd780c9216f6738375ddbcd..499af3efcbc0cdfaa6433af71585443bee90a169 100644 (file)
--- a/src/collectd.conf.pod
+++ b/src/collectd.conf.pod
@@ -501,6 +501,10 @@ File that holds one or more SSL certificates. If you want to use HTTPS you will
possibly need this option. What CA certificates come bundled with C<libcurl>
and are checked by default depends on the distribution you use.
+=item B<MeasureResponseTime> B<true>|B<false>
+
+Measure response time for the request. Disabled by default.
+
=item B<E<lt>MatchE<gt>>
One or more B<Match> blocks that define how to match information in the data
diff --git a/src/curl.c b/src/curl.c
index 41f11f614610fe32842bd45f051e2ae4a664cab4..9c2c54005cbbc0d7730543d8b1931c3e902dc770 100644 (file)
--- a/src/curl.c
+++ b/src/curl.c
int verify_peer;
int verify_host;
char *cacert;
+ int response_time;
CURL *curl;
char curl_errbuf[CURL_ERROR_SIZE];
page->pass = NULL;
page->verify_peer = 1;
page->verify_host = 1;
+ page->response_time = 0;
page->instance = strdup (ci->values[0].value.string);
if (page->instance == NULL)
status = cc_config_set_boolean ("VerifyPeer", &page->verify_peer, child);
else if (strcasecmp ("VerifyHost", child->key) == 0)
status = cc_config_set_boolean ("VerifyHost", &page->verify_host, child);
+ else if (strcasecmp ("MeasureResponseTime", child->key) == 0)
+ status = cc_config_set_boolean (child->key, &page->response_time, child);
else if (strcasecmp ("CACert", child->key) == 0)
status = cc_config_add_string ("CACert", &page->cacert, child);
else if (strcasecmp ("Match", child->key) == 0)
status = -1;
}
- if (page->matches == NULL)
+ if (page->matches == NULL && !page->response_time)
{
assert (page->instance != NULL);
WARNING ("curl plugin: No (valid) `Match' block "
- "within `Page' block `%s'.", page->instance);
+ "or MeasureResponseTime within `Page' block `%s'.", page->instance);
status = -1;
}
plugin_dispatch_values (&vl);
} /* }}} void cc_submit */
+static void cc_submit_response_time (const web_page_t *wp, double seconds) /* {{{ */
+{
+ value_t values[1];
+ value_list_t vl = VALUE_LIST_INIT;
+
+ values[0].gauge = seconds;
+
+ vl.values = values;
+ vl.values_len = 1;
+ vl.time = time (NULL);
+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+ sstrncpy (vl.plugin, "curl", sizeof (vl.plugin));
+ sstrncpy (vl.plugin_instance, wp->instance, sizeof (vl.plugin_instance));
+ sstrncpy (vl.type, "response_time", sizeof (vl.type));
+
+ plugin_dispatch_values (&vl);
+} /* }}} void cc_submit_response_time */
+
static int cc_read_page (web_page_t *wp) /* {{{ */
{
web_match_t *wm;
int status;
+ struct timeval start, end;
+
+ if (wp->response_time)
+ gettimeofday (&start, NULL);
wp->buffer_fill = 0;
status = curl_easy_perform (wp->curl);
return (-1);
}
+ if (wp->response_time)
+ {
+ double secs = 0;
+ gettimeofday (&end, NULL);
+ secs += end.tv_sec - start.tv_sec;
+ secs += (end.tv_usec - start.tv_usec) / 1000000.0;
+ cc_submit_response_time (wp, secs);
+ }
+
for (wm = wp->matches; wm != NULL; wm = wm->next)
{
cu_match_value_t *mv;
diff --git a/src/types.db b/src/types.db
index 20df90eb80475e01c6e909ecbbc65f1989a9e0a0..106de8591dc5ea40b257b95c6d92a96a1da5dcb0 100644 (file)
--- a/src/types.db
+++ b/src/types.db
ps_vm value:GAUGE:0:9223372036854775807
queue_length value:GAUGE:0:U
records count:GAUGE:0:U
+response_time value:GAUGE:0:U
route_etx value:GAUGE:0:U
route_metric value:GAUGE:0:U
routes value:GAUGE:0:U