Web interface to collectd: collectd-web

Configuration

by ross at 08:12:09 on October 29, 2011

Prepare

# cd /usr/ports/converters/p5-JSON
# make install clean
# cd /usr/ports/textproc/p5-HTML-HTML5-Parser
# make install clean

Install version 4 of collectd (net-mgmt/collectd) as described here. Current (0.4.0) version of collectd-web doesn't play nice with net-mgmt/collectd5.

Navigate to http://github.com/httpdss/collectd-web/downloads and download latest version of collectd-web. Extract archive and copy directory to, for example, /home/collectd/collectd-web.

Edit collectd-web/cgi-bin/collection.modified.cgi:

#our $Config   = "/etc/collectd/collection.conf";
our $Config   = "/usr/local/etc/collectd-web.conf";

Find $GraphDefs array in load_graph_definitions sub, add:

        ping_droprate => [
            '-v',
            'Percent',
            'DEF:avg={file}:value:AVERAGE',
            'DEF:min={file}:value:MIN',
            'DEF:max={file}:value:MAX',
            "AREA:max#$HalfRed",
            "AREA:min#$Canvas",
            "LINE2:avg#$FullRed:Percent",
            'GPRINT:min:MIN:%5.1lf%% Min,',
            'GPRINT:avg:AVERAGE:%5.1lf%% Avg,',
            'GPRINT:max:MAX:%5.1lf%% Max,',
            'GPRINT:avg:LAST:%5.1lf%% Last\l'
        ],
        uptime => [
            '-v',
            'Days',
            'DEF:raw={file}:value:MAX',
            'CDEF:out_val=raw,86400,/',
            'CDEF:out_days=out_val,FLOOR',
            'CDEF:out_hours=out_val,out_days,-,24,*,FLOOR',
            'CDEF:out_mins=out_val,out_days,-,24,*,out_hours,-,60,*,FLOOR',
            'CDEF:out_secs=out_val,out_days,-,24,*,out_hours,-,60,*,out_mins,-,60,*',
            "AREA:out_val#$HalfBlue",
            "LINE1:out_val#$FullBlue:Uptime",
            'GPRINT:out_days:LAST:%6.0lf day(s),',
            'GPRINT:out_hours:LAST:%6.0lf hour(s),',
            'GPRINT:out_mins:LAST:%6.0lf min(s),',
            'GPRINT:out_secs:LAST:%6.0lf sec(s)\l'
        ]

Create /usr/local/etc/collectd-web.conf:

datadir: "/home/collectd/data/"

I am using virtual host here. Create /usr/local/etc/apache22/Includes/stats.example.com.conf:

<VirtualHost *:80>
        ServerName stats.example.com
        ServerAdmin root@example.com
        DocumentRoot "/home/collectd/collectd-web"
        ScriptAlias /cgi-bin/ /home/collectd/collectd-web/cgi-bin/
        ErrorLog "/var/log/httpd-stats.example.com-error.log"
        CustomLog "/var/log/httpd-stats.example.com-access.log" combined
</VirtualHost>

<Directory "/home/collectd/collectd-web">
        Options FollowSymLinks Indexes
        AllowOverride All
        Order Allow,Deny
        Allow from all
</Directory>

<Directory "/home/collectd/collectd-web/cgi-bin">
        Options None
        AllowOverride None
        Order Allow,Deny
        Allow from all
</Directory>

Restart Apache

# service apache22 restart

 

Comments