Using collectd with multiple networked instances

Collectd is a data collector deamon able to write data into round-robin database files (rrd). Data can be collected by enabling various plugins in the /etc/collectd/collectd.conf file. After changing this config file the deamon needs to be restarted by

sudo /etc/init.d/collectd restart

The data does not need to be stored and graphed on the host where it is collected. In fact, creating graphs from the rrd files takes quite some processing power we might not want to burden the possibly busy sytem being monitored with. For this use we can run collectd as data provider on the host being monitored and as data collector on another host which eventually creates graphs from it and optionally presents these graphs on a web page.

The data provider needs to have the network plugin enabled by adding these lines in collectd.conf:

#Start collectd network client
LoadPlugin "network"
<Plugin "network">
   Server "x.x.x.x"
</Plugin>

where x.x.x.x is the IP of the host collecting the data. This will result in sending a single muticast packet to that host every minute containing the data gathered by the other plugins of this collectd instance. This host should not have the rrd plugin enabled since it will not create rrd files. However it should have the data collecting plugins like table or reference to python based plugins configured.

On the data collector (the rrd and graphing end) we configure the listener like:

LoadPlugin "network"
<Plugin "network">
   Listen "x.x.x.x"
</Plugin>

where x.x.x.x is this hosts external IP adress (and the same address used by the sender) Also here the rrdtool plugin needs to be enabled which writes te received data to the rrd files (and optionally any collecting plugins if we need to collect data from this host too). The rrdtool is later also used to create nice graphs but we’ll leave that for now.

Where are rrd files stored in this setup?

When data is received over the network plugin both collectd settings in data provider and data collector determine the final location of the rrd file on the data collector server.

1. The base location is determined in the rrdtool plugin on the data collector by the statements in collectd.conf:

<Plugin rrdtool>
   DataDir "/var/lib/collectd/rrd"
</Plugin>

So we will find rrd files in /var/lib/collectd/rrd and beyond.

2. The beyond is determined by the hostname configured in collectd.conf of the data collector:

Hostname "localhost"

so expect data  /var/lib/collectd/rrd/localhost

3. Now the plugin + instance name comes into play. At the collecting device this is defined in the specific plugin definition in collectd:

LoadPlugin "table"
<Plugin table>
  <Table "/sys/class/thermal/thermal_zone0/temp">
    Instance rpi
    Separator " "
    <Result>
      Type gauge
      InstancePrefix "cpu_temp"
      ValuesFrom 0
    </Result>
  </Table>
</Plugin>

defining to put the rrd datafile into the table-rpi subdir.

Or in the case of a python module for dump1090

<Plugin python>
   ModulePath "/home/pi/dump-tools/collectd"
   LogTraces true
   Import "dump1090"
   <Module dump1090>
     <Instance rpi>
        URL "http://localhost/dump1090"
     </Instance>
   </Module>
</Plugin>

directing the various rrd datafiles of this to the dump1090-rpi directory

In general the rrd files will be written to:

/Datadir/Hostname/Plugin/Module name-Instance/*.rrd

Advertisements
This entry was posted in Tools. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s