Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

@joegoggins joegoggins commented Sep 9, 2014

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

This comment has been minimized.

Copy link

@JoyceBabu JoyceBabu commented Oct 4, 2014

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

@william20111

This comment has been minimized.

Copy link

@william20111 william20111 commented Dec 1, 2014

cracking little script. Saved me writing something similar :)

@bobbidigital

This comment has been minimized.

Copy link

@bobbidigital bobbidigital commented Dec 1, 2014

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

This comment has been minimized.

Copy link

@vstaikov vstaikov commented Dec 23, 2015

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

This comment has been minimized.

Copy link

@gowthamsadasivam gowthamsadasivam commented Feb 23, 2016

👍 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

This comment has been minimized.

Copy link

@nss373 nss373 commented Jun 23, 2016

rrdtool-prel should be rrdtool-perl

@mashayev

This comment has been minimized.

Copy link

@mashayev mashayev commented Dec 24, 2017

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

This comment has been minimized.

Copy link

@izghitu 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
You can’t perform that action at this time.