jhmartin / collectd-sensu

Output plugin for Collectd to send data to a local Sensu client.
Apache License 2.0
7 stars 3 forks source link

Introduction

Code Health collectd-sensu is a collectd plugin that publishes collectd values to Sensu using the Event Data API to Sensu Client.

Collectd-librato was largely influenced by collectd-librato.

Requirements

Installation

If you have a /etc/collectd5.conf file it should probably contain something like the following:

BaseDir     "/var/lib/collectd5"
PIDFile     "/var/run/collectd5.pid"
TypesDB     "/usr/share/collectd5/types.db"
LoadPlugin syslog
LoadPlugin cpu
LoadPlugin interface
LoadPlugin load
LoadPlugin memory
<LoadPlugin "python">
  Globals true
</LoadPlugin>
<Plugin "python">
  ModulePath "/usr/lib64/collectd/python"
  Import "collectd_sensu"
  Interactive false
</Plugin>

The plugin will connect to the Sensu client on localhost tcp port 3030.

From Source

Installation from source is provided by the Makefile included in the project.

Simply clone this repository and run make install as root:

$ git clone git://github.com/jhmartin/collectd-sensu.git
$ cd collectd-sensu
$ sudo make install
Installed collected-sensu plugin, add this
to your collectd configuration to load this plugin:

    <LoadPlugin "python">
        Globals true
    </LoadPlugin>

    <Plugin "python">
        # collectd-sensu.py is at /opt/collectd-sensu-0.0.1/lib/collectd-sensu.py
        ModulePath "/opt/collectd-sensu-0.0.1/lib"
        Interactive false

        Import "collectd-sensu"
    </Plugin>

The output above includes a sample configuration file for the plugin. Simply add this to /etc/collectd.conf or drop in the configuration directory as /etc/collectd.d/sensu.conf and restart collectd. See the next section for an explanation of the plugin's configuration variables.

Configuration

The plugin does not require configuration and should work out-of-box.

To control the frequency (resolution) of metrics sent by collectd to Sensu, you must update the collectd option Interval specified in the global collectd.conf file to the desired resolution in seconds.

The following parameters are available:

The following is an example Collectd configuration for this plugin:

<LoadPlugin "python">
    Globals true
</LoadPlugin>

<Plugin "python">
    # collectd-sensu.py is at /opt/collectd-sensu-0.0.1/lib/collectd-sensu.py
    ModulePath "/opt/collectd-sensu-0.0.1/lib"

    Import "collectd_sensu"
    Interactive false

    <Module "collectd_sensu">
        Port "3031"
    </Module>
</Plugin>

Supported Metrics

Collectd-Sensu currently supports the following collectd metric types:

Other metric types are currently ignored.

Operational Notes

This plugin uses a best-effort attempt to deliver metrics to Sensu Metrics. If a flush fails to POST metrics to Sensu the flush will not currently be retried, but instead dropped. In most cases this should not happen, but if it does the plugin will continue to flush metrics after the failure. So in the worst case there may appear a short gap in your metric graphs.

The plugin needs to parse Collectd type files. If there was an error parsing a specific type (look for log messages at Collectd startup time), the plugin will fail to write values for this type. It will simply skip over them and move on to the next value. It will write a log message every time this happens so you can correct the problem.

The plugin needs to perform redundant parsing of the type files because the Collectd Python API does not provide an interface to the types information (unlike the Perl and Java plugin APIs). Hopefully this will be addressed in a future version of Collectd.

Contributing

If you would like to contribute a fix or feature to this plugin please feel free to fork this repo, make your change and submit a pull request!