Collectd
========
Collectd is a daemon to collect system statistics in RRD (Round-Robin Database)
files. It is basically a backend daemon and several front-end exist to navigate through the data.
* Web site: https://collectd.org/
* Plugins: https://collectd.org/wiki/index.php/Table_of_Plugins
* Front-ends: https://collectd.org/wiki/index.php/List_of_front-ends
Installation
------------
Collectd is packaged for some Linux distribution. In Debian, this command
installs collectd with the default configuration::
apt-get install collectd
The configuration is done in ``/etc/collectd/collectd.conf``. It is quite
straightforward and the wiki helps understanding the few tricky fields
(https://collectd.org/wiki/index.php/Table_of_Plugins).
Here is a basic configuration::
LoadPlugin syslog
LogLevel info
LoadPlugin cpu
LoadPlugin df
LoadPlugin disk
LoadPlugin interface
#LoadPlugin irq
LoadPlugin load
LoadPlugin memory
LoadPlugin rrdtool
#LoadPlugin sensors
LoadPlugin swap
Device "rootfs"
# MountPoint "/home"
FSType "cgroup"
FSType "devtmpfs"
FSType "tmpfs"
FSType "overlay"
FSType "squashfs"
IgnoreSelected true
ReportByDevice false
ReportReserved true
ReportInodes true
# Don't collect statistitics about loopback interface
Interface "lo"
IgnoreSelected true
DataDir "/var/lib/collectd/rrd/"
Network setup
-------------
To centralise collected data on a server, you need to use the network plugin
(https://collectd.org/wiki/index.php/Plugin:Network). If your collectd daemon
is recent enough, you may use authenticated and encrypted communication channels
using a password.
On the server, the configuration looks like this in ``collectd.conf``::
# Server IP and UDP port to listen to
SecurityLevel Sign
# This file contains for each user with password "secret":
# user: secret
AuthFile "/etc/collectd/passwd"
Interface "eth0"
MaxPacketSize 1024
On each client, ``collectd.conf`` may contain::
SecurityLevel Encrypt
Username "user"
Password "secret"
Interface "eth0"
TimeToLive "128"
Collection3 front-end
---------------------
Collectd package often provides front-end examples among which is Collection3.
This front-end is a web front-end written as a CGI script in Perl.
By default it will look for RRD files in ``/var/lib/collectd/rrd`` but this
can be changed by editing ``etc/collection.conf`` which contains by default::
DataDir "/var/lib/collectd/rrd"
Collection3 needs some Perl modules:
* ``Config::General``
* ``Regexp::Common``
* ``HTML::Entities``
* ``RRDs``
On a Debian server, this command installs the needed modules::
apt-get install lib{config-general,regexp-common,html-parser,rrds}-perl
Apache virtual host configuration
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
::
Alias /collection3/ /usr/share/doc/collectd-core/examples/collection3/
ScriptAlias /collection3/bin/ /usr/share/doc/collectd-core/examples/collection3/bin/
AddHandler cgi-script .cgi
DirectoryIndex bin/index.cgi
Options +ExecCGI
Order Allow,Deny
Allow from all
Nginx server configuration
~~~~~~~~~~~~~~~~~~~~~~~~~~
::
server {
listen 80 default_server;
location /collection3 {
alias /usr/share/doc/collectd-core/examples/collection3;
location ~ ^/collection3/bin/.+\.cgi$ {
include fastcgi_params;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
}
location /collection3/share {
try_files $uri $uri/ =404;
}
location /collection3 {
return 301 /collection3/bin/index.cgi;
}
}
}
Lighttpd server configuration
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
::
# Note: if the config already enables mod_alias, you must remove it from
# the next line
server.modules += ( "mod_alias" "mod_cgi" )
alias.url += ( "/collection3" => "/usr/share/doc/collectd-core/examples/collection3/" )
$HTTP["url"] =~ "^/collection3" {
cgi.assign = ( ".cgi" => "/usr/bin/perl" )
}
index-file.names += ( "bin/index.cgi" )
Collectd Graph Panel front-end
------------------------------
CGP (Collectd Graph Panel) is a better front-end than Collection3. It is
written in PHP. To install it, you just need to download latest release from
https://github.com/pommi/CGP/releases in a folder and to configure your web
server accordingly.
Official website: http://pommi.nethuis.nl/category/cgp/
To enable ``jsrrdgraph`` (to have Javascript-rendered graphs in which you can
navigate with your mouse), you just need to enable the ``canvas`` mode. This
is done by creating ``conf/config.local.php`` with::