} /* while (received < body_size) */
if (strcasecmp("text/collectd", content_type) == 0) {
- status = handle_putval(stderr, body);
+ status = cmd_handle_putval(stderr, body);
if (status != 0)
- ERROR("amqp plugin: handle_putval failed with status %i.", status);
+ ERROR("amqp plugin: cmd_handle_putval failed with status %i.", status);
return (status);
} else if (strcasecmp("application/json", content_type) == 0) {
ERROR("amqp plugin: camqp_read_body: Parsing JSON data has not "
status = camqp_connect(conf);
if (status != 0) {
- struct timespec ts_interval;
ERROR("amqp plugin: camqp_connect failed. "
"Will sleep for %.3f seconds.",
CDTIME_T_TO_DOUBLE(interval));
- CDTIME_T_TO_TIMESPEC(interval, &ts_interval);
- nanosleep(&ts_interval, /* remaining = */ NULL);
+ nanosleep(&CDTIME_T_TO_TIMESPEC(interval), /* remaining = */ NULL);
continue;
}
status = amqp_simple_wait_frame(conf->connection, &frame);
if (status < 0) {
- struct timespec ts_interval;
ERROR("amqp plugin: amqp_simple_wait_frame failed. "
"Will sleep for %.3f seconds.",
CDTIME_T_TO_DOUBLE(interval));
camqp_close_connection(conf);
- CDTIME_T_TO_TIMESPEC(interval, &ts_interval);
- nanosleep(&ts_interval, /* remaining = */ NULL);
+ nanosleep(&CDTIME_T_TO_TIMESPEC(interval), /* remaining = */ NULL);
continue;
}
memset(tmp, 0, sizeof(*tmp));
status = plugin_thread_create(tmp, /* attr = */ NULL, camqp_subscribe_thread,
- conf);
+ conf, "amqp subscribe");
if (status != 0) {
char errbuf[1024];
ERROR("amqp plugin: pthread_create failed: %s",
}
if (conf->format == CAMQP_FORMAT_COMMAND) {
- status = create_putval(buffer, sizeof(buffer), ds, vl);
+ status = cmd_create_putval(buffer, sizeof(buffer), ds, vl);
if (status != 0) {
- ERROR("amqp plugin: create_putval failed with status %i.", status);
+ ERROR("amqp plugin: cmd_create_putval failed with status %i.", status);
return (status);
}
} else if (conf->format == CAMQP_FORMAT_JSON) {
status = cf_util_get_string(child, &conf->password);
else if (strcasecmp("Exchange", child->key) == 0)
status = cf_util_get_string(child, &conf->exchange);
- else if ((strcasecmp("ExchangeType", child->key) == 0) && !publish)
+ else if (strcasecmp("ExchangeType", child->key) == 0)
status = cf_util_get_string(child, &conf->exchange_type);
else if ((strcasecmp("Queue", child->key) == 0) && !publish)
status = cf_util_get_string(child, &conf->queue);
else if ((strcasecmp("GraphiteAlwaysAppendDS", child->key) == 0) && publish)
status = cf_util_get_flag(child, &conf->graphite_flags,
GRAPHITE_ALWAYS_APPEND_DS);
+ else if ((strcasecmp("GraphitePreserveSeparator", child->key) == 0) &&
+ publish)
+ status = cf_util_get_flag(child, &conf->graphite_flags,
+ GRAPHITE_PRESERVE_SEPARATOR);
else if ((strcasecmp("GraphitePrefix", child->key) == 0) && publish)
status = cf_util_get_string(child, &conf->prefix);
else if ((strcasecmp("GraphitePostfix", child->key) == 0) && publish)
if (publish) {
char cbname[128];
- user_data_t ud = {conf, camqp_config_free};
-
ssnprintf(cbname, sizeof(cbname), "amqp/%s", conf->name);
- status = plugin_register_write(cbname, camqp_write, &ud);
+ status = plugin_register_write(
+ cbname, camqp_write, &(user_data_t){
+ .data = conf, .free_func = camqp_config_free,
+ });
if (status != 0) {
camqp_config_free(conf);
return (status);
{"ReqBadSIG", "dns_request", "BadSIG"},
{"ReqTCP", "dns_request", "TCP"},
/* Rejects */
- {"AuthQryRej", "dns_reject", "authorative"},
+ {"AuthQryRej", "dns_reject", "authoritative"},
{"RecQryRej", "dns_reject", "recursive"},
{"XfrRej", "dns_reject", "transfer"},
{"UpdateRej", "dns_reject", "update"},
{"RespTSIG", "dns_response", "TSIG"},
{"RespSIG0", "dns_response", "SIG0"},
/* Queries */
- {"QryAuthAns", "dns_query", "authorative"},
+ {"QryAuthAns", "dns_query", "authoritative"},
{"QryNoauthAns", "dns_query", "nonauth"},
{"QryReferral", "dns_query", "referral"},
{"QryRecursion", "dns_query", "recursion"},
- {"QryDuplicate", "dns_query", "dupliate"},
+ {"QryDuplicate", "dns_query", "duplicate"},
{"QryDropped", "dns_query", "dropped"},
{"QryFailure", "dns_query", "failure"},
/* Response codes */
{"QryFORMERR", "dns_rcode", "tx-FORMERR"},
{"QryNXDOMAIN", "dns_rcode", "tx-NXDOMAIN"}
#if 0
- { "XfrReqDone", "type", "type_instance" },
- { "UpdateReqFwd", "type", "type_instance" },
- { "UpdateRespFwd", "type", "type_instance" },
- { "UpdateFwdFail", "type", "type_instance" },
- { "UpdateDone", "type", "type_instance" },
- { "UpdateFail", "type", "type_instance" },
- { "UpdateBadPrereq", "type", "type_instance" },
+ { "XfrReqDone", "type", "type_instance" },
+ { "UpdateReqFwd", "type", "type_instance" },
+ { "UpdateRespFwd", "type", "type_instance" },
+ { "UpdateFwdFail", "type", "type_instance" },
+ { "UpdateDone", "type", "type_instance" },
+ { "UpdateFail", "type", "type_instance" },
+ { "UpdateBadPrereq", "type", "type_instance" },
#endif
};
static int nsstats_translation_table_length =
static void submit(time_t ts, const char *plugin_instance, /* {{{ */
const char *type, const char *type_instance, value_t value) {
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- values[0] = value;
-
- vl.values = values;
+ vl.values = &value;
vl.values_len = 1;
if (config_parse_time)
vl.time = TIME_T_TO_CDTIME_T(ts);
- sstrncpy(vl.host, hostname_g, sizeof(vl.host));
sstrncpy(vl.plugin, "bind", sizeof(vl.plugin));
if (plugin_instance) {
sstrncpy(vl.plugin_instance, plugin_instance, sizeof(vl.plugin_instance));
status = bind_xml_read_gauge(doc, counter, &value.gauge);
else
status = bind_xml_read_derive(doc, counter, &value.derive);
- if (status != 0)
+ if (status != 0) {
+ xmlFree(name);
continue;
+ }
status = (*list_callback)(name, value, current_time, user_data);
if (status == 0)
status = bind_xml_read_gauge(doc, child, &value.gauge);
else
status = bind_xml_read_derive(doc, child, &value.derive);
- if (status != 0)
+ if (status != 0) {
+ xmlFree(attr_name);
continue;
+ }
status = (*list_callback)(attr_name, value, current_time, user_data);
if (status == 0)
num_entries++;
+
+ xmlFree(attr_name);
}
}
}
static void gr_copy_escape_part(char *dst, const char *src, size_t dst_len,
- char escape_char) {
+ char escape_char, _Bool preserve_separator) {
memset(dst, 0, dst_len);
if (src == NULL)
break;
}
- if ((src[i] == '.') || isspace((int)src[i]) || iscntrl((int)src[i]))
+ if ((!preserve_separator && (src[i] == '.')) || isspace((int)src[i]) ||
+ iscntrl((int)src[i]))
dst[i] = escape_char;
else
dst[i] = src[i];
if (postfix == NULL)
postfix = "";
- gr_copy_escape_part(n_host, vl->host, sizeof(n_host), escape_char);
- gr_copy_escape_part(n_plugin, vl->plugin, sizeof(n_plugin), escape_char);
+ _Bool preserve_separator = (flags & GRAPHITE_PRESERVE_SEPARATOR) ? 1 : 0;
+
+ gr_copy_escape_part(n_host, vl->host, sizeof(n_host), escape_char,
+ preserve_separator);
+ gr_copy_escape_part(n_plugin, vl->plugin, sizeof(n_plugin), escape_char,
+ preserve_separator);
gr_copy_escape_part(n_plugin_instance, vl->plugin_instance,
- sizeof(n_plugin_instance), escape_char);
- gr_copy_escape_part(n_type, vl->type, sizeof(n_type), escape_char);
+ sizeof(n_plugin_instance), escape_char,
+ preserve_separator);
+ gr_copy_escape_part(n_type, vl->type, sizeof(n_type), escape_char,
+ preserve_separator);
gr_copy_escape_part(n_type_instance, vl->type_instance,
- sizeof(n_type_instance), escape_char);
+ sizeof(n_type_instance), escape_char, preserve_separator);
if (n_plugin_instance[0] != '\0')
ssnprintf(tmp_plugin, sizeof(tmp_plugin), "%s%c%s", n_plugin,
else
sstrncpy(tmp_plugin, n_plugin, sizeof(tmp_plugin));
- if (n_type_instance[0] != '\0')
- ssnprintf(tmp_type, sizeof(tmp_type), "%s%c%s", n_type,
- (flags & GRAPHITE_SEPARATE_INSTANCES) ? '.' : '-',
- n_type_instance);
- else
+ if (n_type_instance[0] != '\0') {
+ if ((flags & GRAPHITE_DROP_DUPE_FIELDS) && strcmp(n_plugin, n_type) == 0)
+ sstrncpy(tmp_type, n_type_instance, sizeof(tmp_type));
+ else
+ ssnprintf(tmp_type, sizeof(tmp_type), "%s%c%s", n_type,
+ (flags & GRAPHITE_SEPARATE_INSTANCES) ? '.' : '-',
+ n_type_instance);
+ } else
sstrncpy(tmp_type, n_type, sizeof(tmp_type));
/* Assert always_append_ds -> ds_name */
assert(!(flags & GRAPHITE_ALWAYS_APPEND_DS) || (ds_name != NULL));
- if (ds_name != NULL)
- ssnprintf(ret, ret_len, "%s%s%s.%s.%s.%s", prefix, n_host, postfix,
- tmp_plugin, tmp_type, ds_name);
- else
+ if (ds_name != NULL) {
+ if ((flags & GRAPHITE_DROP_DUPE_FIELDS) &&
+ strcmp(tmp_plugin, tmp_type) == 0)
+ ssnprintf(ret, ret_len, "%s%s%s.%s.%s", prefix, n_host, postfix,
+ tmp_plugin, ds_name);
+ else
+ ssnprintf(ret, ret_len, "%s%s%s.%s.%s.%s", prefix, n_host, postfix,
+ tmp_plugin, tmp_type, ds_name);
+ } else
ssnprintf(ret, ret_len, "%s%s%s.%s.%s", prefix, n_host, postfix, tmp_plugin,
tmp_type);
int buffer_pos = 0;
gauge_t *rates = NULL;
- if (flags & GRAPHITE_STORE_RATES)
+ if (flags & GRAPHITE_STORE_RATES) {
rates = uc_get_rate(ds, vl);
+ if (rates == NULL) {
+ ERROR("format_graphite: error with uc_get_rate");
+ return -1;
+ }
+ }
for (size_t i = 0; i < ds->ds_num; i++) {
char const *ds_name = NULL;