Custom Collectd plugins for Linux/Ubuntu

About Collectd

Collectd is an application which collects system/application metrics periodically and provides ways to store these values in variety of ways like time series databases. One of the most popular usecase is collecting metrics from Linux machines and send data to time series databases like graphite, influxdb ..

Plugins for collectd

In this article i will explain how to write custom collectd plugins. We write a plugin for gathering the metric “number of openfiles” in the Linux system”.

Step 1. Create the Plugin

We create a script which collect the openfiles count from the file /proc/sys/fs/file-nr

 

Step 2 : Install the new Collectd custom plugin to Collectd

Copy the script we created from Step 1 , to the collectd plugin folder. On Centos its at /usr/lib64/collectd/

Step 3 : Configure new Plugin

Now we will link the new plugin into collectd.conf file.

NB: You need to create the user “collectd” if it doesnt exist

Step4 : Restart Collectd Service

On Centos7, use

On Centos6 use,

Watch the Collectd logs for any errors. On Linux machines, using

On Ubuntu, use

It should show the new plugin details in the logs and collected metrics will be send to the destination configured, network, graphite..If any errors, it will show up un the logs. Please let me know incase you face any issue, always glad to assist.

 

Leave a Reply

Your email address will not be published. Required fields are marked *