#include "collectd.h"
-#include "common.h"
#include "plugin.h"
+#include "utils/common/common.h"
#include "utils_cache.h"
#include <mongoc.h>
char *user;
char *passwd;
- _Bool store_rates;
- _Bool connected;
+ bool store_rates;
+ bool connected;
mongoc_client_t *client;
mongoc_database_t *database;
* Functions
*/
static bson_t *wm_create_bson(const data_set_t *ds, /* {{{ */
- const value_list_t *vl, _Bool store_rates) {
+ const value_list_t *vl, bool store_rates) {
bson_t *ret;
bson_t subarray;
gauge_t *rates;
"authentication string.");
mongoc_client_destroy(node->client);
node->client = NULL;
- node->connected = 0;
+ node->connected = false;
return -1;
}
ERROR("write_mongodb plugin: Authenticating to [%s]:%d for database "
"\"%s\" as user \"%s\" failed.",
node->host, node->port, node->db, node->user);
- node->connected = 0;
+ node->connected = false;
sfree(uri);
return -1;
}
"authentication string.");
mongoc_client_destroy(node->client);
node->client = NULL;
- node->connected = 0;
+ node->connected = false;
return -1;
}
if (!node->client) {
ERROR("write_mongodb plugin: Connecting to [%s]:%d failed.", node->host,
node->port);
- node->connected = 0;
+ node->connected = false;
sfree(uri);
return -1;
}
ERROR("write_mongodb plugin: error creating/getting database");
mongoc_client_destroy(node->client);
node->client = NULL;
- node->connected = 0;
+ node->connected = false;
return -1;
}
- node->connected = 1;
+ node->connected = true;
return 0;
} /* }}} int wm_initialize */
mongoc_client_destroy(node->client);
node->database = NULL;
node->client = NULL;
- node->connected = 0;
+ node->connected = false;
pthread_mutex_unlock(&node->lock);
bson_destroy(bson_record);
return -1;
mongoc_client_destroy(node->client);
node->database = NULL;
node->client = NULL;
- node->connected = 0;
+ node->connected = false;
pthread_mutex_unlock(&node->lock);
bson_destroy(bson_record);
mongoc_collection_destroy(collection);
mongoc_client_destroy(node->client);
node->database = NULL;
node->client = NULL;
- node->connected = 0;
+ node->connected = false;
sfree(node->host);
sfree(node);
return ENOMEM;
}
node->port = MONGOC_DEFAULT_PORT;
- node->store_rates = 1;
+ node->store_rates = true;
pthread_mutex_init(&node->lock, /* attr = */ NULL);
status = cf_util_get_string_buffer(ci, node->name, sizeof(node->name));
snprintf(cb_name, sizeof(cb_name), "write_mongodb/%s", node->name);
- status =
- plugin_register_write(cb_name, wm_write,
- &(user_data_t){
- .data = node, .free_func = wm_config_free,
- });
+ status = plugin_register_write(cb_name, wm_write,
+ &(user_data_t){
+ .data = node,
+ .free_func = wm_config_free,
+ });
INFO("write_mongodb plugin: registered write plugin %s %d", cb_name,
status);
}