Set up a Collectd client
Published: 09-04-2013 | Author: Remy van Elst | Text only version of this article
❗ This post is over eight years old. It may no longer be up to date. Opinions may have changed.
Table of Contents
This tutorial shows you how to set up a collectd client for use with a collectd server. What is collectd? collectd gathers statistics about the system it is running on and stores this information. Those statistics can then be used to find current performance bottlenecks (i.e. performance analysis) and predict future system load (i.e. capacity planning). Or if you just want pretty graphs of your private server and are fed up with some homegrown solution you're at the right place, too ;).
You need a collectd server set up to fully use this tutorial, but I also have written a tutorial to do that.
Consider sponsoring me on Github. It means the world to me if you show your appreciation and you'll help pay the server costs.
You can also sponsor me by getting a Digital Ocean VPS. With this referral link you'll get $100 credit for 60 days.
The collectd client is much easier to set up than the server with web frontend. It only requires installation and configuring the client.
First install all the required packages:
sudo apt-get install collectd
Configuring Collectd to talk to our server
Open your favorite editor and edit the
/etc/collectd/collectd.conf file. Read
it, then remove it all and make sure it looks like the below config file:
## /etc/collectd/collectd.conf generated for vps3.sparklingclouds.nl by Ansible ## Config Type: CollectD Client Hostname $HOSTNAME FQDNLookup false Interval 30 ReadThreads 1 LoadPlugin syslog <Plugin syslog> LogLevel info </Plugin> LoadPlugin cpu LoadPlugin df LoadPlugin disk LoadPlugin entropy LoadPlugin interface LoadPlugin irq LoadPlugin load LoadPlugin memory LoadPlugin processes LoadPlugin rrdtool LoadPlugin swap LoadPlugin users LoadPlugin network ## Extra Plugins LoadPlugin nginx LoadPlugin iptables LoadPlugin uptime LoadPlugin dns LoadPlugin ping ## CollectD Servers <Plugin "network"> Server "$COLLECTD SERVER IP" "25826" Server "$COLLECTD SERVER IP" "25826" SecurityLevel None </Plugin> <Plugin rrdtool> DataDir "/var/lib/collectd/rrd" </Plugin> Include "/etc/collectd/filters.conf" Include "/etc/collectd/plugins.conf" Include "/etc/collectd/thresholds.conf"
The configuration file is relatively simple. Make sure to replace $VARIABLE$ by
the correct on for your server. You load plugins via
"LoadPlugin $name". The
network part is important, this configures our client to send its data to our
server. Replace $COLLECT SERVER IP with your collectd server IP.
*Make sure the file has a blank newline at the end. If it has not, collectd will fail to start/run correctly.
Configure collectd plugins
Now create the following file:
/etc/collectd/plugins.conf, it doesn't exist by
default. This will house the plugin config. Add the following content to it, but
make sure it matches your LoadPlugin settings above. If you don't have the ping
plugin, you also don't need the config for it.
## /etc/collectd/plugins.conf ## Static Plugins (every host has them) <Plugin swap> ReportByDevice false </Plugin> ## Dynamic Plugins <Plugin nginx> URL "http://127.0.0.1/nginx_status" </Plugin> <Plugin ntpd> Host "localhost" Port 123 ReverseLookups false </Plugin> <Plugin ping> Host "google.com" </Plugin> <Plugin sensors> SensorConfigFile "/etc/sensors3.conf" Sensor "it8712-isa-0290/temperature-temp1" Sensor "it8712-isa-0290/fanspeed-fan3" Sensor "it8712-isa-0290/voltage-in8" IgnoreSelected false </Plugin> <Plugin write_graphite> <Carbon> Host "$GRAPHITE_HOST$" Port "2003" Prefix "collectd" Postfix "collectd" StoreRates false AlwaysAppendDS false EscapeCharacter "_" </Carbon> </Plugin>
Collectd server is now set up in "client" mode. To test it we restart the service:
And then check the
/var/lib/collectd/rrd/ folder and you should see some files
and folders (rrd libraries). If not then your collectd is setup wrong, see
syslog for more info.
We also should see these files on the collectd server, in the
/var/lib/collectd/rrd folder. If you see them there, you have done it
Remember to add the IP to the collectd server firewall.
Now you have a fully working collectd client set up.Tags: collectd , monitoring , munin , rrd , rrdtool , statistics , tutorials