Building an RPM package for collectd

Hello Squirrels,

We figured we would save folks some time and put together a quick blog post with the steps needed to create an RPM package for collectd for CentOS 6.x out of the latest sources.

This has been partly based on a few sources we found online so please look at the bottom of this post if you are interested in finding out more about those.

For those who are not familiar with it, collectd, is a daemon for collecting system statistics (cpu, memory etc). The highlights are that it’s built in plain C and as such it’s really fast and lightweight and it also comes with a ton of plugins. It can also be used as a building block for building Grafana dashboards – but more on this later 🙂

1. Get the latest source code – in this example we are going to build an RPM out of collectd 5.5.2.

cd /tmp
wget -c http://collectd.org/files/collectd-5.5.2.tar.bz2

2. Untar and enter the source directory

tar -xf collectd-5.5.2.tar.bz2
cd collectd-5.5.2

3. Install EPEL, GCC and the RPM build tools:

yum install -y rpm-build yum-utils rpmdevtools epel-release gcc

4. Create the /root/rpmbuild/SOURCES/ since rpmbuild expects it and copy the source code there

mkdir -pv /root/rpmbuild/SOURCES/
cp /tmp/collectd*.bz2 /root/rpmbuild/SOURCES/

5. Change the version number to 5.5.2 (the spec file in my case was for 5.5.1)

sed -i -- 's/5.5.1/5.5.2/g' /tmp/collectd-5.5.2/contrib/redhat/collectd.spec

6. Get any remaining dependencies with yum:

yum-builddep -y /tmp/collectd-5.5.2/contrib/redhat/collectd.spec

7. Build the RPM:

rpmbuild -bb /tmp/collectd-5.5.2/contrib/redhat/collectd.spec

8. The packages are now under /root/rpmbuild/RPMS/x86_64. To install locally do this:

cd /root/rpmbuild/RPMS/x86_64
yum localinstall collectd-* libcollectdclient-*

9. Set collectd to chkconfig to ‘on’ so that it can start on boot automatically:

chkconfig collectd on

10. Before starting the collectd service make sure that you change and uncomment the “#Hostname” line in the /etc/collectd.conf configuration file

11. Finally start collectd:

/etc/init.d/collectd start

Sources:

One thought on “Building an RPM package for collectd”

Leave a Reply

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