I whipped up this quick 'n dirty script this morning to generate a graph showing how many reviews were posted to our RB installation per day. I thought someone else might find this interesting, so here it is. You'll need to install RRDTool::OO perl module first with this command:
sudo cpan -i RRDTool::OO There's a lot of room for improvement. Jay #!/usr/bin/perl use strict; use warnings; use RRDTool::OO; use DateTime; use Log::Log4perl qw(:easy); use DBI; # uncomment to debug #Log::Log4perl->easy_init( $DEBUG ); my $dbh = DBI->connect ( "DBI:mysql:database=reviewboard;host=localhost", "reviewboard", 'xxx' ); my $sth = $dbh->prepare( "select date_format( time_added, \"%Y%m%d\"), count(*) from reviews_reviewrequest group by date_format( time_added, \"%Y%m%d\")" ) or die $dbh->errstr(); $sth->execute(); # need to know the date of the first row my ( $date, $count ) = $sth->fetchrow_array(); if ( !$date ) { die "no data"; } my $dt = parse_date($date); my $start = $dt->epoch(); my $rrd = RRDTool::OO->new( file => "codereview-usage.rrd" ); $rrd->create( step => 60 * 60 * 24, # once a day data_source => { name => "reviews-per-day", type => "GAUGE" }, archive => { rows => 365 }, start => ( $start - 1 ), ); do { my $dt = parse_date($date); $rrd->update( 'time' => $dt->epoch(), value => $count, ); } while ( ( $date, $count ) = $sth->fetchrow_array() ); # Draw a graph in a PNG image $rrd->graph( image => "codereview-usage.png", vertical_label => "Number of Reviews", start => $start, draw => { type => "area", color => '0000FF', legend => "Code reviews posted per day", } ); sub parse_date { my $date = shift; $date =~ /(\d{4})(\d{2})(\d{2})/; my ( $year, $month, $day ) = ( $1, $2, $3 ); DEBUG "$year $month $day\n"; die "invalid date: '$date'" if !$day; return DateTime->new( year => $year, month => $month, day => $day, ); } --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "reviewboard" group. To post to this group, send email to reviewboard@googlegroups.com To unsubscribe from this group, send email to reviewboard+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/reviewboard?hl=en -~----------~----~----~----~------~----~------~--~---