projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
src/daemon/plugin.[ch]: Use cdtime_t for the interval argument of "register complex...
[collectd.git]
/
src
/
apache.c
diff --git
a/src/apache.c
b/src/apache.c
index
3c4354f
..
82a267b
100644
(file)
--- a/
src/apache.c
+++ b/
src/apache.c
@@
-54,6
+54,7
@@
struct apache_s
char apache_curl_error[CURL_ERROR_SIZE];
size_t apache_buffer_size;
size_t apache_buffer_fill;
char apache_curl_error[CURL_ERROR_SIZE];
size_t apache_buffer_size;
size_t apache_buffer_fill;
+ int timeout;
CURL *curl;
}; /* apache_s */
CURL *curl;
}; /* apache_s */
@@
-181,6
+182,8
@@
static int config_add (oconfig_item_t *ci)
}
memset (st, 0, sizeof (*st));
}
memset (st, 0, sizeof (*st));
+ st->timeout = -1;
+
status = cf_util_get_string (ci, &st->name);
if (status != 0)
{
status = cf_util_get_string (ci, &st->name);
if (status != 0)
{
@@
-211,6
+214,8
@@
static int config_add (oconfig_item_t *ci)
status = cf_util_get_string (child, &st->ssl_ciphers);
else if (strcasecmp ("Server", child->key) == 0)
status = cf_util_get_string (child, &st->server);
status = cf_util_get_string (child, &st->ssl_ciphers);
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.",
else
{
WARNING ("apache plugin: Option `%s' not allowed here.",
@@
-249,7
+254,7
@@
static int config_add (oconfig_item_t *ci)
status = plugin_register_complex_read (/* group = */ NULL,
/* name = */ callback_name,
/* callback = */ apache_read_host,
status = plugin_register_complex_read (/* group = */ NULL,
/* name = */ callback_name,
/* callback = */ apache_read_host,
- /* interval = */
NULL
,
+ /* interval = */
0
,
/* user_data = */ &ud);
}
/* user_data = */ &ud);
}
@@
-287,8
+292,6
@@
static int config (oconfig_item_t *ci)
/* initialize curl for each host */
static int init_host (apache_t *st) /* {{{ */
{
/* initialize curl for each host */
static int init_host (apache_t *st) /* {{{ */
{
- static char credentials[1024];
-
assert (st->url != NULL);
/* (Assured by `config_add') */
assert (st->url != NULL);
/* (Assured by `config_add') */
@@
-338,6
+341,12
@@
static int init_host (apache_t *st) /* {{{ */
if (st->user != NULL)
{
if (st->user != NULL)
{
+#ifdef HAVE_CURLOPT_USERNAME
+ curl_easy_setopt (st->curl, CURLOPT_USERNAME, st->user);
+ curl_easy_setopt (st->curl, CURLOPT_PASSWORD,
+ (st->pass == NULL) ? "" : st->pass);
+#else
+ static char credentials[1024];
int status;
status = ssnprintf (credentials, sizeof (credentials), "%s:%s",
int status;
status = ssnprintf (credentials, sizeof (credentials), "%s:%s",
@@
-353,6
+362,7
@@
static int init_host (apache_t *st) /* {{{ */
}
curl_easy_setopt (st->curl, CURLOPT_USERPWD, credentials);
}
curl_easy_setopt (st->curl, CURLOPT_USERPWD, credentials);
+#endif
}
curl_easy_setopt (st->curl, CURLOPT_URL, st->url);
}
curl_easy_setopt (st->curl, CURLOPT_URL, st->url);
@@
-368,6
+378,14
@@
static int init_host (apache_t *st) /* {{{ */
if (st->ssl_ciphers != NULL)
curl_easy_setopt (st->curl, CURLOPT_SSL_CIPHER_LIST,st->ssl_ciphers);
if (st->ssl_ciphers != NULL)
curl_easy_setopt (st->curl, CURLOPT_SSL_CIPHER_LIST,st->ssl_ciphers);
+#ifdef HAVE_CURLOPT_TIMEOUT_MS
+ if (st->timeout >= 0)
+ curl_easy_setopt (st->curl, CURLOPT_TIMEOUT_MS, (long) st->timeout);
+ else
+ curl_easy_setopt (st->curl, CURLOPT_TIMEOUT_MS,
+ CDTIME_T_TO_MS(plugin_get_interval()));
+#endif
+
return (0);
} /* }}} int init_host */
return (0);
} /* }}} int init_host */