Merge branch 'collectd-5.5'
authorRuben Kerkhof <ruben@rubenkerkhof.com>
Tue, 1 Mar 2016 11:47:25 +0000 (12:47 +0100)
committerRuben Kerkhof <ruben@rubenkerkhof.com>
Tue, 1 Mar 2016 11:47:25 +0000 (12:47 +0100)
1  2 
src/barometer.c
src/daemon/collectd.c
src/daemon/plugin.h
src/daemon/utils_cache.c
src/redis.c
src/write_riemann.c
src/write_riemann_threshold.c
src/write_sensu.c

diff --combined src/barometer.c
@@@ -407,7 -407,7 +407,7 @@@ static int get_reference_temperature(do
  
      gauge_t * values = NULL;   /**< rate values */
      size_t    values_num = 0;  /**< number of rate values */
 -    int i;
 +    size_t i;
  
      gauge_t values_history[REF_TEMP_AVG_NUM];
  
  
              for(i=0; i<values_num; ++i)
              {
 -                DEBUG ("barometer: get_reference_temperature - rate %d: %lf **",
 -                       i,
 -                       values[i]);
 +                DEBUG ("barometer: get_reference_temperature - rate %zu: %lf **",
 +                       i, values[i]);
                  if(!isnan(values[i]))
                  {
                      avg_sum += values[i];
  
          for(i=0; i<REF_TEMP_AVG_NUM*list->num_values; ++i)
          {
 -            DEBUG ("barometer: get_reference_temperature - history %d: %lf",
 -                   i,
 -                   values_history[i]);
 +            DEBUG ("barometer: get_reference_temperature - history %zu: %lf",
 +                   i, values_history[i]);
              if(!isnan(values_history[i]))
              {
                  avg_sum += values_history[i];
  
              for(i=0; i<values_num; ++i)
              {
 -                DEBUG ("barometer: get_reference_temperature - rate last %d: %lf **",
 -                       i,
 -                       values[i]);
 +                DEBUG ("barometer: get_reference_temperature - rate last %zu: %lf **",
 +                       i, values[i]);
                  if(!isnan(values[i]))
                  {
                      avg_sum += values[i];
@@@ -1360,7 -1363,7 +1360,7 @@@ static int BMP085_read(double * pressur
   *
   * @return detected sensor type
   */
enum Sensor_type Detect_sensor_type(void)
static enum Sensor_type detect_sensor_type(void)
  {
      if(BMP085_detect())
          return Sensor_BMP085;
@@@ -1802,7 -1805,7 +1802,7 @@@ static int collectd_barometer_init (voi
      }
  
      /* detect sensor type - this will also set slave address */
-     sensor_type = Detect_sensor_type();
+     sensor_type = detect_sensor_type();
  
      /* init correct sensor type */
      switch(sensor_type)
diff --combined src/daemon/collectd.c
@@@ -32,6 -32,7 +32,6 @@@
  #include "configfile.h"
  
  #include <sys/types.h>
 -#include <sys/socket.h>
  #include <sys/un.h>
  #include <netdb.h>
  
@@@ -422,91 -423,68 +422,91 @@@ static int pidfile_remove (void
  #endif /* COLLECT_DAEMON */
  
  #ifdef KERNEL_LINUX
- int notify_upstart (void)
static int notify_upstart (void)
  {
 -    const char  *upstart_job = getenv("UPSTART_JOB");
 +    char const *upstart_job = getenv("UPSTART_JOB");
  
      if (upstart_job == NULL)
          return 0;
  
      if (strcmp(upstart_job, "collectd") != 0)
 +    {
 +        WARNING ("Environment specifies unexpected UPSTART_JOB=\"%s\", expected \"collectd\". Ignoring the variable.", upstart_job);
          return 0;
 +    }
  
 -    WARNING ("supervised by upstart, will stop to signal readyness");
 +    NOTICE("Upstart detected, stopping now to signal readyness.");
      raise(SIGSTOP);
      unsetenv("UPSTART_JOB");
  
      return 1;
  }
  
- int notify_systemd (void)
static int notify_systemd (void)
  {
 -    int                  fd = -1;
 -    const char          *notifysocket = getenv("NOTIFY_SOCKET");
 +    int                  fd;
 +    const char          *notifysocket;
      struct sockaddr_un   su;
 -    struct iovec         iov;
 -    struct msghdr        hdr;
 +    size_t               su_size;
 +    char                 buffer[] = "READY=1\n";
  
 +    notifysocket = getenv ("NOTIFY_SOCKET");
      if (notifysocket == NULL)
          return 0;
  
 -    if ((strchr("@/", notifysocket[0])) == NULL ||
 -        strlen(notifysocket) < 2)
 +    if ((strlen (notifysocket) < 2)
 +        || ((notifysocket[0] != '@') && (notifysocket[0] != '/')))
 +    {
 +        ERROR ("invalid notification socket NOTIFY_SOCKET=\"%s\": path must be absolute", notifysocket);
          return 0;
 +    }
 +    NOTICE ("Systemd detected, trying to signal readyness.");
  
 -    WARNING ("supervised by systemd, will signal readyness");
 -    if ((fd = socket(AF_UNIX, SOCK_DGRAM, 0)) < 0) {
 -        WARNING ("cannot contact systemd socket %s", notifysocket);
 +    unsetenv ("NOTIFY_SOCKET");
 +
 +#if defined(SOCK_CLOEXEC)
 +    fd = socket (AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, /* protocol = */ 0);
 +#else
 +    fd = socket (AF_UNIX, SOCK_DGRAM, /* protocol = */ 0);
 +#endif
 +    if (fd < 0) {
 +        char errbuf[1024];
 +        ERROR ("creating UNIX socket failed: %s",
 +                 sstrerror (errno, errbuf, sizeof (errbuf)));
          return 0;
      }
  
 -    bzero(&su, sizeof(su));
 +    memset (&su, 0, sizeof (su));
      su.sun_family = AF_UNIX;
 -    sstrncpy (su.sun_path, notifysocket, sizeof(su.sun_path));
 -
 -    if (notifysocket[0] == '@')
 +    if (notifysocket[0] != '@')
 +    {
 +        /* regular UNIX socket */
 +        sstrncpy (su.sun_path, notifysocket, sizeof (su.sun_path));
 +        su_size = sizeof (su);
 +    }
 +    else
 +    {
 +        /* Linux abstract namespace socket: specify address as "\0foo", i.e.
 +         * start with a null byte. Since null bytes have no special meaning in
 +         * that case, we have to set su_size correctly to cover only the bytes
 +         * that are part of the address. */
 +        sstrncpy (su.sun_path, notifysocket, sizeof (su.sun_path));
          su.sun_path[0] = 0;
 +        su_size = sizeof (sa_family_t) + strlen (notifysocket);
 +        if (su_size > sizeof (su))
 +            su_size = sizeof (su);
 +    }
  
 -    bzero(&iov, sizeof(iov));
 -    iov.iov_base = "READY=1";
 -    iov.iov_len = strlen("READY=1");
 -
 -    bzero(&hdr, sizeof(hdr));
 -    hdr.msg_name = &su;
 -    hdr.msg_namelen = offsetof(struct sockaddr_un, sun_path) +
 -        strlen(notifysocket);
 -    hdr.msg_iov = &iov;
 -    hdr.msg_iovlen = 1;
 -
 -    unsetenv("NOTIFY_SOCKET");
 -    if (sendmsg(fd, &hdr, MSG_NOSIGNAL) < 0) {
 -        WARNING ("cannot send notification to systemd");
 +    if (sendto (fd, buffer, strlen (buffer), MSG_NOSIGNAL, (void *) &su, (socklen_t) su_size) < 0)
 +    {
 +        char errbuf[1024];
 +        ERROR ("sendto(\"%s\") failed: %s", notifysocket,
 +                 sstrerror (errno, errbuf, sizeof (errbuf)));
          close(fd);
          return 0;
      }
 +
 +    unsetenv ("NOTIFY_SOCKET");
      close(fd);
      return 1;
  }
@@@ -638,8 -616,6 +638,8 @@@ int main (int argc, char **argv
  #endif
        )
        {
 +              int status;
 +
                if ((pid = fork ()) == -1)
                {
                        /* error */
                close (1);
                close (0);
  
 -              if (open ("/dev/null", O_RDWR) != 0)
 +              status = open ("/dev/null", O_RDWR);
 +              if (status != 0)
                {
 -                      ERROR ("Error: Could not connect `STDIN' to `/dev/null'");
 +                      ERROR ("Error: Could not connect `STDIN' to `/dev/null' (status %d)", status);
                        return (1);
                }
 -              if (dup (0) != 1)
 +
 +              status = dup (0);
 +              if (status != 1)
                {
 -                      ERROR ("Error: Could not connect `STDOUT' to `/dev/null'");
 +                      ERROR ("Error: Could not connect `STDOUT' to `/dev/null' (status %d)", status);
                        return (1);
                }
 -              if (dup (0) != 2)
 +
 +              status = dup (0);
 +              if (status != 2)
                {
 -                      ERROR ("Error: Could not connect `STDERR' to `/dev/null'");
 +                      ERROR ("Error: Could not connect `STDERR' to `/dev/null', (status %d)", status);
                        return (1);
                }
        } /* if (daemonize) */
diff --combined src/daemon/plugin.h
@@@ -97,7 -97,7 +97,7 @@@ typedef union value_u value_t
  struct value_list_s
  {
        value_t *values;
 -      int      values_len;
 +      size_t   values_len;
        cdtime_t time;
        cdtime_t interval;
        char     host[DATA_MAX_NAME_LEN];
@@@ -125,7 -125,7 +125,7 @@@ typedef struct data_source_s data_sourc
  struct data_set_s
  {
        char           type[DATA_MAX_NAME_LEN];
 -      int            ds_num;
 +      size_t         ds_num;
        data_source_t *ds;
  };
  typedef struct data_set_s data_set_t;
@@@ -177,8 -177,6 +177,8 @@@ typedef struct user_data_s user_data_t
  struct plugin_ctx_s
  {
        cdtime_t interval;
 +      cdtime_t flush_interval;
 +      cdtime_t flush_timeout;
  };
  typedef struct plugin_ctx_s plugin_ctx_t;
  
@@@ -295,7 -293,7 +295,7 @@@ int plugin_register_read (const char *n
   * "plugin_register_complex_read" returns an error (non-zero). */
  int plugin_register_complex_read (const char *group, const char *name,
                plugin_read_cb callback,
 -              const struct timespec *interval,
 +              cdtime_t interval,
                user_data_t *user_data);
  int plugin_register_write (const char *name,
                plugin_write_cb callback, user_data_t *user_data);
@@@ -334,7 -332,7 +334,7 @@@ int plugin_unregister_notification (con
   *  Since some writers dynamically build their name it can be hard for
   *  the configuring person to know it. This function will fill this gap.
   */
- void plugin_log_available_writers ();
+ void plugin_log_available_writers (void);
  
  /*
   * NAME
diff --combined src/daemon/utils_cache.c
@@@ -37,7 -37,7 +37,7 @@@
  typedef struct cache_entry_s
  {
        char name[6 * DATA_MAX_NAME_LEN];
 -      int        values_num;
 +      size_t     values_num;
        gauge_t   *values_gauge;
        value_t   *values_raw;
        /* Time contained in the package
@@@ -79,7 -79,7 +79,7 @@@ static int cache_compare (const cache_e
    return (strcmp (a->name, b->name));
  } /* int cache_compare */
  
 -static cache_entry_t *cache_alloc (int values_num)
 +static cache_entry_t *cache_alloc (size_t values_num)
  {
    cache_entry_t *ce;
  
@@@ -128,7 -128,7 +128,7 @@@ static void cache_free (cache_entry_t *
  
  static void uc_check_range (const data_set_t *ds, cache_entry_t *ce)
  {
 -  int i;
 +  size_t i;
  
    for (i = 0; i < ds->ds_num; i++)
    {
  static int uc_insert (const data_set_t *ds, const value_list_t *vl,
      const char *key)
  {
 -  int i;
    char *key_copy;
    cache_entry_t *ce;
 +  size_t i;
  
    /* `cache_lock' has been locked by `uc_update' */
  
    if (ce == NULL)
    {
      sfree (key_copy);
 -    ERROR ("uc_insert: cache_alloc (%i) failed.", ds->ds_num);
 +    ERROR ("uc_insert: cache_alloc (%zu) failed.", ds->ds_num);
      return (-1);
    }
  
@@@ -375,7 -375,7 +375,7 @@@ int uc_update (const data_set_t *ds, co
    char name[6 * DATA_MAX_NAME_LEN];
    cache_entry_t *ce = NULL;
    int status;
 -  int i;
 +  size_t i;
  
    if (FORMAT_VL (name, sizeof (name), vl) != 0)
    {
      {
        case DS_TYPE_COUNTER:
        {
 -        counter_t diff;
 -
 -        /* check if the counter has wrapped around */
 -        if (vl->values[i].counter < ce->values_raw[i].counter)
 -        {
 -          if (ce->values_raw[i].counter <= 4294967295U)
 -            diff = (4294967295U - ce->values_raw[i].counter)
 -              + vl->values[i].counter;
 -          else
 -            diff = (18446744073709551615ULL - ce->values_raw[i].counter)
 -              + vl->values[i].counter;
 -        }
 -        else /* counter has NOT wrapped around */
 -        {
 -          diff = vl->values[i].counter - ce->values_raw[i].counter;
 -        }
 -
 +        counter_t diff = counter_diff (ce->values_raw[i].counter, vl->values[i].counter);
          ce->values_gauge[i] = ((double) diff)
            / (CDTIME_T_TO_DOUBLE (vl->time - ce->last_time));
          ce->values_raw[i].counter = vl->values[i].counter;
  
        case DS_TYPE_DERIVE:
        {
 -        derive_t diff;
 -
 -        diff = vl->values[i].derive - ce->values_raw[i].derive;
 +        derive_t diff = vl->values[i].derive - ce->values_raw[i].derive;
  
          ce->values_gauge[i] = ((double) diff)
            / (CDTIME_T_TO_DOUBLE (vl->time - ce->last_time));
        return (-1);
      } /* switch (ds->ds[i].type) */
  
 -    DEBUG ("uc_update: %s: ds[%i] = %lf", name, i, ce->values_gauge[i]);
 +    DEBUG ("uc_update: %s: ds[%zu] = %lf", name, i, ce->values_gauge[i]);
    } /* for (i) */
  
    /* Update the history if it exists. */
@@@ -549,7 -567,7 +549,7 @@@ gauge_t *uc_get_rate (const data_set_t 
     * values are returned. */
    if (ret_num != (size_t) ds->ds_num)
    {
 -    ERROR ("utils_cache: uc_get_rate: ds[%s] has %i values, "
 +    ERROR ("utils_cache: uc_get_rate: ds[%s] has %zu values, "
        "but uc_get_rate_by_name returned %zu.",
        ds->type, ds->ds_num, ret_num);
      sfree (ret);
    return (ret);
  } /* gauge_t *uc_get_rate */
  
- size_t uc_get_size() {
+ size_t uc_get_size (void) {
    size_t size_arrays = 0;
  
    pthread_mutex_lock (&cache_lock);
diff --combined src/redis.c
@@@ -294,7 -294,7 +294,7 @@@ static int redis_init (void) /* {{{ *
    return (0);
  } /* }}} int redis_init */
  
- int redis_handle_info (char *node, char const *info_line, char const *type, char const *type_instance, char const *field_name, int ds_type) /* {{{ */
static int redis_handle_info (char *node, char const *info_line, char const *type, char const *type_instance, char const *field_name, int ds_type) /* {{{ */
  {
    char *str = strstr (info_line, field_name);
    static char buf[MAX_REDIS_VAL_SIZE];
      int i;
  
      str += strlen (field_name) + 1; /* also skip the ':' */
 -    for(i=0;(*str && (isdigit(*str) || *str == '.'));i++,str++)
 +    for(i=0;(*str && (isdigit((unsigned char)*str) || *str == '.'));i++,str++)
        buf[i] = *str;
      buf[i] ='\0';
  
  
  } /* }}} int redis_handle_info */
  
- int redis_handle_query (redisContext *rh, redis_node_t *rn, redis_query_t *rq) /* {{{ */
static int redis_handle_query (redisContext *rh, redis_node_t *rn, redis_query_t *rq) /* {{{ */
  {
      redisReply *rr;
      const data_set_t *ds;
@@@ -430,14 -430,9 +430,14 @@@ static int redis_read (void) /* {{{ *
      redis_handle_info (rn->name, rr->str, "total_connections", NULL, "total_connections_received", DS_TYPE_DERIVE);
      redis_handle_info (rn->name, rr->str, "total_operations", NULL, "total_commands_processed", DS_TYPE_DERIVE);
      redis_handle_info (rn->name, rr->str, "expired_keys", NULL, "expired_keys", DS_TYPE_DERIVE);
 +    redis_handle_info (rn->name, rr->str, "evicted_keys", NULL, "evicted_keys", DS_TYPE_DERIVE);
      redis_handle_info (rn->name, rr->str, "pubsub", "channels", "pubsub_channels", DS_TYPE_GAUGE);
      redis_handle_info (rn->name, rr->str, "pubsub", "patterns", "pubsub_patterns", DS_TYPE_GAUGE);
      redis_handle_info (rn->name, rr->str, "current_connections", "slaves", "connected_slaves", DS_TYPE_GAUGE);
 +    redis_handle_info (rn->name, rr->str, "cache_result", "hits", "keyspace_hits", DS_TYPE_DERIVE);
 +    redis_handle_info (rn->name, rr->str, "cache_result", "misses", "keyspace_misses", DS_TYPE_DERIVE);
 +    redis_handle_info (rn->name, rr->str, "total_bytes", "input", "total_net_input_bytes", DS_TYPE_DERIVE);
 +    redis_handle_info (rn->name, rr->str, "total_bytes", "output", "total_net_output_bytes", DS_TYPE_DERIVE);
  
      freeReplyObject (rr);
  
diff --combined src/write_riemann.c
   *   Florian octo Forster <octo at collectd.org>
   */
  
 -#include <sys/socket.h>
+ #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 <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;
@@@ -364,7 -364,7 +363,7 @@@ static Msg *riemann_notification_to_pro
        char service_buffer[6 * DATA_MAX_NAME_LEN];
        char const *severity;
        notification_meta_t *meta;
 -      int i;
 +      size_t i;
  
        msg = malloc (sizeof (*msg));
        if (msg == NULL)
@@@ -473,7 -473,7 +472,7 @@@ static Event *riemann_value_to_protobuf
        char name_buffer[5 * DATA_MAX_NAME_LEN];
        char service_buffer[6 * DATA_MAX_NAME_LEN];
        double ttl;
 -      int i;
 +      size_t i;
  
        event = malloc (sizeof (*event));
        if (event == NULL)
@@@ -618,7 -618,7 +617,7 @@@ static Msg *riemann_value_list_to_proto
        msg__init (msg);
  
        /* Set up events. First, the list of pointers. */
 -      msg->n_events = (size_t) vl->values_len;
 +      msg->n_events = vl->values_len;
        msg->events = calloc (msg->n_events, sizeof (*msg->events));
        if (msg->events == NULL)
        {
@@@ -743,8 -743,8 +742,8 @@@ static int riemann_batch_add_value_lis
  
        len = msg__get_packed_size(host->batch_msg);
      ret = 0;
 -    if (len >= host->batch_max) {
 -        ret = riemann_batch_flush_nolock(0, host);
 +    if ((host->batch_max < 0) || (((size_t) host->batch_max) <= len)) {
 +          ret = riemann_batch_flush_nolock(0, host);
      }
  
      pthread_mutex_unlock(&host->lock);
@@@ -777,35 -777,35 +776,35 @@@ static int riemann_notification(const n
  } /* }}} int riemann_notification */
  
  static int riemann_write(const data_set_t *ds, /* {{{ */
 -            const value_list_t *vl,
 -            user_data_t *ud)
 +              const value_list_t *vl,
 +              user_data_t *ud)
  {
        int                      status = 0;
        int                      statuses[vl->values_len];
        struct riemann_host     *host = ud->data;
 -      Msg                     *msg;
 -
 -      if (host->check_thresholds)
 -              write_riemann_threshold_check(ds, vl, statuses);
 -
 -    if (host->use_tcp == 1 && host->batch_mode) {
 -
 -        riemann_batch_add_value_list (host, ds, vl, statuses);
  
 +      if (host->check_thresholds) {
 +              status = write_riemann_threshold_check(ds, vl, statuses);
 +              if (status != 0)
 +                      return status;
 +      } else {
 +              memset (statuses, 0, sizeof (statuses));
 +      }
  
 -    } else {
 +      if (host->use_tcp == 1 && host->batch_mode) {
 +              riemann_batch_add_value_list (host, ds, vl, statuses);
 +      } else {
 +              Msg *msg = riemann_value_list_to_protobuf (host, ds, vl, statuses);
 +              if (msg == NULL)
 +                      return (-1);
  
 -        msg = riemann_value_list_to_protobuf (host, ds, vl, statuses);
 -        if (msg == NULL)
 -            return (-1);
 +              status = riemann_send (host, msg);
 +              if (status != 0)
 +                      ERROR ("write_riemann plugin: riemann_send failed with status %i", status);
  
 -        status = riemann_send (host, msg);
 -        if (status != 0)
 -            ERROR ("write_riemann plugin: riemann_send failed with status %i",
 -                   status);
 +              riemann_msg_protobuf_free (msg);
 +      }
  
 -        riemann_msg_protobuf_free (msg);
 -    }
        return status;
  } /* }}} int riemann_write */
  
   *   Andrés J. Díaz <ajdiaz at connectical.com>
   **/
  
+ #include <assert.h>
+ #include <ltdl.h>
+ #include <pthread.h>
  #include "collectd.h"
  #include "common.h"
  #include "plugin.h"
  #include "utils_avltree.h"
  #include "utils_cache.h"
  #include "utils_threshold.h"
- #include <assert.h>
- #include <pthread.h>
+ #include "write_riemann_threshold.h"
  
  /*
   * Threshold management
@@@ -132,7 -134,7 +134,7 @@@ static int ut_check_one_threshold (cons
      int *statuses)
  { /* {{{ */
    int ret = -1;
 -  int i;
 +  size_t i;
    int status;
    gauge_t values_copy[ds->ds_num];
  
@@@ -201,9 -203,7 +203,9 @@@ int write_riemann_threshold_check (cons
    gauge_t *values;
    int status;
  
 +  assert (vl->values_len > 0);
    memset(statuses, 0, vl->values_len * sizeof(*statuses));
 +
    if (threshold_tree == NULL)
          return 0;
  
diff --combined src/write_sensu.c
@@@ -29,6 -29,7 +29,6 @@@
  #include "common.h"
  #include "configfile.h"
  #include "utils_cache.h"
 -#include <sys/socket.h>
  #include <arpa/inet.h>
  #include <errno.h>
  #include <netdb.h>
@@@ -46,7 -47,7 +46,7 @@@
  #include <stdio.h>
  #include <stdarg.h>
  
- int vasprintf(char **str, const char *fmt, va_list args) {
static int vasprintf(char **str, const char *fmt, va_list args) {
        int size = 0;
        va_list tmpa;
        // copy
@@@ -70,7 -71,7 +70,7 @@@
        return size;
  }
  
- int asprintf(char **str, const char *fmt, ...) {
static int asprintf(char **str, const char *fmt, ...) {
        int size = 0;
        va_list args;
        // init variadic argumens
@@@ -258,7 -259,7 +258,7 @@@ static char *build_json_str_list(const 
        return ret_str;
  } /* }}} char *build_json_str_list*/
  
- int sensu_format_name2(char *ret, int ret_len,
static int sensu_format_name2(char *ret, int ret_len,
                const char *hostname,
                const char *plugin, const char *plugin_instance,
                const char *type, const char *type_instance,
@@@ -328,7 -329,7 +328,7 @@@ static char *sensu_value_to_json(struc
  {
        char name_buffer[5 * DATA_MAX_NAME_LEN];
        char service_buffer[6 * DATA_MAX_NAME_LEN];
 -      int i;
 +      size_t i;
        char *ret_str;
        char *temp_str;
        char *value_str;
   * http://creativeandcritical.net/str-replace-c/
   * copyright (c) Laird Shaw, under public domain.
   */
- char *replace_str(const char *str, const char *old, /* {{{ */
static char *replace_str(const char *str, const char *old, /* {{{ */
                const char *new)
  {
        char *ret, *r;
@@@ -640,7 -641,7 +640,7 @@@ static char *sensu_notification_to_json
        char *ret_str;
        char *temp_str;
        int status;
 -      int i;
 +      size_t i;
        int res;
        // add the severity/status
        switch (n->severity) {
@@@ -884,7 -885,7 +884,7 @@@ static int sensu_write(const data_set_
        int statuses[vl->values_len];
        struct sensu_host       *host = ud->data;
        gauge_t *rates = NULL;
 -      int i;
 +      size_t i;
        char *msg;
  
        pthread_mutex_lock(&host->lock);
                        return -1;
                }
        }
 -      for (i = 0; i < (size_t) vl->values_len; i++) {
 +      for (i = 0; i < vl->values_len; i++) {
                msg = sensu_value_to_json(host, ds, vl, (int) i, rates, statuses[i]);
                if (msg == NULL) {
                        sfree(rates);