What is collectd?
collectd is a daemon which collects system performance statistics periodically and provides mechanisms to store the values in a variety of ways, for example in RRD-files.
This is a short “how to get started with collectd” guide.
1) Configure and start collectd
Here is a basic collectd.conf file, located in the /etc directory. Only the ping input plugin is activated for two hosts.
1 2 3 4 5 6 7 | Hostname “localhost“ FQDNLookup false BaseDir “/var/lib/collectd“ PluginDir “/usr/lib/collectd“ lTypesDB ”/usr/lib/collectd/types.db“ Interval 10 ReadThreads 5 |
1 | LoadPlugin syslog |
1 2 | LoadPlugin ping LoadPlugin rrdtool |
1 2 3 4 | <Plugin ping> Host “hostname1.domain.com“ Host “hostname2.domain.com“ </Plugin> |
Start the collectd daemon now. Hint: You maybe want to use collectmon to start collectd — if collectd itself crash, collectdmon will automatically restart collectd.
2) Get some data
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | # rrdtool info /var/lib/collectd/localhost/ping/ping-hostname1.domain.com.rrd filename = “/var/lib/collectd/localhost/ping/ping-hostname1.domain.com.rrd“ rrd_version = “0003” step = 10 last_update = 1244479170 ds[ping].type = “GAUGE“ ds[ping].minimal_heartbeat = 20 ds[ping].min = 0.0000000000e+00 ds[ping].max = 6.5535000000e+04 ds[ping].last_ds = “1.026000″ ds[ping].value = 0.0000000000e+00 ds[ping].unknown_sec = 0 rra[0].cf = “AVERAGE“ rra[0].rows = 1200 rra[0].cur_row = 959 rra[0].pdp_per_row = 1 <…> |
As you see, “ping” is the name of this datasource collectd created for us.
3) Create a nice image out of the rrd datafile
Default image, last 24 hours:
1 | # rrdtool graph –E /tmp/ping-24h.png –title “Ping hostname1.domain.com, last 24h” –vertical-label “ms” DEF:ptime=/var/lib/collectd/localhost/ping/ping-hostname1.domain.com.rrd:ping:AVERAGE LINE:ptime#6188AB:“Pingtime” |
Output:

Image for the last hour:
1 | # rrdtool graph –E –start end-1h /tmp/ping-1h.png –title “Ping hostname1.domain.com, last hour” –vertical-label “ms” DEF:ptime=/var/lib/collectd/localhost/ping/ping-hostname1.domain.com.rrd:ping:AVERAGE LINE:ptime#6188AB:“Pingtime” |
Output:

The parameter –E creates a more ‘organic’ look.
Now we could also combine multible data sources into one rrd image:
1 | rrdtool graph –E –start end-1h /tmp/ping-24h.png –title “Ping time, last hour” –vertical-label “ms” DEF:ptime=/var/lib/collectd/localhost/ping/ping-hostname1.domain.com.rrd:ping:AVERAGE LINE:ptime#6188AB:“hostname1.domain.com” DEF:ptime2=/var/lib/collectd/localhost/ping/ping-hostname2.domain.com.rrd:ping:AVERAGE LINE:ptime2#DE8745:“hostname2.domain.com” |
Output:
