What is col­lectd?

col­lectd is a dae­mon which col­lects sys­tem per­for­mance sta­tis­tics peri­od­i­cally and pro­vides mech­a­nisms to store the val­ues in a vari­ety of ways, for exam­ple in RRD-files.

This is a short “how to get started with col­lectd” guide.

1) Con­fig­ure and start col­lectd
Here is a basic collectd.conf file, located in the /etc direc­tory. Only the ping input plu­gin is acti­vated for two hosts.

1
2
3
4
5
6
7
Host­name        “local­host“
FQDNLookup      false
BaseDir         “/var/lib/collectd“
Plug­inDir       “/usr/lib/collectd“
lTypesDB        ”/usr/lib/collectd/types.db“
Inter­val        10
ReadThreads     5
1
Load­Plu­gin syslog
1
2
Load­Plu­gin ping
Load­Plu­gin rrdtool
1
2
3
4
<Plugin ping>
Host “hostname1.domain.com“
Host “hostname2.domain.com“
</Plugin>

Start the col­lectd dae­mon now. Hint: You maybe want to use col­lect­mon to start col­lectd — if col­lectd itself crash, col­lect­d­mon will auto­mat­i­cally restart collectd.

2) Get some data

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# rrd­tool info /var/lib/collectd/localhost/ping/ping-hostname1.domain.com.rrd
file­name = “/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 data­source col­lectd cre­ated for us.

3) Cre­ate a nice image out of the rrd datafile
Default image, last 24 hours:

1
# rrd­tool 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”

Out­put:

Image for the last hour:

1
# rrd­tool 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”

Out­put:

The para­me­ter –E cre­ates a more ‘organic’ look.

Now we could also com­bine multi­ble data sources into one rrd image:

1
rrd­tool 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”

Out­put: