#!/usr/bin/perl -w use strict; use RRDs; my $HOSTNAME = `hostname`; #my $IMG_URL = 'http://images.noreply.org/mixminion-nodes/'; my $IMG_URL = ''; my $NOW = time; my $GMTIME = gmtime($NOW); my $START_AT = $NOW-9*30*24*3600; my $RRD = '/home/weasel/www/www.noreply.org/Build/other/mixminion/rrd/nodes.rrd'; my $RRD_DIR = '/home/weasel/www/www.noreply.org/Build/other/mixminion/rrd/nodes'; opendir(D,$RRD_DIR) or die ("Cannot opendir .: $!\n"); my @SOURCES = sort { lc($a) cmp lc($b)} grep { /\.rrd$/ } readdir(D); @SOURCES = grep { my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, $atime,$mtime,$ctime,$blksize,$blocks) = stat($RRD_DIR.'/'.$_); $mtime >= $START_AT; } @SOURCES; closedir(D); my @params = qw{result/total.png}; push @params, sprintf('-s %s', $START_AT); #push @params, sprintf('-e %s', $NOW- 2*24*3600); push @params, sprintf('-t %s', "Mixminion nodes"); push @params, sprintf('-v %s', "# nodes"); #push @params, sprintf('-w %d', 600); #push @params, sprintf('-h %d', 400); push @params, sprintf('DEF:%s=%s:%s:%s', 'd_inDirectory' , $RRD, 'inDirectory', 'AVERAGE'); push @params, sprintf('CDEF:%s=%s' , 'c_inDirectory' , 'd_inDirectory'); push @params, sprintf('%s:%s#%s:%s' , 'LINE2' , 'c_inDirectory' , 'FF77FF', '# in directory'); push @params, sprintf('DEF:%s=%s:%s:%s', 'd_recommended' , $RRD, 'recommended', 'AVERAGE'); push @params, sprintf('CDEF:%s=%s' , 'c_recommended' , 'd_recommended'); push @params, sprintf('%s:%s#%s:%s' , 'LINE3' , 'c_recommended' , '7777FF', '# recommended' ); push @params, sprintf('CDEF:%s=d_inDirectory,0,*,%s,+' , 'zeroline' , '0'); push @params, sprintf('%s:%s' , 'LINE1' , 'zeroline' ); my $body; my $index; for my $source (@SOURCES) { my $def = $source; $def =~ s/\.rrd$//; my $cdef = 'c_'.$def; my $label = $def; $source = $RRD_DIR .'/'. $source; my @this; push @this, sprintf('result/node-%s.png', $def); push @this, sprintf('-s %s', $START_AT); push @this, sprintf('-t %s', "$def"); push @this, sprintf('-v %s', "#"); #push @this, sprintf('-w %d', 150); #push @this, sprintf('-h %d', 50); push @this, sprintf('DEF:%s=%s:%s:%s', 'd_inDirectory' , $source, 'inDirectory', 'AVERAGE'); push @this, sprintf('CDEF:%s=%s' , 'c_inDirectory' , 'd_inDirectory'); push @this, sprintf('%s:%s#%s:%s' , 'AREA' , 'c_inDirectory' , 'FF77FF', '# in directory'); push @this, sprintf('DEF:%s=%s:%s:%s', 'd_recommended' , $source, 'recommended', 'AVERAGE'); push @this, sprintf('CDEF:%s=%s' , 'c_recommended' , 'd_recommended'); push @this, sprintf('%s:%s#%s:%s' , 'AREA' , 'c_recommended' , '7777FF', '# recommended' ); push @this, sprintf('CDEF:%s=d_inDirectory,0,*,%s,+' , 'zeroline' , '0'); push @this, sprintf('%s:%s' , 'LINE1' , 'zeroline' ); my ($averages,$xsize,$ysize) = RRDs::graph @this; warn RRDs::error if RRDs::error; $body .= "

$def

top

\"$def

\n"; $index .= "
  • $def
  • \n"; } my ($averages,$xsize,$ysize) = RRDs::graph @params; die RRDs::error if RRDs::error; my $html = "Number of Mixminion Nodes"; $html .= "

    Number of Mixminion Nodes

    "; $html .= "..
    \n"; $html .= "

    "; $html .= "

    Nodes

    "; $html .= ""; $html .= $body; $html .= "


    \n"; $html .= 'Images created with Tobi Oetiker\'s rrdtool'."\n"; $html .= "
    \nBuilt at $GMTIME on $HOSTNAME
    \n"; $html .= "Peter Palfrader <web\@palfrader.org>\n"; $html .= "\n"; open (F, ">result/index.html") or die ("Cannot open index.html: $!\n"); print F $html; close F;