diff options
Diffstat (limited to 'other/mixminion/bin/rrd-graph')
-rwxr-xr-x | other/mixminion/bin/rrd-graph | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/other/mixminion/bin/rrd-graph b/other/mixminion/bin/rrd-graph new file mode 100755 index 0000000..269a2ad --- /dev/null +++ b/other/mixminion/bin/rrd-graph @@ -0,0 +1,103 @@ +#!/usr/bin/perl -w + +use strict; +use RRDs; +use BER; + +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 .= "<h2><a name=\"$def\">$def</a></h2><p><a href=\"#_top\">top</a><p><img width=\"$xsize\" height=\"$ysize\" alt=\"$def running\" src=\"$IMG_URL"."node-$def.png\"></p>\n"; + $index .= "<li><a href=\"#$def\">$def</a></li>\n"; +} + +my ($averages,$xsize,$ysize) = RRDs::graph @params; +die RRDs::error if RRDs::error; + +my $html = "<html><head><title>Number of Mixminion Nodes</title></head><body>"; +$html .= "<h1><a name=\"_top\">Number of Mixminion Nodes</a></h1>"; +$html .= "<a href=\"../\">..</a><br>\n"; +$html .= "<p><img width=\"$xsize\" height=\"$ysize\" src=\"$IMG_URL"."total.png\"></p>"; +$html .= "<h1>Nodes</h1>"; +$html .= "<ul>".$index."</ul>"; +$html .= $body; +$html .= "<br><br><br>\n"; +$html .= 'Images created with Tobi Oetiker\'s <a href="http://people.ee.ethz.ch/~oetiker/webtools/rrdtool/">rrdtool</a>'."\n"; +$html .= "<hr>\nBuilt at $GMTIME on $HOSTNAME<br>\n"; +$html .= "<a href=\"mailto:web\@palfrader.org\">Peter Palfrader <web\@palfrader.org></a>\n"; +$html .= "</body></html>\n"; + +open (F, ">result/index.html") or die ("Cannot open index.html: $!\n"); +print F $html; +close F; + |