#include "collectd.h"
+#include "common.h"
+#include "plugin.h"
+#include "utils_cache.h"
+
#include <arpa/inet.h>
#include <errno.h>
#include <inttypes.h>
#include <netdb.h>
#include <stddef.h>
-#include "common.h"
-#include "plugin.h"
-#include "utils_cache.h"
#include <stdlib.h>
#define SENSU_HOST "localhost"
// incorporate the data source type
if ((ds->ds[index].type != DS_TYPE_GAUGE) && (rates != NULL)) {
char ds_type[DATA_MAX_NAME_LEN];
- ssnprintf(ds_type, sizeof(ds_type), "%s:rate",
- DS_TYPE_TO_STRING(ds->ds[index].type));
+ snprintf(ds_type, sizeof(ds_type), "%s:rate",
+ DS_TYPE_TO_STRING(ds->ds[index].type));
res = my_asprintf(&temp_str, "%s, \"collectd_data_source_type\": \"%s\"",
ret_str, ds_type);
free(ret_str);
// incorporate the data source index
{
char ds_index[DATA_MAX_NAME_LEN];
- ssnprintf(ds_index, sizeof(ds_index), "%zu", index);
+ snprintf(ds_index, sizeof(ds_index), "%zu", index);
res = my_asprintf(&temp_str, "%s, \"collectd_data_source_index\": %s",
ret_str, ds_index);
free(ret_str);
host->separator);
if (host->always_append_ds || (ds->ds_num > 1)) {
if (host->event_service_prefix == NULL)
- ssnprintf(service_buffer, sizeof(service_buffer), "%s.%s", name_buffer,
- ds->ds[index].name);
+ snprintf(service_buffer, sizeof(service_buffer), "%s.%s", name_buffer,
+ ds->ds[index].name);
else
- ssnprintf(service_buffer, sizeof(service_buffer), "%s%s.%s",
- host->event_service_prefix, name_buffer, ds->ds[index].name);
+ snprintf(service_buffer, sizeof(service_buffer), "%s%s.%s",
+ host->event_service_prefix, name_buffer, ds->ds[index].name);
} else {
if (host->event_service_prefix == NULL)
sstrncpy(service_buffer, name_buffer, sizeof(service_buffer));
else
- ssnprintf(service_buffer, sizeof(service_buffer), "%s%s",
- host->event_service_prefix, name_buffer);
+ snprintf(service_buffer, sizeof(service_buffer), "%s%s",
+ host->event_service_prefix, name_buffer);
}
// Replace collectd sensor name reserved characters so that time series DB is
sensu_close_socket(host);
if (status != 0) {
- char errbuf[1024];
ERROR("write_sensu plugin: Sending to Sensu at %s:%s failed: %s",
(host->node != NULL) ? host->node : SENSU_HOST,
- (host->service != NULL) ? host->service : SENSU_PORT,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ (host->service != NULL) ? host->service : SENSU_PORT, STRERRNO);
return -1;
}
sfree(host->separator);
free_str_list(&(host->metric_handlers));
free_str_list(&(host->notification_handlers));
+
+ pthread_mutex_unlock(&host->lock);
pthread_mutex_destroy(&host->lock);
+
sfree(host);
} /* }}} void sensu_free */
return -1;
}
- ssnprintf(callback_name, sizeof(callback_name), "write_sensu/%s", host->name);
+ snprintf(callback_name, sizeof(callback_name), "write_sensu/%s", host->name);
user_data_t ud = {.data = host, .free_func = sensu_free};