if (st == NULL) {
ERROR("apache plugin: apache_curl_callback: "
"user_data pointer is NULL.");
- return (0);
+ return 0;
}
if (len == 0)
- return (len);
+ return len;
if ((st->apache_buffer_fill + len) >= st->apache_buffer_size) {
char *temp;
temp = realloc(st->apache_buffer, st->apache_buffer_fill + len + 1);
if (temp == NULL) {
ERROR("apache plugin: realloc failed.");
- return (0);
+ return 0;
}
st->apache_buffer = temp;
st->apache_buffer_size = st->apache_buffer_fill + len + 1;
st->apache_buffer_fill += len;
st->apache_buffer[st->apache_buffer_fill] = 0;
- return (len);
+ return len;
} /* int apache_curl_callback */
static size_t apache_header_callback(void *buf, size_t size, size_t nmemb,
if (st == NULL) {
ERROR("apache plugin: apache_header_callback: "
"user_data pointer is NULL.");
- return (0);
+ return 0;
}
if (len == 0)
- return (len);
+ return len;
/* look for the Server header */
if (strncasecmp(buf, "Server: ", strlen("Server: ")) != 0)
- return (len);
+ return len;
if (strstr(buf, "Apache") != NULL)
st->server_type = APACHE;
NOTICE("apache plugin: Unknown server software: %s", hdr);
}
- return (len);
+ return len;
} /* apache_header_callback */
/* Configuration handling functiions
st = calloc(1, sizeof(*st));
if (st == NULL) {
ERROR("apache plugin: calloc failed.");
- return (-1);
+ return -1;
}
st->timeout = -1;
status = cf_util_get_string(ci, &st->name);
if (status != 0) {
sfree(st);
- return (status);
+ return status;
}
assert(st->name != NULL);
if (status != 0) {
apache_free(st);
- return (-1);
+ return -1;
}
- return (0);
+ return 0;
} /* int config_add */
static int config(oconfig_item_t *ci) {
child->key);
} /* for (ci->children) */
- return (status);
+ return status;
} /* int config */
/* initialize curl for each host */
if ((st->curl = curl_easy_init()) == NULL) {
ERROR("apache plugin: init_host: `curl_easy_init' failed.");
- return (-1);
+ return -1;
}
curl_easy_setopt(st->curl, CURLOPT_NOSIGNAL, 1L);
"truncated.");
curl_easy_cleanup(st->curl);
st->curl = NULL;
- return (-1);
+ return -1;
}
curl_easy_setopt(st->curl, CURLOPT_USERPWD, credentials);
(long)CDTIME_T_TO_MS(plugin_get_interval()));
#endif
- return (0);
+ return 0;
} /* }}} int init_host */
static void submit_value(const char *type, const char *type_instance,
if (st->curl == NULL) {
status = init_host(st);
if (status != 0)
- return (-1);
+ return -1;
}
assert(st->curl != NULL);
st->apache_buffer_fill = 0;
if (curl_easy_perform(st->curl) != CURLE_OK) {
ERROR("apache: curl_easy_perform failed: %s", st->apache_curl_error);
- return (-1);
+ return -1;
}
/* fallback - server_type to apache if not set at this time */
st->apache_buffer_fill = 0;
- return (0);
+ return 0;
} /* }}} int apache_read_host */
static int apache_init(void) /* {{{ */
/* Call this while collectd is still single-threaded to avoid
* initialization issues in libgcrypt. */
curl_global_init(CURL_GLOBAL_SSL);
- return (0);
+ return 0;
} /* }}} int apache_init */
void module_register(void) {