Merge remote-tracking branch 'github/pr/706'
authorFlorian Forster <octo@collectd.org>
Fri, 22 Aug 2014 05:23:28 +0000 (07:23 +0200)
committerFlorian Forster <octo@collectd.org>
Fri, 22 Aug 2014 05:23:28 +0000 (07:23 +0200)
Conflicts:
src/write_riemann.c

1  2 
src/collectd.conf.in
src/collectd.conf.pod
src/write_riemann.c

diff --combined src/collectd.conf.in
  #@BUILD_PLUGIN_WRITE_MONGODB_TRUE@LoadPlugin write_mongodb
  #@BUILD_PLUGIN_WRITE_REDIS_TRUE@LoadPlugin write_redis
  #@BUILD_PLUGIN_WRITE_RIEMANN_TRUE@LoadPlugin write_riemann
 +#@BUILD_PLUGIN_WRITE_TSDB_TRUE@LoadPlugin write_tsdb
  #@BUILD_PLUGIN_XMMS_TRUE@LoadPlugin xmms
  #@BUILD_PLUGIN_ZFS_ARC_TRUE@LoadPlugin zfs_arc
  
  #  </View>
  #</Plugin>
  
 -#<Plugin cgroup>
 +#<Plugin cgroups>
  #  CGroup "libvirt"
  #  IgnoreSelected false
  #</Plugin>
  #             StoreRates true
  #             AlwaysAppendDS false
  #             TTLFactor 2.0
+ #             EventServicePrefix ""
  #     </Node>
  #     Tag "foobar"
  #       Attribute "foo" "bar"
  #</Plugin>
  
 +#<Plugin write_tsdb>
 +#     <Node>
 +#             Host "localhost"
 +#             Port "4242"
 +#             HostTags "status=production"
 +#             StoreRates false
 +#             AlwaysAppendDS false
 +#     </Node>
 +#</Plugin>
 +
  ##############################################################################
  # Filter configuration                                                       #
  #----------------------------------------------------------------------------#
diff --combined src/collectd.conf.pod
@@@ -494,8 -494,6 +494,8 @@@ possibly filtering or messages
   #   StoreRates false
   #   GraphitePrefix "collectd."
   #   GraphiteEscapeChar "_"
 + #   GraphiteSeparateInstances false
 + #   GraphiteAlwaysAppendDS false
     </Publish>
  
     # Receive values from an AMQP broker
@@@ -649,19 -647,6 +649,19 @@@ In I<Graphite> metric name, dots are us
  metric parts (host, plugin, type).
  Default is "_" (I<Underscore>).
  
 +=item B<GraphiteSeparateInstances> B<true>|B<false>
 +
 +If set to B<true>, the plugin instance and type instance will be in their own
 +path component, for example C<host.cpu.0.cpu.idle>. If set to B<false> (the
 +default), the plugin and plugin instance (and likewise the type and type
 +instance) are put into one component, for example C<host.cpu-0.cpu-idle>.
 +
 +=item B<GraphiteAlwaysAppendDS> B<true>|B<false>
 +
 +If set to B<true>, append the name of the I<Data Source> (DS) to the "metric"
 +identifier. If set to B<false> (the default), this is only done when there is
 +more than one DS.
 +
  =back
  
  =head2 Plugin C<apache>
@@@ -6527,59 -6512,6 +6527,59 @@@ instance) are put into one component, f
  
  =item B<AlwaysAppendDS> B<false>|B<true>
  
 +If set to B<true>, append the name of the I<Data Source> (DS) to the "metric"
 +identifier. If set to B<false> (the default), this is only done when there is
 +more than one DS.
 +
 +=back
 +
 +=head2 Plugin C<write_tsdb>
 +
 +The C<write_tsdb> plugin writes data to I<OpenTSDB>, a scalable open-source
 +time series database. The plugin connects to a I<TSD>, a masterless, no shared
 +state daemon that ingests metrics and stores them in HBase. The plugin uses
 +I<TCP> over the "line based" protocol with a default port 4242. The data will
 +be sent in blocks of at most 1428 bytes to minimize the number of network
 +packets.
 +
 +Synopsis:
 +
 + <Plugin write_tsdb>
 +   <Node "example">
 +     Host "tsd-1.my.domain"
 +     Port "4242"
 +     HostTags "status=production"
 +   </Node>
 + </Plugin>
 +
 +The configuration consists of one or more E<lt>B<Node>E<nbsp>I<Name>E<gt>
 +blocks. Inside the B<Node> blocks, the following options are recognized:
 +
 +=over 4
 +
 +=item B<Host> I<Address>
 +
 +Hostname or address to connect to. Defaults to C<localhost>.
 +
 +=item B<Port> I<Service>
 +
 +Service name or port number to connect to. Defaults to C<4242>.
 +
 +
 +=item B<HostTags> I<String>
 +
 +When set, I<HostTags> is added to the end of the metric. It is intended to be
 +used for name=value pairs that the TSD will tag the metric with. Dots and
 +whitespace are I<not> escaped in this string.
 +
 +=item B<StoreRates> B<false>|B<true>
 +
 +If set to B<true>, convert counter values to rates. If set to B<false>
 +(the default) counter values are stored as is, as an increasing
 +integer number.
 +
 +=item B<AlwaysAppendDS> B<false>|B<true>
 +
  If set the B<true>, append the name of the I<Data Source> (DS) to the "metric"
  identifier. If set to B<false> (the default), this is only done when there is
  more than one DS.
@@@ -6918,6 -6850,12 +6918,12 @@@ useful to avoid getting notification ev
  If set to B<true>, attach state to events based on thresholds defined
  in the B<Threshold> plugin. Defaults to B<false>.
  
+ =item B<EventServicePrefix> I<String>
+ Add the given string as a prefix to the event service name.
+ If B<EventServicePrefix> not set or set to an empty string (""),
+ no prefix will be used.
  =back
  
  =item B<Tag> I<String>
@@@ -7402,36 -7340,19 +7408,36 @@@ Available options
  =item B<Plugin> I<Name>
  
  Name of the write plugin to which the data should be sent. This option may be
 -given multiple times to send the data to more than one write plugin.
 +given multiple times to send the data to more than one write plugin. If the
 +plugin supports multiple instances, the plugin's instance(s) must also be
 +specified.
  
  =back
  
  If no plugin is explicitly specified, the values will be sent to all available
  write plugins.
  
 -Example:
 +Single-instance plugin example:
  
   <Target "write">
     Plugin "rrdtool"
   </Target>
  
 +Multi-instance plugin example:
 +
 + <Plugin "write_graphite">
 +   <Node "foo">
 +   ...
 +   </Node>
 +   <Node "bar">
 +   ...
 +   </Node>
 + </Plugin>
 +  ...
 + <Target "write">
 +   Plugin "write_graphite/foo"
 + </Target>
 +
  =item B<jump>
  
  Starts processing the rules of another chain, see L<"Flow control"> above. If
diff --combined src/write_riemann.c
@@@ -48,11 -48,12 +48,12 @@@ int write_riemann_threshold_check(cons
  
  struct riemann_host {
        char                    *name;
+       char                    *event_service_prefix;
  #define F_CONNECT              0x01
        uint8_t                  flags;
        pthread_mutex_t          lock;
 -    _Bool            notifications;
 -    _Bool            check_thresholds;
 +      _Bool                    notifications;
 +      _Bool                    check_thresholds;
        _Bool                    store_rates;
        _Bool                    always_append_ds;
        char                    *node;
@@@ -97,7 -98,7 +98,7 @@@ static void riemann_event_protobuf_fre
        sfree (event);
  } /* }}} void riemann_event_protobuf_free */
  
 -static void riemann_msg_protobuf_free (Msg *msg) /* {{{ */
 +static void riemann_msg_protobuf_free(Msg *msg) /* {{{ */
  {
        size_t i;
  
@@@ -319,7 -320,7 +320,7 @@@ static int riemann_event_add_tag (Even
        return (strarray_add (&event->tags, &event->n_tags, tag));
  } /* }}} int riemann_event_add_tag */
  
 -static int riemann_event_add_attribute (Event *event, /* {{{ */
 +static int riemann_event_add_attribute(Event *event, /* {{{ */
                char const *key, char const *value)
  {
        Attribute **new_attributes;
        return (0);
  } /* }}} int riemann_event_add_attribute */
  
 -static Msg *riemann_notification_to_protobuf (struct riemann_host *host, /* {{{ */
 +static Msg *riemann_notification_to_protobuf(struct riemann_host *host, /* {{{ */
                notification_t const *n)
  {
        Msg *msg;
        return (msg);
  } /* }}} Msg *riemann_notification_to_protobuf */
  
 -static Event *riemann_value_to_protobuf (struct riemann_host const *host, /* {{{ */
 +static Event *riemann_value_to_protobuf(struct riemann_host const *host, /* {{{ */
                data_set_t const *ds,
                value_list_t const *vl, size_t index,
                                         gauge_t const *rates,
        event->time = CDTIME_T_TO_TIME_T (vl->time);
        event->has_time = 1;
  
 -    if (host->check_thresholds) {
 -        switch (status) {
 -        case STATE_OKAY:
 -            event->state = strdup("ok");
 -            break;
 -        case STATE_ERROR:
 -            event->state = strdup("critical");
 -            break;
 -        case STATE_WARNING:
 -            event->state = strdup("warning");
 -            break;
 -        case STATE_MISSING:
 -            event->state = strdup("unknown");
 -            break;
 -        }
 -    }
 +      if (host->check_thresholds) {
 +              switch (status) {
 +                      case STATE_OKAY:
 +                              event->state = strdup("ok");
 +                              break;
 +                      case STATE_ERROR:
 +                              event->state = strdup("critical");
 +                              break;
 +                      case STATE_WARNING:
 +                              event->state = strdup("warning");
 +                              break;
 +                      case STATE_MISSING:
 +                              event->state = strdup("unknown");
 +                              break;
 +              }
 +      }
  
        ttl = CDTIME_T_TO_DOUBLE (vl->interval) * host->ttl_factor;
        event->ttl = (float) ttl;
                        /* host = */ "", vl->plugin, vl->plugin_instance,
                        vl->type, vl->type_instance);
        if (host->always_append_ds || (ds->ds_num > 1))
-               ssnprintf (service_buffer, sizeof (service_buffer),
-                               "%s/%s", &name_buffer[1], ds->ds[index].name);
 -              if (host->event_service_prefix == NULL || host->event_service_prefix[0] == '\0')
 -                      ssnprintf (service_buffer, sizeof (service_buffer),
 -                                      "%s/%s", &name_buffer[1], ds->ds[index].name);
++      {
++              if (host->event_service_prefix == NULL)
++                      ssnprintf (service_buffer, sizeof (service_buffer), "%s/%s",
++                                      &name_buffer[1], ds->ds[index].name);
+               else
 -                      ssnprintf (service_buffer, sizeof (service_buffer),
 -                                      "%s%s/%s", host->event_service_prefix, &name_buffer[1], ds->ds[index].name);
++                      ssnprintf (service_buffer, sizeof (service_buffer), "%s%s/%s",
++                                      host->event_service_prefix, &name_buffer[1], ds->ds[index].name);
++      }
        else
-               sstrncpy (service_buffer, &name_buffer[1],
-                               sizeof (service_buffer));
 -              if (host->event_service_prefix == NULL || host->event_service_prefix[0] == '\0')
 -                      sstrncpy (service_buffer, &name_buffer[1],
 -                                      sizeof (service_buffer));
++      {
++              if (host->event_service_prefix == NULL)
++                      sstrncpy (service_buffer, &name_buffer[1], sizeof (service_buffer));
+               else
 -                      ssnprintf (service_buffer, sizeof (service_buffer),
 -                                      "%s%s", host->event_service_prefix, &name_buffer[1]);
++                      ssnprintf (service_buffer, sizeof (service_buffer), "%s%s",
++                                      host->event_service_prefix, &name_buffer[1]);
++      }
  
        event->service = strdup (service_buffer);
  
@@@ -645,8 -654,8 +657,8 @@@ static int riemann_notification(const n
        struct riemann_host     *host = ud->data;
        Msg                     *msg;
  
 -    if (!host->notifications)
 -        return 0;
 +      if (!host->notifications)
 +              return 0;
  
        msg = riemann_notification_to_protobuf (host, n);
        if (msg == NULL)
@@@ -670,8 -679,8 +682,8 @@@ static int riemann_write(const data_set
        struct riemann_host     *host = ud->data;
        Msg                     *msg;
  
 -    if (host->check_thresholds)
 -        write_riemann_threshold_check(ds, vl, statuses);
 +      if (host->check_thresholds)
 +              write_riemann_threshold_check(ds, vl, statuses);
        msg = riemann_value_list_to_protobuf (host, ds, vl, statuses);
        if (msg == NULL)
                return (-1);
@@@ -725,8 -734,8 +737,8 @@@ static int riemann_config_node(oconfig_
        host->reference_count = 1;
        host->node = NULL;
        host->service = NULL;
 -    host->notifications = 1;
 -    host->check_thresholds = 0;
 +      host->notifications = 1;
 +      host->check_thresholds = 0;
        host->store_rates = 1;
        host->always_append_ds = 0;
        host->use_tcp = 0;
                        status = cf_util_get_string (child, &host->node);
                        if (status != 0)
                                break;
 -        } else if (strcasecmp ("Notifications", child->key) == 0) {
 -            status = cf_util_get_boolean(child, &host->notifications);
 -            if (status != 0)
 -                break;
 -        } else if (strcasecmp ("EventServicePrefix", child->key) == 0) {
 -            status = cf_util_get_string (child, &host->event_service_prefix);
 -            if (status != 0)
 -                break;
 -        } else if (strcasecmp ("CheckThresholds", child->key) == 0) {
 -            status = cf_util_get_boolean(child, &host->check_thresholds);
 -            if (status != 0)
 -                break;
 +              } else if (strcasecmp ("Notifications", child->key) == 0) {
 +                      status = cf_util_get_boolean(child, &host->notifications);
 +                      if (status != 0)
 +                              break;
++              } else if (strcasecmp ("EventServicePrefix", child->key) == 0) {
++                      status = cf_util_get_string (child, &host->event_service_prefix);
++                      if (status != 0)
++                              break;
 +              } else if (strcasecmp ("CheckThresholds", child->key) == 0) {
 +                      status = cf_util_get_boolean(child, &host->check_thresholds);
 +                      if (status != 0)
 +                              break;
                } else if (strcasecmp ("Port", child->key) == 0) {
                        status = cf_util_get_service (child, &host->service);
                        if (status != 0) {
@@@ -928,7 -941,7 +944,7 @@@ static int riemann_config(oconfig_item_
                                 child->key);
                }
        }
 -    return 0;
 +      return (0);
  } /* }}} int riemann_config */
  
  void module_register(void)