Skip to content

Instantly share code, notes, and snippets.

@tnolet
Last active December 5, 2018 02:48
Show Gist options
  • Star 29 You must be signed in to star a gist
  • Fork 22 You must be signed in to fork a gist
  • Save tnolet/7361441 to your computer and use it in GitHub Desktop.
Save tnolet/7361441 to your computer and use it in GitHub Desktop.
Install collectd 5.4 on Centos 6.x and make it spit out cool metrics. Copied from http://linuxdrops.com/install-collectd-statistics-collecter-on-centos-rhel-ubuntu-debian/ and tweaked for your and my pleasure. For all other cool options, check the provided link.
#!/bin/bash
# Perform installation as root
# Install prereqs
yum -y install libcurl libcurl-devel rrdtool rrdtool-devel rrdtool-prel libgcrypt-devel gcc make gcc-c++
# Get Collectd, untar it, make it and install
wget http://collectd.org/files/collectd-5.4.0.tar.gz
tar zxvf collectd-5.4.0.tar.gz
cd collectd-5.4.0
./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --libdir=/usr/lib --mandir=/usr/share/man --enable-all-plugins
make
make install
# Copy the default init.d script
cp /root/collectd-5.4.0/contrib/redhat/init.d-collectd /etc/init.d/collectd
# Set the correct permissions
chmod +x /etc/init.d/collectd
# Start the deamon
service collectd start
# NOTE! FQDN lookup is enabled by default. This might give you troubles if you'r running on Vagrant or some cloud server
# Check /var/log/messages for something like "Looking up "<yourhost>" failed. You have set the "FQDNLookup" option, but I cannot resolve my hostname...
# The fix is easy, just set "FQDNLookup false" in /etc/collectd.conf
@joegoggins
Copy link

This is a nice and handy script @tnolet, thanks for sharing!

A couple of things I changed, worth noting in my setup:

  • if you want the curl_json plugin to work, be sure to include libyajl and libyajl-devel
  • if you are compiling on a 64-bit system (likely), you'll want to change the ./configure call to be --libdir=/usr/lib64'
  • if you're using collectd with with Librato's collectd integration on a CentOS box, this route will work to get a 5.4.0 version running instead of the recommended pre-packaged 4.10 version http://support.metrics.librato.com/knowledgebase/articles/404267-collectd-faq

@JoyceBabu
Copy link

@joegoggins In CentOS the packages are yajl and yajl-devel (no need for the lib prefix).

@william20111
Copy link

cracking little script. Saved me writing something similar :)

@bobbidigital
Copy link

If you're on a new box and don't have the Perl tools installed you might need those too.

perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker

@vstaikov
Copy link

if you want the notify_email plugin to work, be sure to include libesmtp and libesmtp-devel and ./configure with --with-libesmtp=/usr/lib64

@gowthamsadasivam
Copy link

👍 This script is good, Just in case if anyone wants to compile collect for ALL THE PLUGINS with all dependencies, follow this link: http://giovannitorres.me/enabling-almost-all-collectd-plugins-on-centos-6.html (Contains list of all dependencies) :)

@nss373
Copy link

nss373 commented Jun 23, 2016

rrdtool-prel should be rrdtool-perl

@mashayev
Copy link

For some reason tcpconns metrics are not being sent at all.
I'm running CentOS6 and I used this command to install the collectd:
./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --libdir=/usr/lib64 --mandir=/usr/share/man --enable-all-plugins

[root@ip-10-152-219-179 ~]# collectd -h
Usage: collectd [OPTIONS]

Available options:
  General:
    -C <file>       Configuration file.
                    Default: /etc/collectd.conf
    -t              Test config and exit.
    -T              Test plugin read and exit.
    -P <file>       PID-file.
                    Default: /var/run/collectd.pid
    -f              Don't fork to the background.
    -h              Display help (this message)

Builtin defaults:
  Config file       /etc/collectd.conf
  PID file          /var/run/collectd.pid
  Plugin directory  /usr/lib64/collectd
  Data directory    /var/lib/collectd

collectd 5.7.2, http://collectd.org/
by Florian octo Forster <octo@collectd.org>
for contributions see `AUTHORS'

All metrics are being sent except of tcpconns, any suggestions?

@izghitu
Copy link

izghitu commented Nov 14, 2018

there's a typo in the first yum install command. Instead of rrdtool-perl you have rrdtool-prel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment