author | Marc Fournier <marc.fournier@camptocamp.com> | |
Wed, 8 Apr 2015 22:07:07 +0000 (00:07 +0200) | ||
committer | Marc Fournier <marc.fournier@camptocamp.com> | |
Wed, 8 Apr 2015 22:07:07 +0000 (00:07 +0200) |
src/collectd.conf.in | patch | blob | history | |
src/collectd.conf.pod | patch | blob | history | |
src/write_http.c | patch | blob | history |
diff --git a/src/collectd.conf.in b/src/collectd.conf.in
index 8d7622a1ece160af8d5a215006f8285da52a1caf..a9fe668ef33ff90f6fd73227c054d865b16362ca 100644 (file)
--- a/src/collectd.conf.in
+++ b/src/collectd.conf.in
# Format "Command"
# StoreRates false
# BufferSize 4096
+# LowSpeedLimit 0
+# Timeout 0
# </Node>
#</Plugin>
diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod
index b0ed0ed5b2f052f7e22b371e76bcaff056c591ac..524c435bfa497330cf9a528caea451fb61bccf49 100644 (file)
--- a/src/collectd.conf.pod
+++ b/src/collectd.conf.pod
exceed the size of an C<int>, i.e. 2E<nbsp>GByte.
Defaults to C<4096>.
+=item B<LowSpeedLimit> I<Bytes per Second>
+
+Sets the minimal transfer rate in I<Bytes per Second> below which the
+connection with the HTTP server will be considered too slow and aborted. All
+the data submitted over this connection will probably be lost. Defaults to 0,
+which means no minimum transfer rate is enforced.
+
+=item B<Timeout> I<Timeout>
+
+Sets the maximum time in milliseconds given for HTTP POST operations to
+complete. When this limit is reached, the POST operation will be aborted, and
+all the data in the current send buffer will probably be lost. Defaults to 0,
+which means the connection never times out.
+
+The C<write_http> plugin regularly submits the collected values to the HTTP
+server. How frequently this happens depends on how much data you are collecting
+and the size of B<BufferSize>. The optimal value to set B<Timeout> to is
+slightly below this interval, which you can estimate by monitoring the network
+traffic between collectd and the HTTP server.
+
=back
=head2 Plugin C<write_kafka>
diff --git a/src/write_http.c b/src/write_http.c
index 8d3b85b366079e75232a5ff8dcfd9a586aa39c61..3b594be497ae371ac53e66098dfb3a6115d646dc 100644 (file)
--- a/src/write_http.c
+++ b/src/write_http.c
char *clientkeypass;
long sslversion;
_Bool store_rates;
+ int low_speed_limit;
+ time_t low_speed_time;
+ int timeout;
#define WH_FORMAT_COMMAND 0
#define WH_FORMAT_JSON 1
return (-1);
}
+ if (cb->low_speed_limit > 0 && cb->low_speed_time > 0)
+ {
+ curl_easy_setopt (cb->curl, CURLOPT_LOW_SPEED_LIMIT,
+ (long) (cb->low_speed_limit * cb->low_speed_time));
+ curl_easy_setopt (cb->curl, CURLOPT_LOW_SPEED_TIME,
+ (long) cb->low_speed_time);
+ }
+
+ if (cb->timeout > 0)
+ curl_easy_setopt (cb->curl, CURLOPT_TIMEOUT_MS, (long) cb->timeout);
+
curl_easy_setopt (cb->curl, CURLOPT_NOSIGNAL, 1L);
curl_easy_setopt (cb->curl, CURLOPT_USERAGENT, COLLECTD_USERAGENT);
cb->verify_host = 1;
cb->format = WH_FORMAT_COMMAND;
cb->sslversion = CURL_SSLVERSION_DEFAULT;
+ cb->low_speed_limit = 0;
+ cb->timeout = 0;
pthread_mutex_init (&cb->send_lock, /* attr = */ NULL);
cf_util_get_boolean (child, &cb->store_rates);
else if (strcasecmp ("BufferSize", child->key) == 0)
cf_util_get_int (child, &buffer_size);
+ else if (strcasecmp ("LowSpeedLimit", child->key) == 0)
+ cf_util_get_int (child, &cb->low_speed_limit);
+ else if (strcasecmp ("Timeout", child->key) == 0)
+ cf_util_get_int (child, &cb->timeout);
else
{
ERROR ("write_http plugin: Invalid configuration "
return (-1);
}
+ if (cb->low_speed_limit > 0)
+ cb->low_speed_time = CDTIME_T_TO_TIME_T(plugin_get_interval());
+
/* Determine send_buffer_size. */
cb->send_buffer_size = WRITE_HTTP_DEFAULT_BUFFER_SIZE;
if (buffer_size >= 1024)