collectd-web

From Gentoo Wiki
Jump to: navigation, search

collectd-web is a web-based Perl CGI front-end for RRD data collected by collectd.

Installation

Emerge

Install www-apps/collectd-web:

root #emerge --ask collectd-web

To display the graphs, net-analyzer/rrdtool needs the USE flags graph and perl.

Web server

You need also a web server.

The CGI scripts have to be executable:

root #chmod +x /usr/share/webapps/collectd-web/*/hostroot/cgi-bin/*.cgi

Built-in web server

The collectd-web project offers a simple web server to process the CGI scripts:

root #cd /usr/share/webapps/collectd-web/*/hostroot/
root #python2 runserver <ip> <port>

Now you need to set up a reverse proxy which will serve static files from /usr/share/webapps/collectd-web/0.4.0/htdocs for / and for /cgi-bin/ it will proxy the request to the above set up <ip> <port>.

Apache

It is possible to use Apache to serve the pages. Configuration of the corresponding virtual host needs to be adjusted so that it knows where to find cgi scripts of collectd-web. For default vhost make following modification:

FILE /etc/apache2/vhosts.d/00_default_vhost.confDefining alias to cgi scripts location
<VirtualHost *:80>
...
    ScriptAlias /collectd-web/cgi-bin/ "/var/www/localhost/cgi-bin/"
...
</VirtualHost>

nginx

This is an example server section for nginx using www-misc/fcgiwrap. This setup does not require using the built-in webserver and downloading the extra python script.

root #emerge --ask fcgiwrap
root #systemctl enable fcgiwrap.socket
root #systemctl start fcgiwrap.socket
FILE /etc/nginx/conf.d/collectd-web.confExample nginx confiugration for collectd
server {
    listen 80;
    large_client_header_buffers 4 16k; # for large cookies and headers

    location / {
        root  /usr/share/webapps/collectd-web/0.4.0/htdocs; # this serves the static files
    }

    location /cgi-bin/ {
        gzip off;
        root  /usr/share/webapps/collectd-web/0.4.0/hostroot; # this is the parent directory of cgi-bin
        fastcgi_pass  unix:/var/run/fcgiwrap.sock;
        include /etc/nginx/fastcgi_params;
        fastcgi_param SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    }
}

Save this as a separate file as suggested above and include it in /etc/nginx/nginx.conf and restart nginx:

root #systemctl restart nginx

The web interface is then available on http://localhost.

Configuration

Configure Collectd#rrdtool_plugin

Define where collectd-web shall look for rrd files:

FILE /etc/collectd/collection.conf
datadir: "/var/lib/collectd/rrd"

Usage

Point your browser at the reverse proxy or (in case you using default Apache configuration) at http://localhost/collectd-web.