There are no shortage of tutorials on setting up collectd as an agent on a machine. However, I have found little help in the way of describing how to setup a centralized collectd collection server that aggregates statistics from multiple clients and sends them to Graphite. This post will help you do just that. It focuses on Ubuntu, but the instructions are universally applicable.
First, let’s setup the central collectd server. This could be on the same machine as your Graphite server, but on large production environments, it is not recommended.
The Ubuntu collectd repositories do not contain the necessary write_graphite plugin, so you must download and install collectd manually. Download the source from the website at: http://collectd.org/download.shtml
tar jxf collectd-version.tar.bz2
make all install
Once collectd is installed, modify the /opt/etc/collectd.conf file to contain the following:
Listen “*” “12345”
Make adjustments for your network as needed.
Now, we are going install the collectd agent on the client and then tell it to send the metrics to the collectd server (not Graphite).
The clients do not need the write_graphite plugin and can use the older version of Collectd that ships with the repositories. On each client, run:
sudo apt-get install collectd collectd-utils
Then, cd into /etc/collectd. Backup the collectd.conf file as collectd.conf.bkp or similar and then create a new collectd.conf file. In it, enable the plugins you want and also add the following:
Server “collectd.domain.com” “12345”
Be sure to configure the network plugin with your collectd server information.
Now, if you log into Graphite, you should see that your clients are sending all of their statistics to the collectd server which is then sending them to Graphite.