temp = realloc(db->buffer, db->buffer_fill + len + 1);
if (temp == NULL) {
ERROR("curl_xml plugin: realloc failed.");
temp = realloc(db->buffer, db->buffer_fill + len + 1);
if (temp == NULL) {
ERROR("curl_xml plugin: realloc failed.");
struct curl_slist *temp = NULL;
if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING)) {
WARNING("curl_xml plugin: `%s' needs exactly one string argument.", name);
struct curl_slist *temp = NULL;
if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING)) {
WARNING("curl_xml plugin: `%s' needs exactly one string argument.", name);
} /* }}} int cx_config_append_string */
static int cx_check_type(const data_set_t *ds, cx_xpath_t *xpath) /* {{{ */
{
if (!ds) {
WARNING("curl_xml plugin: DataSet `%s' not defined.", xpath->type);
} /* }}} int cx_config_append_string */
static int cx_check_type(const data_set_t *ds, cx_xpath_t *xpath) /* {{{ */
{
if (!ds) {
WARNING("curl_xml plugin: DataSet `%s' not defined.", xpath->type);
}
if (ds->ds_num != xpath->values_len) {
WARNING("curl_xml plugin: DataSet `%s' requires %zu values, but config "
"talks about %zu",
xpath->type, ds->ds_num, xpath->values_len);
}
if (ds->ds_num != xpath->values_len) {
WARNING("curl_xml plugin: DataSet `%s' requires %zu values, but config "
"talks about %zu",
xpath->type, ds->ds_num, xpath->values_len);
{
if (node->type == XML_TEXT_NODE || node->type == XML_ATTRIBUTE_NODE ||
node->type == XML_ELEMENT_NODE)
{
if (node->type == XML_TEXT_NODE || node->type == XML_ATTRIBUTE_NODE ||
node->type == XML_ELEMENT_NODE)
WARNING("curl_xml plugin: "
"Node \"%s\" doesn't seem to be a text node. Skipping...",
WARNING("curl_xml plugin: "
"Node \"%s\" doesn't seem to be a text node. Skipping...",
values_node_obj =
cx_evaluate_xpath(xpath_ctx, BAD_CAST xpath->values[index].path);
if (values_node_obj == NULL)
values_node_obj =
cx_evaluate_xpath(xpath_ctx, BAD_CAST xpath->values[index].path);
if (values_node_obj == NULL)
"only one node. Skipping...",
xpath->values[index].path);
xmlXPathFreeObject(values_node_obj);
"only one node. Skipping...",
xpath->values[index].path);
xmlXPathFreeObject(values_node_obj);
"only text/attribute node which is not the case. Skipping...",
xpath->values[index].path);
xmlXPathFreeObject(values_node_obj);
"only text/attribute node which is not the case. Skipping...",
xpath->values[index].path);
xmlXPathFreeObject(values_node_obj);
} /* }}} int cx_handle_single_value_xpath */
static int cx_handle_all_value_xpaths(xmlXPathContextPtr xpath_ctx, /* {{{ */
} /* }}} int cx_handle_single_value_xpath */
static int cx_handle_all_value_xpaths(xmlXPathContextPtr xpath_ctx, /* {{{ */
for (size_t i = 0; i < xpath->values_len; i++) {
status = cx_handle_single_value_xpath(xpath_ctx, xpath, ds, vl, i);
if (status != 0)
for (size_t i = 0; i < xpath->values_len; i++) {
status = cx_handle_single_value_xpath(xpath_ctx, xpath, ds, vl, i);
if (status != 0)
} /* }}} int cx_handle_all_value_xpaths */
static int cx_handle_instance_xpath(xmlXPathContextPtr xpath_ctx, /* {{{ */
} /* }}} int cx_handle_all_value_xpaths */
static int cx_handle_instance_xpath(xmlXPathContextPtr xpath_ctx, /* {{{ */
"Base-XPath %s is a table (more than one result was returned), "
"but no instance-XPath has been defined.",
xpath->path);
"Base-XPath %s is a table (more than one result was returned), "
"but no instance-XPath has been defined.",
xpath->path);
instance_node_obj = cx_evaluate_xpath(xpath_ctx, BAD_CAST xpath->instance);
if (instance_node_obj == NULL)
instance_node_obj = cx_evaluate_xpath(xpath_ctx, BAD_CAST xpath->instance);
if (instance_node_obj == NULL)
instance_node = instance_node_obj->nodesetval;
tmp_size = (instance_node) ? instance_node->nodeNr : 0;
instance_node = instance_node_obj->nodesetval;
tmp_size = (instance_node) ? instance_node->nodeNr : 0;
"any of the nodes. Skipping the node.",
xpath->instance);
xmlXPathFreeObject(instance_node_obj);
"any of the nodes. Skipping the node.",
xpath->instance);
xmlXPathFreeObject(instance_node_obj);
"to return only one text node. Skipping the node.",
xpath->instance);
xmlXPathFreeObject(instance_node_obj);
"to return only one text node. Skipping the node.",
xpath->instance);
xmlXPathFreeObject(instance_node_obj);
"which is not the case. Skipping the node.",
xpath->instance);
xmlXPathFreeObject(instance_node_obj);
"which is not the case. Skipping the node.",
xpath->instance);
xmlXPathFreeObject(instance_node_obj);
}
} /* if (xpath->instance != NULL) */
if (xpath->instance_prefix != NULL) {
if (instance_node != NULL) {
char *node_value = (char *)xmlNodeGetContent(instance_node->nodeTab[0]);
}
} /* if (xpath->instance != NULL) */
if (xpath->instance_prefix != NULL) {
if (instance_node != NULL) {
char *node_value = (char *)xmlNodeGetContent(instance_node->nodeTab[0]);
- ssnprintf(vl->type_instance, sizeof(vl->type_instance), "%s%s",
- xpath->instance_prefix, node_value);
+ snprintf(vl->type_instance, sizeof(vl->type_instance), "%s%s",
+ xpath->instance_prefix, node_value);
} /* }}} int cx_handle_instance_xpath */
static int cx_handle_base_xpath(char const *plugin_instance, /* {{{ */
} /* }}} int cx_handle_instance_xpath */
static int cx_handle_base_xpath(char const *plugin_instance, /* {{{ */
} /* }}} cx_handle_base_xpath */
static int cx_handle_parsed_xml(xmlDocPtr doc, /* {{{ */
} /* }}} cx_handle_base_xpath */
static int cx_handle_parsed_xml(xmlDocPtr doc, /* {{{ */
if (status != CURLE_OK) {
ERROR("curl_xml plugin: curl_easy_perform failed with status %i: %s (%s)",
status, db->curl_errbuf, db->url);
if (status != CURLE_OK) {
ERROR("curl_xml plugin: curl_easy_perform failed with status %i: %s (%s)",
status, db->curl_errbuf, db->url);
}
if (db->stats != NULL)
curl_stats_dispatch(db->stats, db->curl, cx_host(db), "curl_xml",
}
if (db->stats != NULL)
curl_stats_dispatch(db->stats, db->curl, cx_host(db), "curl_xml",
}
for (int i = 0; i < ci->values_num; i++)
if (ci->values[i].type != OCONFIG_TYPE_STRING) {
WARNING("curl_xml plugin: `ValuesFrom' needs only string argument.");
}
for (int i = 0; i < ci->values_num; i++)
if (ci->values[i].type != OCONFIG_TYPE_STRING) {
WARNING("curl_xml plugin: `ValuesFrom' needs only string argument.");
} /* }}} cx_config_add_values */
static int cx_config_add_xpath(cx_t *db, oconfig_item_t *ci) /* {{{ */
} /* }}} cx_config_add_values */
static int cx_config_add_xpath(cx_t *db, oconfig_item_t *ci) /* {{{ */
xpath = calloc(1, sizeof(*xpath));
if (xpath == NULL) {
ERROR("curl_xml plugin: calloc failed.");
xpath = calloc(1, sizeof(*xpath));
if (xpath == NULL) {
ERROR("curl_xml plugin: calloc failed.");
} /* }}} int cx_config_add_xpath */
static int cx_config_add_namespace(cx_t *db, /* {{{ */
} /* }}} int cx_config_add_xpath */
static int cx_config_add_namespace(cx_t *db, /* {{{ */
(ci->values[1].type != OCONFIG_TYPE_STRING)) {
WARNING("curl_xml plugin: The `Namespace' option "
"needs exactly two string arguments.");
(ci->values[1].type != OCONFIG_TYPE_STRING)) {
WARNING("curl_xml plugin: The `Namespace' option "
"needs exactly two string arguments.");
}
ns = realloc(db->namespaces,
sizeof(*db->namespaces) * (db->namespaces_num + 1));
if (ns == NULL) {
ERROR("curl_xml plugin: realloc failed.");
}
ns = realloc(db->namespaces,
sizeof(*db->namespaces) * (db->namespaces_num + 1));
if (ns == NULL) {
ERROR("curl_xml plugin: realloc failed.");
db->credentials = malloc(credentials_size);
if (db->credentials == NULL) {
ERROR("curl_xml plugin: malloc failed.");
db->credentials = malloc(credentials_size);
if (db->credentials == NULL) {
ERROR("curl_xml plugin: malloc failed.");
- ssnprintf(db->credentials, credentials_size, "%s:%s", db->user,
- (db->pass == NULL) ? "" : db->pass);
+ snprintf(db->credentials, credentials_size, "%s:%s", db->user,
+ (db->pass == NULL) ? "" : db->pass);
if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING)) {
WARNING("curl_xml plugin: The `URL' block "
"needs exactly one string argument.");
if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING)) {
WARNING("curl_xml plugin: The `URL' block "
"needs exactly one string argument.");
}
db = calloc(1, sizeof(*db));
if (db == NULL) {
ERROR("curl_xml plugin: calloc failed.");
}
db = calloc(1, sizeof(*db));
if (db == NULL) {
ERROR("curl_xml plugin: calloc failed.");
plugin_register_complex_read(/* group = */ "curl_xml", cb_name, cx_read,
plugin_register_complex_read(/* group = */ "curl_xml", cb_name, cx_read,
/* Call this while collectd is still single-threaded to avoid
* initialization issues in libgcrypt. */
curl_global_init(CURL_GLOBAL_SSL);
/* Call this while collectd is still single-threaded to avoid
* initialization issues in libgcrypt. */
curl_global_init(CURL_GLOBAL_SSL);
} /* }}} int cx_init */
void module_register(void) {
plugin_register_complex_config("curl_xml", cx_config);
plugin_register_init("curl_xml", cx_init);
} /* void module_register */
} /* }}} int cx_init */
void module_register(void) {
plugin_register_complex_config("curl_xml", cx_config);
plugin_register_init("curl_xml", cx_init);
} /* void module_register */