Code

Merge pull request #613 from rubenk/master
authorPierre-Yves Ritschard <pyr@spootnik.org>
Sat, 26 Jul 2014 17:03:06 +0000 (19:03 +0200)
committerPierre-Yves Ritschard <pyr@spootnik.org>
Sat, 26 Jul 2014 17:03:06 +0000 (19:03 +0200)
Fix a few typos

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

diff --combined src/collectd.conf.pod
index 8d05e9a07101689c7987571441a32e4a765a6be3,f1df4b9af5f5a0697e685c4912dd5185107f0492..39a657d29eb4b7a8e12245e7daf828ef357a9fc5
@@@ -506,8 -506,6 +506,8 @@@ possibly filtering or messages
       Exchange "amq.fanout"
   #   ExchangeType "fanout"
   #   Queue "queue_name"
 + #   QueueDurable false
 + #   QueueAutoDelete true
   #   RoutingKey "collectd.#"
     </Subscribe>
   </Plugin>
@@@ -560,23 -558,9 +560,23 @@@ be bound to this exchange
  
  =item B<Queue> I<Queue> (Subscribe only)
  
 -Configures the I<queue> name to subscribe to. If no queue name was configures
 +Configures the I<queue> name to subscribe to. If no queue name was configured
  explicitly, a unique queue name will be created by the broker.
  
 +=item B<QueueDurable> B<true>|B<false> (Subscribe only)
 +
 +Defines if the I<queue> subscribed to is durable (saved to persistent storage)
 +or transient (will disappear if the AMQP broker is restarted). Defaults to
 +"false".
 +
 +This option should be used in conjunction with the I<Persistent> option on the
 +publish side.
 +
 +=item B<QueueAutoDelete> B<true>|B<false> (Subscribe only)
 +
 +Defines if the I<queue> subscribed to will be deleted once the last consumer
 +unsubscribes. Defaults to "true".
 +
  =item B<RoutingKey> I<Key>
  
  In I<Publish> blocks, this configures the routing key to set on all outgoing
@@@ -1704,20 -1688,6 +1704,20 @@@ collected. If at least one B<Disk> opti
  set to B<false>, B<only> matching disks will be collected. If B<IgnoreSelected>
  is set to B<true>, all disks are collected B<except> the ones matched.
  
 +=item B<UseBSDName> B<true>|B<false>
 +
 +Whether to use the device's "BSD Name", on MacE<nbsp>OSE<nbsp>X, instead of the
 +default major/minor numbers. Requires collectd to be built with Apple's
 +IOKitLib support.
 +
 +=item B<UdevNameAttr> I<Attribute>
 +
 +Attempt to override disk instance name with the value of a specified udev
 +attribute when built with B<libudev>.  If the attribute is not defined for the
 +given device, the default name is used. Example:
 +
 +  UdevNameAttr "DM_NAME"
 +
  =back
  
  =head2 Plugin C<dns>
@@@ -2321,34 -2291,6 +2321,34 @@@ B<Note>: There is no need to notify th
  log file (e.E<nbsp>g. when rotating the logs). The plugin reopens the file
  for each line it writes.
  
 +=head2 Plugin C<log_logstash>
 +
 +The I<log logstash plugin> behaves like the logfile plugin but formats
 +messages as JSON events for logstash to parse and input.
 +
 +=over 4
 +
 +=item B<LogLevel> B<debug|info|notice|warning|err>
 +
 +Sets the log-level. If, for example, set to B<notice>, then all events with
 +severity B<notice>, B<warning>, or B<err> will be written to the logfile.
 +
 +Please note that B<debug> is only available if collectd has been compiled with
 +debugging support.
 +
 +=item B<File> I<File>
 +
 +Sets the file to write log messages to. The special strings B<stdout> and
 +B<stderr> can be used to write to the standard output and standard error
 +channels, respectively. This, of course, only makes much sense when I<collectd>
 +is running in foreground- or non-daemon-mode.
 +
 +=back
 +
 +B<Note>: There is no need to notify the daemon after moving or removing the
 +log file (e.E<nbsp>g. when rotating the logs). The plugin reopens the file
 +for each line it writes.
 +
  =head2 Plugin C<lpar>
  
  The I<LPAR plugin> reads CPU statistics of I<Logical Partitions>, a
@@@ -2540,7 -2482,7 +2540,7 @@@ The following options are valid inside 
  
  =item B<ShowCPU> B<true>|B<false>
  
- If enabled (the default) a sum of the CPU usage accross all cores is reported.
+ If enabled (the default) a sum of the CPU usage across all cores is reported.
  
  =item B<ShowCPUCores> B<true>|B<false>
  
@@@ -6424,114 -6366,9 +6424,114 @@@ number
  
  =back
  
 +=head2 Plugin C<write_kafka>
 +
 +The I<write_kafka plugin> will send values to a I<Kafka> topic, a distributed
 +queue.
 +Synopsis:
 +
 + <Plugin "write_kafka">
 +   Property "metadata.broker.list" "broker1:9092,broker2:9092"
 +   <Topic "collectd">
 +     Format JSON
 +   </Topic>
 + </Plugin>
 +
 +The following options are understood by the I<write_kafka plugin>:
 +
 +=over 4
 +
 +=item E<lt>B<Topic> I<Name>E<gt>
 +
 +The plugin's configuration consists of one or more B<Topic> blocks. Each block
 +is given a unique I<Name> and specifies one kafka producer.
 +Inside the B<Topic> block, the following per-topic options are
 +understood:
 +
 +=over 4
 +
 +=item B<Property> I<String> I<String>
 +
 +Configure the named property for the current topic. Properties are
 +forwarded to the kafka producer library B<librdkafka>.
 +
 +=item B<Key> I<String>
 +
 +Use the specified string as a partioning key for the topic. Kafka breaks
 +topic into partitions and guarantees that for a given topology, the same
 +consumer will be used for a specific key. The special (case insensitive)
 +string B<Random> can be used to specify that an arbitrary partition should
 +be used.
 +
 +=item B<Format> B<Command>|B<JSON>|B<Graphite>
 +
 +Selects the format in which messages are sent to the broker. If set to
 +B<Command> (the default), values are sent as C<PUTVAL> commands which are
 +identical to the syntax used by the I<Exec> and I<UnixSock plugins>.
 +
 +If set to B<JSON>, the values are encoded in the I<JavaScript Object Notation>,
 +an easy and straight forward exchange format.
 +
 +If set to B<Graphite>, values are encoded in the I<Graphite> format, which is
 +"<metric> <value> <timestamp>\n".
 +
 +=item B<StoreRates> B<true>|B<false>
 +
 +Determines whether or not C<COUNTER>, C<DERIVE> and C<ABSOLUTE> data sources
 +are converted to a I<rate> (i.e. a C<GAUGE> value). If set to B<false> (the
 +default), no conversion is performed. Otherwise the conversion is performed
 +using the internal value cache.
 +
 +Please note that currently this option is only used if the B<Format> option has
 +been set to B<JSON>.
 +
 +=item B<GraphitePrefix> (B<Format>=I<Graphite> only)
 +
 +A prefix can be added in the metric name when outputting in the I<Graphite> format.
 +It's added before the I<Host> name.
 +Metric name will be "<prefix><host><postfix><plugin><type><name>"
 +
 +=item B<GraphitePostfix> (B<Format>=I<Graphite> only)
 +
 +A postfix can be added in the metric name when outputting in the I<Graphite> format.
 +It's added after the I<Host> name.
 +Metric name will be "<prefix><host><postfix><plugin><type><name>"
 +
 +=item B<GraphiteEscapeChar> (B<Format>=I<Graphite> only)
 +
 +Specify a character to replace dots (.) in the host part of the metric name.
 +In I<Graphite> metric name, dots are used as separators between different
 +metric parts (host, plugin, type).
 +Default is "_" (I<Underscore>).
 +
 +=item B<GraphiteSeparateInstances> B<false>|B<true>
 +
 +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<StoreRates> B<true>|B<false>
 +
 +If set to B<true> (the default), convert counter values to rates. If set to
 +B<false> counter values are stored as is, i.e. as an increasing integer number.
 +
 +This will be reflected in the C<ds_type> tag: If B<StoreRates> is enabled,
 +converted values will have "rate" appended to the data source type, e.g.
 +C<ds_type:derive:rate>.
 +
 +=back
 +
 +=item B<Property> I<String> I<String>
 +
 +Configure the kafka producer through properties, you almost always will
 +want to set B<metadata.broker.list> to your Kafka broker list.
 +
 +=back
 +
  =head2 Plugin C<write_riemann>
  
- The I<write_riemann plugin> will send values to I<Riemann>, a powerfull stream
+ The I<write_riemann plugin> will send values to I<Riemann>, a powerful stream
  aggregation and monitoring system. The plugin sends I<Protobuf> encoded data to
  I<Riemann> using UDP packets.
  
@@@ -6601,17 -6438,6 +6601,17 @@@ interval is multiplied to set the TTL. 
  know exactly what you're doing, you should only increase this setting from its
  default value.
  
 +=item B<Notifications> B<false>|B<true>
 +
 +If set to B<true>, create riemann events for notifications. This is B<true>
 +by default. When processing thresholds from write_riemann, it might prove
 +useful to avoid getting notification events.
 +
 +=item B<CheckThresholds> B<false>|B<true>
 +
 +If set to B<true>, attach state to events based on thresholds defined
 +in the B<Threshold> plugin. Defaults to B<false>.
 +
  =back
  
  =item B<Tag> I<String>
diff --combined src/java.c
index ee503550bda2840a1fa6bdd465e2a11abca68642,aa47f804b36785d2c5398909be56a003f57c9c9f..e4b10bebb4f543bb74d3772f0894247c96c38f30
@@@ -906,7 -906,7 +906,7 @@@ static jobject ctoj_notification (JNIEn
  #undef SET_STRING
  
    /* Set the `time' member. Java stores time in milliseconds. */
 -  status = ctoj_long (jvm_env, ((jlong) n->time) * ((jlong) 1000),
 +  status = ctoj_long (jvm_env, (jlong) CDTIME_T_TO_MS (n->time),
        c_notification, o_notification, "setTime");
    if (status != 0)
    {
@@@ -1306,7 -1306,7 +1306,7 @@@ static int jtoc_notification (JNIEnv *j
      return (-1);
    }
    /* Java measures time in milliseconds. */
 -  n->time = (time_t) (tmp_long / ((jlong) 1000));
 +  n->time = MS_TO_CDTIME_T(tmp_long);
  
    status = jtoc_int (jvm_env, &tmp_int,
        class_ptr, object_ptr, "getSeverity");
@@@ -2436,7 -2436,7 +2436,7 @@@ static void cjni_callback_info_destroy 
  
    cbi = (cjni_callback_info_t *) arg;
  
-   /* This condition can occurr when shutting down. */
+   /* This condition can occur when shutting down. */
    if (jvm == NULL)
    {
      sfree (cbi);
diff --combined src/write_riemann.c
index 9d2b53982d0d328c4a7f113625be72f6adb8a733,69fdaad34b17c03dd1844cfd6312f5bdbe21e01f..780bccbefb2c794cf59f33cfc6f0fe3717d68496
  #define RIEMANN_PORT          "5555"
  #define RIEMANN_TTL_FACTOR      2.0
  
 +int write_riemann_threshold_check(const data_set_t *, const value_list_t *, int *);
 +
  struct riemann_host {
        char                    *name;
  #define F_CONNECT              0x01
        uint8_t                  flags;
        pthread_mutex_t          lock;
 +    _Bool            notifications;
 +    _Bool            check_thresholds;
        _Bool                    store_rates;
        _Bool                    always_append_ds;
        char                    *node;
@@@ -154,7 -150,7 +154,7 @@@ static int riemann_connect(struct riema
                }
  
                host->flags |= F_CONNECT;
-               DEBUG("write_riemann plugin: got a succesful connection for: %s:%s",
+               DEBUG("write_riemann plugin: got a successful connection for: %s:%s",
                                node, service);
                break;
        }
@@@ -457,8 -453,7 +457,8 @@@ static Msg *riemann_notification_to_pro
  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)
 +                                       gauge_t const *rates,
 +                                       int status)
  {
        Event *event;
        char name_buffer[5 * DATA_MAX_NAME_LEN];
        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;
 +        }
 +    }
 +
        ttl = CDTIME_T_TO_DOUBLE (vl->interval) * host->ttl_factor;
        event->ttl = (float) ttl;
        event->has_ttl = 1;
  } /* }}} Event *riemann_value_to_protobuf */
  
  static Msg *riemann_value_list_to_protobuf (struct riemann_host const *host, /* {{{ */
 -              data_set_t const *ds,
 -              value_list_t const *vl)
 +                                          data_set_t const *ds,
 +                                          value_list_t const *vl,
 +                                          int *statuses)
  {
        Msg *msg;
        size_t i;
        for (i = 0; i < msg->n_events; i++)
        {
                msg->events[i] = riemann_value_to_protobuf (host, ds, vl,
 -                              (int) i, rates);
 +                                                          (int) i, rates, statuses[i]);
                if (msg->events[i] == NULL)
                {
                        riemann_msg_protobuf_free (msg);
@@@ -640,9 -617,6 +640,9 @@@ static int riemann_notification(const n
        struct riemann_host     *host = ud->data;
        Msg                     *msg;
  
 +    if (!host->notifications)
 +        return 0;
 +
        msg = riemann_notification_to_protobuf (host, n);
        if (msg == NULL)
                return (-1);
@@@ -661,13 -635,10 +661,13 @@@ static int riemann_write(const data_set
              user_data_t *ud)
  {
        int                      status;
 +      int                      statuses[vl->values_len];
        struct riemann_host     *host = ud->data;
        Msg                     *msg;
  
 -      msg = riemann_value_list_to_protobuf (host, ds, vl);
 +    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);
  
@@@ -720,8 -691,6 +720,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->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 ("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) {
@@@ -923,7 -884,7 +923,7 @@@ static int riemann_config(oconfig_item_
                                 child->key);
                }
        }
 -      return (0);
 +    return 0;
  } /* }}} int riemann_config */
  
  void module_register(void)