Skip to content

Instantly share code, notes, and snippets.

@jehadassaf
Forked from tnolet/gist:7361441
Last active July 25, 2017 07:02
Show Gist options
  • Save jehadassaf/631c8b9312dd5b0edb1c2f724c5a935d to your computer and use it in GitHub Desktop.
Save jehadassaf/631c8b9312dd5b0edb1c2f724c5a935d to your computer and use it in GitHub Desktop.
Install latest collectd on RHEL 6.x
Hostname "friendly_name@hostname_with_underscores"
FQDNLookup false
Interval "10"
Timeout 2
ReadThreads 5
LoadPlugin cpu
LoadPlugin df
LoadPlugin load
LoadPlugin memory
LoadPlugin disk
LoadPlugin interface
LoadPlugin uptime
LoadPlugin swap
LoadPlugin write_graphite
LoadPlugin processes
LoadPlugin aggregation
LoadPlugin match_regex
<Plugin df>
# expose host's mounts into container using -v /:/host:ro (location inside container does not matter much)
# ignore rootfs; else, the root file-system would appear twice, causing
# one of the updates to fail and spam the log
FSType rootfs
# ignore the usual virtual / temporary file-systems
FSType sysfs
FSType proc
FSType devtmpfs
FSType devpts
FSType tmpfs
FSType fusectl
FSType cgroup
FSType overlay
FSType debugfs
FSType pstore
FSType securityfs
FSType hugetlbfs
FSType squashfs
FSType mqueue
MountPoint "/etc/resolv.conf"
MountPoint "/etc/hostname"
MountPoint "/etc/hosts"
IgnoreSelected true
ReportByDevice false
ReportInodes true
ValuesAbsolute true
ValuesPercentage true
ReportInodes true
</Plugin>
<Plugin "disk">
Disk "/^[hs]d[a-z]/"
IgnoreSelected false
</Plugin>
<Plugin "aggregation">
<Aggregation>
Plugin "cpu"
Type "cpu"
GroupBy "Host"
GroupBy "TypeInstance"
CalculateAverage true
</Aggregation>
</Plugin>
<Plugin interface>
Interface "lo"
Interface "/^veth.*/"
Interface "/^docker.*/"
IgnoreSelected true
</Plugin>
<Chain "PostCache">
<Rule>
<Match regex>
Plugin "^cpu$"
PluginInstance "^[0-9]+$"
</Match>
<Target write>
Plugin "aggregation"
</Target>
Target stop
</Rule>
Target "write"
</Chain>
<Plugin "write_graphite">
<Carbon>
Host "15.57.33.232"
Port "2003"
Prefix "collectd."
EscapeCharacter "_"
SeparateInstances true
StoreRates true
AlwaysAppendDS false
</Carbon>
</Plugin>
#!/bin/bash
# Perform installation as root
# Install prereqs
yum -y install libcurl libcurl-devel rrdtool rrdtool-devel rrdtool-perl libgcrypt-devel gcc make gcc-c++
# Get Collectd, untar it, make it and install
wget https://collectd.org/files/collectd-5.7.2.tar.bz2
tar xvjf collectd-5.7.2.tar.bz2
cd collectd-5.7.2
./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 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment