Munin plugin for Trac

HISTORY

This is not maintained anymore and the information is just kept for historic reason. We do use Munin but we do not use Trac anymore.

Trac + Munin

As we use Munin for some statistical purposes we wrote a simple plugin to plot the tickets in Trac as a graph. The base is the status and in an active Trac setup it should be fairly obvious how tickets have travelled in the system.

Enjoy!

#!/usr/bin/perl -wT
#
# Munin plugin that graphs the number of tickets based on the status.
# (C) 2009 Martin Bagge, <brother@bsnet.se>
# GPL 2 applies
#      
use DBI;

# Add the path to your Trac database here
my $sqlitepath = "/var/spool/trac/db/trac.db";

## Below this line is the code, you should not need to change anything here.

if ($ARGV[0] and $ARGV[0] eq "config" ){
    print "graph_title Tickets in Tracn";
    print "graph_args --base 1000 -l 0n";
    print "graph_scale yesn";
    print "graph_vlabel ticketsn";
    print "graph_category tracn";
    print "graph_total Totaln";

    my $dbh = DBI->connect("dbi:SQLite:dbname=$sqlitepath","","");
    my $all = $dbh->selectall_arrayref("SELECT status FROM ticket GROUP BY status");
    foreach my $row (@$all) {
        my ($status) = @$row;
        print $status.".label $statusn";
    }
    exit 0;
}

my $dbh = DBI->connect("dbi:SQLite:dbname=$sqlitepath","","");

my $all = $dbh->selectall_arrayref("SELECT status, count(id) AS antal FROM ticket GROUP BY status");
foreach my $row (@$all) {
    my ($status, $count) = @$row;
    print $status.".value $countn";
}

$dbh->disconnect();