Code

Merge branch 'ff/statsd'
authorFlorian Forster <octo@collectd.org>
Wed, 7 Aug 2013 06:39:28 +0000 (08:39 +0200)
committerFlorian Forster <octo@collectd.org>
Wed, 7 Aug 2013 06:39:28 +0000 (08:39 +0200)
1  2 
configure.in
src/Makefile.am
src/collectd.conf.in
src/collectd.conf.pod

diff --combined configure.in
index 0838de8b914317c42cb35894f8bf6328b5dc41f4,3701d8ade781a62e988796d38bf9c81b3f1eeab4..dbdc0589a0fee67ca9566f43c07ecb40012c3ae2
  AM_CONDITIONAL(BUILD_WITH_LM_SENSORS, test "x$with_libsensors" = "xyes")
  # }}}
  
 +# --with-libsigrok {{{
 +with_libsigrok_cflags=""
 +with_libsigrok_ldflags=""
 +AC_ARG_WITH(libsigrok, [AS_HELP_STRING([--with-libsigrok@<:@=PREFIX@:>@], [Path to libsigrok.])],
 +[
 +      if test "x$withval" = "xno"
 +      then
 +              with_libsigrok="no"
 +      else
 +              with_libsigrok="yes"
 +              if test "x$withval" != "xyes"
 +              then
 +                      with_libsigrok_cflags="-I$withval/include"
 +                      with_libsigrok_ldflags="-L$withval/lib"
 +              fi
 +      fi
 +],[])
 +
 +# libsigrok has a glib dependency
 +if test "x$with_libsigrok" = "xyes"
 +then
 +      if test -z "m4_ifdef([AM_PATH_GLIB_2_0], [yes], [])"
 +      then
 +              with_libsigrok="no (glib not available)"
 +      else
 +              AM_PATH_GLIB_2_0([2.28.0],
 +                      [with_libsigrok_cflags="$with_libsigrok_cflags $GLIB_CFLAGS"; with_libsigrok_ldflags="$with_libsigrok_ldflags $GLIB_LIBS"])
 +      fi
 +fi
 +
 +# libsigrok headers
 +if test "x$with_libsigrok" = "xyes"
 +then
 +      SAVE_CPPFLAGS="$CPPFLAGS"
 +      CPPFLAGS="$CPPFLAGS $with_libsigrok_cflags"
 +
 +      AC_CHECK_HEADERS(libsigrok/libsigrok.h, [], [with_libsigrok="no (libsigrok/libsigrok.h not found)"])
 +
 +      CPPFLAGS="$SAVE_CPPFLAGS"
 +fi
 +
 +# libsigrok library
 +if test "x$with_libsigrok" = "xyes"
 +then
 +      SAVE_CPPFLAGS="$CPPFLAGS"
 +      SAVE_LDFLAGS="$LDFLAGS"
 +      CPPFLAGS="$CPPFLAGS $with_libsigrok_cflags"
 +      LDFLAGS="$LDFLAGS $with_libsigrok_ldflags"
 +
 +      AC_CHECK_LIB(sigrok, sr_init,
 +      [
 +              AC_DEFINE(HAVE_LIBSIGROK, 1, [Define to 1 if you have the sigrok library (-lsigrok).])
 +      ],
 +      [with_libsigrok="no (libsigrok not found)"])
 +
 +      CPPFLAGS="$SAVE_CPPFLAGS"
 +      LDFLAGS="$SAVE_LDFLAGS"
 +fi
 +if test "x$with_libsigrok" = "xyes"
 +then
 +      BUILD_WITH_LIBSIGROK_CFLAGS="$with_libsigrok_cflags"
 +      BUILD_WITH_LIBSIGROK_LDFLAGS="$with_libsigrok_ldflags"
 +      AC_SUBST(BUILD_WITH_LIBSIGROK_CFLAGS)
 +      AC_SUBST(BUILD_WITH_LIBSIGROK_LDFLAGS)
 +fi
 +AM_CONDITIONAL(BUILD_WITH_LIBSIGROK, test "x$with_libsigrok" = "xyes")
 +# }}}
 +
  # --with-libstatgrab {{{
  with_libstatgrab_cflags=""
  with_libstatgrab_ldflags=""
@@@ -5166,8 -5098,8 +5166,9 @@@ AC_PLUGIN([rrdcached],   [$librrd_rrdc_
  AC_PLUGIN([rrdtool],     [$with_librrd],       [RRDTool output plugin])
  AC_PLUGIN([sensors],     [$with_libsensors],   [lm_sensors statistics])
  AC_PLUGIN([serial],      [$plugin_serial],     [serial port traffic])
 +AC_PLUGIN([sigrok],      [$with_libsigrok],    [sigrok acquisition sources])
  AC_PLUGIN([snmp],        [$with_libnetsnmp],   [SNMP querying plugin])
+ AC_PLUGIN([statsd],      [yes],                [StatsD plugin])
  AC_PLUGIN([swap],        [$plugin_swap],       [Swap usage statistics])
  AC_PLUGIN([syslog],      [$have_syslog],       [Syslog logging plugin])
  AC_PLUGIN([table],       [yes],                [Parsing of tabular data])
@@@ -5400,7 -5332,6 +5401,7 @@@ Configuration
      librouteros . . . . . $with_librouteros
      librrd  . . . . . . . $with_librrd
      libsensors  . . . . . $with_libsensors
 +    libsigrok   . . . . . $with_libsigrok
      libstatgrab . . . . . $with_libstatgrab
      libtokyotyrant  . . . $with_libtokyotyrant
      libupsclient  . . . . $with_libupsclient
      rrdtool . . . . . . . $enable_rrdtool
      sensors . . . . . . . $enable_sensors
      serial  . . . . . . . $enable_serial
 +    sigrok  . . . . . . . $enable_sigrok
      snmp  . . . . . . . . $enable_snmp
+     statsd  . . . . . . . $enable_statsd
      swap  . . . . . . . . $enable_swap
      syslog  . . . . . . . $enable_syslog
      table . . . . . . . . $enable_table
diff --combined src/Makefile.am
index bdde5a3518d3703596898a6c9d212b3a602e8b77,9f16fd7cb7edb7486f7d4e06965a6b98bf389c31..f35b45a35c335cc6302df127f6f87a0891c5cacd
@@@ -1052,16 -1052,6 +1052,16 @@@ collectd_LDADD += "-dlopen" serial.l
  collectd_DEPENDENCIES += serial.la
  endif
  
 +if BUILD_PLUGIN_SIGROK
 +pkglib_LTLIBRARIES += sigrok.la
 +sigrok_la_SOURCES = sigrok.c
 +sigrok_la_CFLAGS = $(AM_CFLAGS) $(BUILD_WITH_LIBSIGROK_CFLAGS)
 +sigrok_la_LDFLAGS = -module -avoid-version $(BUILD_WITH_LIBSIGROK_LDFLAGS)
 +sigrok_la_LIBADD = -lsigrok
 +collectd_LDADD += "-dlopen" sigrok.la
 +collectd_DEPENDENCIES += sigrok.la
 +endif
 +
  if BUILD_PLUGIN_SNMP
  pkglib_LTLIBRARIES += snmp.la
  snmp_la_SOURCES = snmp.c
@@@ -1079,6 -1069,16 +1079,16 @@@ collectd_LDADD += "-dlopen" snmp.l
  collectd_DEPENDENCIES += snmp.la
  endif
  
+ if BUILD_PLUGIN_STATSD
+ pkglib_LTLIBRARIES += statsd.la
+ statsd_la_SOURCES = statsd.c \
+                     utils_latency.h utils_latency.c
+ statsd_la_LDFLAGS = -module -avoid-version
+ statsd_la_LIBADD = -lpthread
+ collectd_LDADD += "-dlopen" statsd.la
+ collectd_DEPENDENCIES += statsd.la
+ endif
  if BUILD_PLUGIN_SWAP
  pkglib_LTLIBRARIES += swap.la
  swap_la_SOURCES = swap.c
diff --combined src/collectd.conf.in
index e471a7d9c57f24a21a46a76b2d5edf5f26593bc1,c5ab3ce83a31ab4e063b3ff63fcaf6ccc1dea409..e8d4d28ef026c1c09546cdc0d143de52a19bbed5
  #ReadThreads  5
  #WriteThreads 5
  
 +# Limit the size of the write queue. Default is no limit. Setting up a limit is
 +# recommended for servers handling a high volume of traffic.
 +#WriteQueueLimitHigh 1000000
 +#WriteQueueLimitLow   800000
 +
  ##############################################################################
  # Logging                                                                    #
  #----------------------------------------------------------------------------#
  @LOAD_PLUGIN_RRDTOOL@LoadPlugin rrdtool
  #@BUILD_PLUGIN_SENSORS_TRUE@LoadPlugin sensors
  #@BUILD_PLUGIN_SERIAL_TRUE@LoadPlugin serial
 +#@BUILD_PLUGIN_SIGROK_TRUE@LoadPlugin sigrok
  #@BUILD_PLUGIN_SNMP_TRUE@LoadPlugin snmp
+ #@BUILD_PLUGIN_STATSD_TRUE@LoadPlugin statsd
  #@BUILD_PLUGIN_SWAP_TRUE@LoadPlugin swap
  #@BUILD_PLUGIN_TABLE_TRUE@LoadPlugin table
  #@BUILD_PLUGIN_TAIL_TRUE@LoadPlugin tail
  #     IgnoreSelected false
  #</Plugin>
  
 +#<Plugin sigrok>
 +#  LogLevel 3
 +#  <Device "AC Voltage">
 +#    Driver "fluke-dmm"
 +#    MinimumInterval 10
 +#    Conn "/dev/ttyUSB2"
 +#  </Device>
 +#  <Device "Sound Level">
 +#    Driver "cem-dt-885x"
 +#    Conn "/dev/ttyUSB1"
 +#  </Device>
 +#</Plugin>
 +
  #<Plugin snmp>
  #   <Data "powerplus_voltge_input">
  #       Type "voltage"
  #   </Host>
  #</Plugin>
  
+ #<Plugin statsd>
+ #  Host "::"
+ #  Port "8125"
+ #  DeleteCounters false
+ #  DeleteTimers   false
+ #  DeleteGauges   false
+ #  DeleteSets     false
+ #  TimerPercentile 90.0
+ #</Plugin>
  #<Plugin "swap">
  #     ReportByDevice false
  #     ReportBytes true
  #  <Node "example">
  #    Host "localhost"
  #    Port "2003"
 +#    Protocol "udp"
 +#    LogSendErrors true
  #    Prefix "collectd"
  #    Postfix "collectd"
  #    StoreRates true
diff --combined src/collectd.conf.pod
index 7b9a5598b77c65fae169edc835295c0d2801b15a,4a34fe5df3780ad76bb945be0a0ed1c926a883e7..1b73c417d9ebfc54211eefc252116d733a0b9c96
@@@ -1,5 -1,3 +1,5 @@@
 +=encoding UTF-8
 +
  =head1 NAME
  
  collectd.conf - Configuration for the system statistics collection daemon B<collectd>
@@@ -150,29 -148,15 +150,29 @@@ use statements like the following
  
    Include "/etc/collectd.d/*.conf"
  
 +Starting with version 5.3, this may also be a block in which further options
 +affecting the behavior of B<Include> may be specified. The following option is
 +currently allowed:
 +
 +  <Include "/etc/collectd.d">
 +    Filter "*.conf"
 +  </Include>
 +
 +=over 4
 +
 +=item B<Filter> I<pattern>
 +
  If the C<fnmatch> function is available on your system, a shell-like wildcard
  I<pattern> may be specified to filter which files to include. This may be used
  in combination with recursively including a directory to easily be able to
  arbitrarily mix configuration files and other documents (e.g. README files).
 -The following statement is similar to the example above but includes all files
 +The given example is similar to the first example above but includes all files
  matching C<*.conf> in any subdirectory of C</etc/collectd.d>:
  
    Include "/etc/collectd.d" "*.conf"
  
 +=back
 +
  If more than one files are included by a single B<Include> option, the files
  will be included in lexicographical order (as defined by the C<strcmp>
  function). Thus, you can e.E<nbsp>g. use numbered prefixes to specify the
@@@ -235,36 -219,6 +235,36 @@@ Number of threads to start for dispatch
  default value is B<5>, but you may want to increase this if you have more than
  five plugins that may take relatively long to write to.
  
 +=item B<WriteQueueLimitHigh> I<HighNum>
 +
 +=item B<WriteQueueLimitLow> I<LowNum>
 +
 +Metrics are read by the I<read threads> and then put into a queue to be handled
 +by the I<write threads>. If one of the I<write plugins> is slow (e.g. network
 +timeouts, I/O saturation of the disk) this queue will grow. In order to avoid
 +running into memory issues in such a case, you can limit the size of this
 +queue.
 +
 +By default, there is no limit and memory may grow indefinitely. This is most
 +likely not an issue for clients, i.e. instances that only handle the local
 +metrics. For servers it is recommended to set this to a non-zero value, though.
 +
 +You can set the limits using B<WriteQueueLimitHigh> and B<WriteQueueLimitLow>.
 +Each of them takes a numerical argument which is the number of metrics in the
 +queue. If there are I<HighNum> metrics in the queue, any new metrics I<will> be
 +dropped. If there are less than I<LowNum> metrics in the queue, all new metrics
 +I<will> be enqueued. If the number of metrics currently in the queue is between
 +I<LowNum> and I<HighNum>, the metric is dropped with a probability that is
 +proportional to the number of metrics in the queue (i.e. it increases linearly
 +until it reaches 100%.)
 +
 +If B<WriteQueueLimitHigh> is set to non-zero and B<WriteQueueLimitLow> is
 +unset, the latter will default to half of B<WriteQueueLimitHigh>.
 +
 +If you do not want to randomly drop values when the queue size is between
 +I<LowNum> and I<HighNum>, set If B<WriteQueueLimitHigh> and
 +B<WriteQueueLimitLow> to same value.
 +
  =item B<Hostname> I<Name>
  
  Sets the hostname that identifies a host. If you omit this setting, the
@@@ -1557,19 -1511,14 +1557,19 @@@ Enable this option if inodes are a scar
  many small files are stored on the disk. This is a usual scenario for mail
  transfer agents and web caches.
  
 -=item B<ReportPercentage> B<false>|B<true>
 +=item B<ValuesAbsolute> B<true>|B<false>
  
 -Enables or disables reporting of disk space and inodes as a percentage.
 -Defaults to B<false>.
 +Enables or disables reporting of free, used and used disk space in 1K-blocks. 
 +Defaults to true.
  
 -This is useful for deploying I<collectd> on the cloud, where machines with
 -different disk size may exist. Then it is more practical to configure
 -thresholds based on relative disk size.
 +=item B<ValuesPercentage> B<true>|B<false>
 +
 +Enables or disables reporting of free, used and used disk space in percentage.
 +Defaults to false.
 +
 +This is useful for deploying collectd on the cloud, where machines with
 +different disk size may exist. Then it is more practical to configure thresholds
 +based on relative disk size.
  
  =back
  
@@@ -5148,80 -5097,61 +5148,129 @@@ and all other sensors are collected
  
  =back
  
 +=head2 Plugin C<sigrok>
 +
 +The I<sigrok plugin> uses I<libsigrok> to retrieve measurements from any device
 +supported by the L<sigrok|http://sigrok.org/> project.
 +
 +B<Synopsis>
 +
 + <Plugin sigrok>
 +   LogLevel 3
 +   <Device "AC Voltage">
 +      Driver "fluke-dmm"
 +      MinimumInterval 10
 +      Conn "/dev/ttyUSB2"
 +   </Device>
 +   <Device "Sound Level">
 +      Driver "cem-dt-885x"
 +      Conn "/dev/ttyUSB1"
 +   </Device>
 + </Plugin>
 +
 +=over 4
 +
 +=item B<LogLevel> B<0-5>
 +
 +The I<sigrok> logging level to pass on to the I<collectd> log, as a number
 +between B<0> and B<5> (inclusive). These levels correspond to C<None>,
 +C<Errors>, C<Warnings>, C<Informational>, C<Debug >and C<Spew>, respectively.
 +The default is B<2> (C<Warnings>). The I<sigrok> log messages, regardless of
 +their level, are always submitted to I<collectd> at its INFO log level.
 +
 +=item E<lt>B<Device> I<Name>E<gt>
 +
 +A sigrok-supported device, uniquely identified by this section's options. The
 +I<Name> is passed to I<collectd> as the I<plugin instance>.
 +
 +=item B<Driver> I<DriverName>
 +
 +The sigrok driver to use for this device.
 +
 +=item B<Conn> I<ConnectionSpec>
 +
 +If the device cannot be auto-discovered, or more than one might be discovered
 +by the driver, I<ConnectionSpec> specifies the connection string to the device.
 +It can be of the form of a device path (e.g.E<nbsp>C</dev/ttyUSB2>), or, in
 +case of a non-serial USB-connected device, the USB I<VendorID>B<.>I<ProductID>
 +separated by a period (e.g.E<nbsp>C<0403.6001>). A USB device can also be
 +specified as I<Bus>B<.>I<Address> (e.g.E<nbsp>C<1.41>).
 +
 +=item B<SerialComm> I<SerialSpec>
 +
 +For serial devices with non-standard port settings, this option can be used
 +to specify them in a form understood by I<sigrok>, e.g.E<nbsp>C<9600/8n1>.
 +This should not be necessary; drivers know how to communicate with devices they
 +support.
 +
 +=item B<MinimumInterval> I<Seconds>
 +
 +Specifies the minimum time between measurement dispatches to I<collectd>, in
 +seconds. Since some I<sigrok> supported devices can acquire measurements many
 +times per second, it may be necessary to throttle these. For example, the
 +I<RRD plugin> cannot process writes more than once per second.
 +
 +The default B<MinimumInterval> is B<0>, meaning measurements received from the
 +device are always dispatched to I<collectd>. When throttled, unused
 +measurements are discarded.
 +
 +=back
 +
  =head2 Plugin C<snmp>
  
  Since the configuration of the C<snmp plugin> is a little more complicated than
  other plugins, its documentation has been moved to an own manpage,
  L<collectd-snmp(5)>. Please see there for details.
  
+ =head2 Plugin C<statsd>
+ The I<statsd plugin> listens to a UDP socket, reads "events" in the statsd
+ protocol and dispatches rates or other aggregates of these numbers
+ periodically.
+ The plugin implements the I<Counter>, I<Timer>, I<Gauge> and I<Set> types which
+ are dispatched as the I<collectd> types C<derive>, C<latency>, C<gauge> and
+ C<objects> respectively.
+ The following configuration options are valid:
+ =over 4
+ =item B<Host> I<Host>
+ Bind to the hostname / address I<Host>. By default, the plugin will bind to the
+ "any" address, i.e. accept packets sent to any of the hosts addresses.
+ =item B<Port> I<Port>
+ UDP port to listen to. This can be either a service name or a port number.
+ Defaults to C<8125>.
+ =item B<DeleteCounters> B<false>|B<true>
+ =item B<DeleteTimers> B<false>|B<true>
+ =item B<DeleteGauges> B<false>|B<true>
+ =item B<DeleteSets> B<false>|B<true>
+ These options control what happens if metrics are not updated in an interval.
+ If set to B<False>, the default, metrics are dispatched unchanged, i.e. the
+ rate of counters and size of sets will be zero, timers report C<NaN> and gauges
+ are unchanged. If set to B<True>, the such metrics are not dispatched and
+ removed from the internal cache.
+ =item B<TimerPercentile> I<Percent>
+ Calculate and dispatch the configured percentile, i.e. compute the latency, so
+ that I<Percent> of all reported timers are smaller than or equal to the
+ computed latency. This is useful for cutting off the long tail latency, as it's
+ often done in I<Service Level Agreements> (SLAs).
+ If not specified, no percentile is calculated / dispatched.
+ =back
  =head2 Plugin C<swap>
  
  The I<Swap plugin> collects information about used and available swap space. On
@@@ -5815,33 -5745,7 +5864,33 @@@ Take the UUID from the given file (defa
  
  =head2 Plugin C<varnish>
  
 -The Varnish plugin collects information about Varnish, an HTTP accelerator.
 +The I<varnish plugin> collects information about Varnish, an HTTP accelerator.
 +
 +Synopsis:
 +
 + <Plugin "varnish">
 +   <Instance "example">
 +     CollectCache       true
 +     CollectConnections true
 +     CollectBackend     true
 +     CollectSHM         true
 +     CollectESI         false
 +     CollectFetch       false
 +     CollectHCB         false
 +     CollectSMA         false
 +     CollectSMS         false
 +     CollectSM          false
 +     CollectTotals      false
 +     CollectWorkers     false
 +   </Instance>
 + </Plugin>
 +
 +The configuration consists of one or more E<lt>B<Instance>E<nbsp>I<Name>E<gt>
 +blocks. I<Name> is the parameter passed to "varnishd -n". If left empty, it
 +will collectd statistics from the default "varnishd" instance (this should work
 +fine in most cases).
 +
 +Inside each E<lt>B<Instance>E<gt> blocks, the following options are recognized:
  
  =over 4
  
@@@ -5982,9 -5886,9 +6031,9 @@@ iptables to feed data for the guest IP
  
  The C<write_graphite> plugin writes data to I<Graphite>, an open-source metrics
  storage and graphing project. The plugin connects to I<Carbon>, the data layer
 -of I<Graphite>, and sends data via the "line based" protocol (per default using
 -portE<nbsp>2003). The data will be sent in blocks of at most 1428 bytes to
 -minimize the number of network packets.
 +of I<Graphite>, via I<TCP> or I<UDP> and sends data via the "line based"
 +protocol (per default using portE<nbsp>2003). The data will be sent in blocks
 +of at most 1428 bytes to minimize the number of network packets.
  
  Synopsis:
  
     <Node "example">
       Host "localhost"
       Port "2003"
 +     Protocol "udp"
 +     LogSendErrors true
       Prefix "collectd"
     </Node>
   </Plugin>
@@@ -6011,17 -5913,6 +6060,17 @@@ Hostname or address to connect to. Defa
  
  Service name or port number to connect to. Defaults to C<2003>.
  
 +=item B<Protocol> I<String>
 +
 +Protocol to use when connecting to I<Graphite>. Defaults to C<tcp>.
 +
 +=item B<LogSendErrors> B<false>|B<true>
 +
 +If set to B<true> (the default), logs errors when sending data to I<Graphite>.
 +If set to B<false>, it will not log the errors. This is especially useful when
 +using Protocol UDP since many times we want to use the "fire-and-forget"
 +approach and logging errors fills syslog with unneeded messages.
 +
  =item B<Prefix> I<String>
  
  When set, I<String> is added in front of the host name. Dots and whitespace are