#include "collectd.h"
-#include "common.h"
#include "plugin.h"
+#include "utils/common/common.h"
#include "utils_cache.h"
#include <arpa/inet.h>
#include <errno.h>
#define F_READY 0x01
uint8_t flags;
pthread_mutex_t lock;
- _Bool notifications;
- _Bool metrics;
- _Bool store_rates;
- _Bool always_append_ds;
+ bool notifications;
+ bool metrics;
+ bool store_rates;
+ bool always_append_ds;
char *separator;
char *node;
char *service;
int reference_count;
};
-static char *sensu_tags = NULL;
-static char **sensu_attrs = NULL;
+static char *sensu_tags;
+static char **sensu_attrs;
static size_t sensu_attrs_num;
static int add_str_to_list(struct str_list *strs,
static void in_place_replace_sensu_name_reserved(char *orig_name) /* {{{ */
{
- int len = strlen(orig_name);
- for (int i = 0; i < len; i++) {
+ size_t len = strlen(orig_name);
+ for (size_t i = 0; i < len; i++) {
// some plugins like ipmi generate special characters in metric name
switch (orig_name[i]) {
case '(':
static char *sensu_value_to_json(struct sensu_host const *host, /* {{{ */
data_set_t const *ds, value_list_t const *vl,
- size_t index, gauge_t const *rates,
- int status) {
+ size_t index, gauge_t const *rates) {
char name_buffer[5 * DATA_MAX_NAME_LEN];
char service_buffer[6 * DATA_MAX_NAME_LEN];
char *ret_str;
r += newlen;
p = q + oldlen;
}
- strncpy(r, p, strlen(p));
+ sstrncpy(r, p, retlen + 1);
return ret;
} /* }}} char *replace_str */
}
}
for (size_t i = 0; i < vl->values_len; i++) {
- msg = sensu_value_to_json(host, ds, vl, (int)i, rates, statuses[i]);
+ msg = sensu_value_to_json(host, ds, vl, (int)i, rates);
if (msg == NULL) {
sfree(rates);
pthread_mutex_unlock(&host->lock);
host->reference_count = 1;
host->node = NULL;
host->service = NULL;
- host->notifications = 0;
- host->metrics = 0;
- host->store_rates = 1;
- host->always_append_ds = 0;
+ host->notifications = false;
+ host->metrics = false;
+ host->store_rates = true;
+ host->always_append_ds = false;
host->metric_handlers.nb_strs = 0;
host->metric_handlers.strs = NULL;
host->notification_handlers.nb_strs = 0;
break;
} else if (strcasecmp("Port", child->key) == 0) {
status = cf_util_get_service(child, &host->service);
- if (status != 0) {
- ERROR("write_sensu plugin: Invalid argument "
- "configured for the \"Port\" "
- "option.");
+ if (status != 0)
break;
- }
} else if (strcasecmp("StoreRates", child->key) == 0) {
status = cf_util_get_boolean(child, &host->store_rates);
if (status != 0)
return -1;
}
- if ((host->notification_handlers.nb_strs > 0) && (host->notifications == 0)) {
+ if ((host->notification_handlers.nb_strs > 0) &&
+ (host->notifications == false)) {
WARNING("write_sensu plugin: NotificationHandler given so forcing "
"notifications to be enabled");
host->notifications = 1;
}
- if ((host->metric_handlers.nb_strs > 0) && (host->metrics == 0)) {
+ if ((host->metric_handlers.nb_strs > 0) && (host->metrics == false)) {
WARNING("write_sensu plugin: MetricHandler given so forcing metrics to be "
"enabled");
- host->metrics = 1;
+ host->metrics = true;
}
if (!(host->notifications || host->metrics)) {