* Florian octo Forster <octo at collectd.org>
*/
+#include <arpa/inet.h>
+#include <errno.h>
+#include <netdb.h>
+#include <inttypes.h>
+#include <pthread.h>
+
#include "collectd.h"
#include "plugin.h"
#include "common.h"
#include "configfile.h"
#include "utils_cache.h"
#include "riemann.pb-c.h"
-
-#include <sys/socket.h>
-#include <arpa/inet.h>
-#include <errno.h>
-#include <netdb.h>
-#include <inttypes.h>
-#include <pthread.h>
+#include "write_riemann_threshold.h"
#define RIEMANN_HOST "localhost"
#define RIEMANN_PORT "5555"
#define RIEMANN_TTL_FACTOR 2.0
#define RIEMANN_BATCH_MAX 8192
-int write_riemann_threshold_check(const data_set_t *, const value_list_t *, int *);
-
struct riemann_host {
char *name;
char *event_service_prefix;
if (host->use_tcp)
buffer_len += 4;
- buffer = malloc (buffer_len);
+ buffer = calloc (1, buffer_len);
if (buffer == NULL) {
- ERROR ("write_riemann plugin: malloc failed.");
+ ERROR ("write_riemann plugin: calloc failed.");
return ENOMEM;
}
- memset (buffer, 0, buffer_len);
if (host->use_tcp)
{
notification_meta_t *meta;
size_t i;
- msg = malloc (sizeof (*msg));
+ msg = calloc (1, sizeof (*msg));
if (msg == NULL)
{
- ERROR ("write_riemann plugin: malloc failed.");
+ ERROR ("write_riemann plugin: calloc failed.");
return (NULL);
}
- memset (msg, 0, sizeof (*msg));
msg__init (msg);
msg->events = malloc (sizeof (*msg->events));
return (NULL);
}
- event = malloc (sizeof (*event));
+ event = calloc (1, sizeof (*event));
if (event == NULL)
{
- ERROR ("write_riemann plugin: malloc failed.");
+ ERROR ("write_riemann plugin: calloc failed.");
sfree (msg->events);
sfree (msg);
return (NULL);
}
- memset (event, 0, sizeof (*event));
event__init (event);
msg->events[0] = event;
double ttl;
size_t i;
- event = malloc (sizeof (*event));
+ event = calloc (1, sizeof (*event));
if (event == NULL)
{
- ERROR ("write_riemann plugin: malloc failed.");
+ ERROR ("write_riemann plugin: calloc failed.");
return (NULL);
}
- memset (event, 0, sizeof (*event));
event__init (event);
event->host = strdup (vl->host);
gauge_t *rates = NULL;
/* Initialize the Msg structure. */
- msg = malloc (sizeof (*msg));
+ msg = calloc (1, sizeof (*msg));
if (msg == NULL)
{
- ERROR ("write_riemann plugin: malloc failed.");
+ ERROR ("write_riemann plugin: calloc failed.");
return (NULL);
}
- memset (msg, 0, sizeof (*msg));
msg__init (msg);
/* Set up events. First, the list of pointers. */
}
if ((val = strdup(child->values[1].value.string)) == NULL) {
WARNING("cannot allocate memory for attribute value.");
+ sfree (key);
return (-1);
}
strarray_add(&riemann_attrs, &riemann_attrs_num, key);