1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
#!/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 .= "<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;
|