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 Trac\n";
print "graph_args --base 1000 -l 0\n";
print "graph_scale yes\n";
print "graph_vlabel tickets\n";
print "graph_category trac\n";
print "graph_total Total\n";
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 $status\n";
}
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 $count\n";
}
$dbh->disconnect();
