-#include "utils_cmd_putval.h"
-#include "utils_format_graphite.h"
-#include "utils_format_json.h"
+#include "utils/cmds/putval.h"
+#include "utils/common/common.h"
+#include "utils/format_graphite/format_graphite.h"
+#include "utils/format_json/format_json.h"
-static pthread_t *subscriber_threads = NULL;
-static size_t subscriber_threads_num = 0;
-static _Bool subscriber_threads_running = 1;
+static pthread_t *subscriber_threads;
+static size_t subscriber_threads_num;
+static bool subscriber_threads_running = true;
static char *camqp_strerror(camqp_config_t *conf, /* {{{ */
char *buffer, size_t buffer_size) {
static char *camqp_strerror(camqp_config_t *conf, /* {{{ */
char *buffer, size_t buffer_size) {
amqp_connection_close_t *m = r.reply.decoded;
char *tmp = camqp_bytes_cstring(&m->reply_text);
ssnprintf(buffer, buffer_size, "Server connection error %d: %s",
amqp_connection_close_t *m = r.reply.decoded;
char *tmp = camqp_bytes_cstring(&m->reply_text);
ssnprintf(buffer, buffer_size, "Server connection error %d: %s",
sfree(tmp);
} else if (r.reply.id == AMQP_CHANNEL_CLOSE_METHOD) {
amqp_channel_close_t *m = r.reply.decoded;
char *tmp = camqp_bytes_cstring(&m->reply_text);
ssnprintf(buffer, buffer_size, "Server channel error %d: %s",
sfree(tmp);
} else if (r.reply.id == AMQP_CHANNEL_CLOSE_METHOD) {
amqp_channel_close_t *m = r.reply.decoded;
char *tmp = camqp_bytes_cstring(&m->reply_text);
ssnprintf(buffer, buffer_size, "Server channel error %d: %s",
sfree(tmp);
} else {
ssnprintf(buffer, buffer_size, "Server error method %#" PRIx32,
sfree(tmp);
} else {
ssnprintf(buffer, buffer_size, "Server error method %#" PRIx32,
status = amqp_socket_open(socket, CONF(conf, host), conf->port);
if (status < 0) {
status = amqp_socket_open(socket, CONF(conf, host), conf->port);
if (status < 0) {
- ERROR("amqp plugin: amqp_socket_open failed: %s",
- sstrerror(status, errbuf, sizeof(errbuf)));
+ ERROR("amqp plugin: amqp_socket_open failed: %s", STRERROR(status));
/* this interface is deprecated as of rabbitmq-c 0.4 */
sockfd = amqp_open_socket(CONF(conf, host), conf->port);
if (sockfd < 0) {
/* this interface is deprecated as of rabbitmq-c 0.4 */
sockfd = amqp_open_socket(CONF(conf, host), conf->port);
if (sockfd < 0) {
- ERROR("amqp plugin: amqp_open_socket failed: %s",
- sstrerror(status, errbuf, sizeof(errbuf)));
+ ERROR("amqp plugin: amqp_open_socket failed: %s", STRERROR(status));
while (received < body_size) {
status = amqp_simple_wait_frame(conf->connection, &frame);
if (status < 0) {
while (received < body_size) {
status = amqp_simple_wait_frame(conf->connection, &frame);
if (status < 0) {
- ERROR("amqp plugin: amqp_simple_wait_frame failed: %s",
- sstrerror(status, errbuf, sizeof(errbuf)));
+ ERROR("amqp plugin: amqp_simple_wait_frame failed: %s", STRERROR(status));
- ERROR("amqp plugin: amqp_simple_wait_frame failed: %s",
- sstrerror(status, errbuf, sizeof(errbuf)));
+ ERROR("amqp plugin: amqp_simple_wait_frame failed: %s", STRERROR(status));
status = plugin_thread_create(tmp, /* attr = */ NULL, camqp_subscribe_thread,
conf, "amqp subscribe");
if (status != 0) {
status = plugin_thread_create(tmp, /* attr = */ NULL, camqp_subscribe_thread,
conf, "amqp subscribe");
if (status != 0) {
- char errbuf[1024];
- ERROR("amqp plugin: pthread_create failed: %s",
- sstrerror(status, errbuf, sizeof(errbuf)));
+ ERROR("amqp plugin: pthread_create failed: %s", STRERROR(status));
sstrncpy(routing_key, conf->routing_key, sizeof(routing_key));
} else {
ssnprintf(routing_key, sizeof(routing_key), "collectd/%s/%s/%s/%s/%s",
sstrncpy(routing_key, conf->routing_key, sizeof(routing_key));
} else {
ssnprintf(routing_key, sizeof(routing_key), "collectd/%s/%s/%s/%s/%s",
- vl->host, vl->plugin, vl->plugin_instance, vl->type,
- vl->type_instance);
+ vl->host, vl->plugin, vl->plugin_instance, vl->type,
+ vl->type_instance);
/* Switch slashes (the only character forbidden by collectd) and dots
* (the separation character used by AMQP). */
/* Switch slashes (the only character forbidden by collectd) and dots
* (the separation character used by AMQP). */
} /* }}} int config_set_string */
static int camqp_config_connection(oconfig_item_t *ci, /* {{{ */
} /* }}} int config_set_string */
static int camqp_config_connection(oconfig_item_t *ci, /* {{{ */
else if (strcasecmp("RoutingKey", child->key) == 0)
status = cf_util_get_string(child, &conf->routing_key);
else if ((strcasecmp("Persistent", child->key) == 0) && publish) {
else if (strcasecmp("RoutingKey", child->key) == 0)
status = cf_util_get_string(child, &conf->routing_key);
else if ((strcasecmp("Persistent", child->key) == 0) && publish) {
status = cf_util_get_boolean(child, &tmp);
if (tmp)
conf->delivery_mode = CAMQP_DM_PERSISTENT;
status = cf_util_get_boolean(child, &tmp);
if (tmp)
conf->delivery_mode = CAMQP_DM_PERSISTENT;
char cbname[128];
ssnprintf(cbname, sizeof(cbname), "amqp/%s", conf->name);
char cbname[128];
ssnprintf(cbname, sizeof(cbname), "amqp/%s", conf->name);
- status = plugin_register_write(
- cbname, camqp_write, &(user_data_t){
- .data = conf, .free_func = camqp_config_free,
- });
+ status =
+ plugin_register_write(cbname, camqp_write,
+ &(user_data_t){
+ .data = conf, .free_func = camqp_config_free,
+ });
oconfig_item_t *child = ci->children + i;
if (strcasecmp("Publish", child->key) == 0)
oconfig_item_t *child = ci->children + i;
if (strcasecmp("Publish", child->key) == 0)