X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fapache.c;h=9e91b8024f948f23a5c83328c828a51652481d01;hb=c279c0e5bff589bd7be9a4d63e7bef3ca9ac65d2;hp=1099248a24293485b8af3595793e03dbc1409fa4;hpb=87768c58e44c2d879b6d0c28f849fd18741dc995;p=collectd.git diff --git a/src/apache.c b/src/apache.c index 1099248a..9e91b802 100644 --- a/src/apache.c +++ b/src/apache.c @@ -53,6 +53,7 @@ struct apache_s char apache_curl_error[CURL_ERROR_SIZE]; size_t apache_buffer_size; size_t apache_buffer_fill; + int timeout; CURL *curl; }; /* apache_s */ @@ -179,6 +180,8 @@ static int config_add (oconfig_item_t *ci) } memset (st, 0, sizeof (*st)); + st->timeout = -1; + status = cf_util_get_string (ci, &st->name); if (status != 0) { @@ -207,6 +210,8 @@ static int config_add (oconfig_item_t *ci) status = cf_util_get_string (child, &st->cacert); else if (strcasecmp ("Server", child->key) == 0) status = cf_util_get_string (child, &st->server); + else if (strcasecmp ("Timeout", child->key) == 0) + status = cf_util_get_int (child, &st->timeout); else { WARNING ("apache plugin: Option `%s' not allowed here.", @@ -367,6 +372,12 @@ static int init_host (apache_t *st) /* {{{ */ if (st->cacert != NULL) curl_easy_setopt (st->curl, CURLOPT_CAINFO, st->cacert); + if (st->timeout >= 0) + curl_easy_setopt (st->curl, CURLOPT_TIMEOUT_MS, st->timeout); + else + curl_easy_setopt (st->curl, CURLOPT_TIMEOUT_MS, + CDTIME_T_TO_MS(plugin_get_interval())); + return (0); } /* }}} int init_host */