summaryrefslogtreecommitdiff
path: root/other/tor/bin/rrd-graph
diff options
context:
space:
mode:
Diffstat (limited to 'other/tor/bin/rrd-graph')
-rwxr-xr-xother/tor/bin/rrd-graph75
1 files changed, 48 insertions, 27 deletions
diff --git a/other/tor/bin/rrd-graph b/other/tor/bin/rrd-graph
index 2940f7c..05a9601 100755
--- a/other/tor/bin/rrd-graph
+++ b/other/tor/bin/rrd-graph
@@ -18,37 +18,51 @@ my $RRD_DIR = '/home/weasel/www/www.noreply.org/Build/other/tor/rrd/nodes';
my $INDEX_DIR = '/home/weasel/www/www.noreply.org/Build/other/tor/index';
my $RESULT_DIR = 'result.new';
my $LONG_TIME_MONTHS = 15;
+my $VERBOSE = 0;
# Get list of RRD files
opendir(D,$RRD_DIR) or die ("Cannot opendir $RRD_DIR: $!\n");
-my @SOURCES = 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;
+my @dirs = grep { -d $RRD_DIR.'/'.$_ && $_ =~ /^[A-F0-9]{2}$/ } readdir(D);
closedir(D);
+my @SOURCES;
+for my $dir (@dirs) {
+ opendir(D,$RRD_DIR.'/'.$dir) or die ("Cannot opendir $RRD_DIR/$dir: $!\n");
+ my @sources = grep { /\.rrd$/ } readdir(D);
+ @sources = grep { !/^TRAF-/ } @sources;
+ @sources = grep {
+ my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
+ $atime,$mtime,$ctime,$blksize,$blocks) = stat($RRD_DIR.'/'.$dir.'/'.$_);
+ $mtime >= $START_AT;
+ } @sources;
+ push @SOURCES, @sources;
+ closedir(D);
+};
+
# Read hash <-> name mapping
my %hashes_router;
opendir(D,$INDEX_DIR) or die ("Cannot opendir $INDEX_DIR: $!\n");
-my @NAME = grep { /\.name$/ } readdir(D);
+@dirs = grep { -d $INDEX_DIR.'/'.$_ && $_ =~ /^[A-F0-9]{2}$/ } readdir(D);
closedir(D);
-for my $hash (@NAME) {
- my $f = $INDEX_DIR.'/'.$hash;
- open (F, $f) or warn("Cannot open $f: $!\n"), next;
- my $name = <F>;
- my $platform = <F>;
- my $published = <F>;
- chomp $name;
- chomp $platform;
- chomp $published;
- close F;
- $hash =~ s/\.name$//;
- $hashes_router{$hash} = {name => $name, platform => $platform, published => $published };
+for my $dir (@dirs) {
+ opendir(D,$INDEX_DIR.'/'.$dir) or die ("Cannot opendir $INDEX_DIR/$dir: $!\n");
+ my @NAME = grep { /\.name$/ } readdir(D);
+ closedir(D);
+ for my $hash (@NAME) {
+ my $f = $INDEX_DIR.'/'.$dir.'/'.$hash;
+ open (F, $f) or warn("Cannot open $f: $!\n"), next;
+ my $name = <F>;
+ my $platform = <F>;
+ my $published = <F>;
+ chomp $name;
+ chomp $platform;
+ chomp $published;
+ close F;
+ $hash =~ s/\.name$//;
+ $hashes_router{$hash} = {name => $name, platform => $platform, published => $published };
+ };
};
-@SOURCES = grep { !/^TRAF-/ } @SOURCES;
@SOURCES = sort {
my $aa = $a;
my $bb = $b;
@@ -69,21 +83,24 @@ for my $source (@SOURCES) {
my $hash = $source;
$hash =~ s/\.rrd$//;
my $name = $hashes_router{$hash}->{'name'};
+ die ("No name for $hash") unless defined $name;
my $platform = $hashes_router{$hash}->{'platform'};
my $published = $hashes_router{$hash}->{'published'};
my $def = $name;
my $cdef = 'c_'.$def;
my $label = $def;
+ my $subdir = substr($hash,0,2);
- my $source_traffic = $RRD_DIR .'/TRAF-'. $source;
- $source = $RRD_DIR .'/'. $source;
+ my $source_traffic = $RRD_DIR .'/'.$subdir.'/TRAF-'. $source;
+ $source = $RRD_DIR .'/'.$subdir.'/'. $source;
my (undef,undef,undef,undef,undef,undef,undef,undef, undef,$mtime,undef,undef,undef) = stat($source);
my $section = $mtime < $OLD_AT ? 'old' : 'current';
my @this;
- push @this, sprintf($RESULT_DIR.'/node-%s.png', $hash);
+ mkdir ($RESULT_DIR.'/'.$subdir) unless -d ($RESULT_DIR.'/'.$subdir);
+ push @this, sprintf($RESULT_DIR.'/'.$subdir.'/node-%s.png', $hash);
push @this, sprintf('-s %s', $START_AT);
push @this, sprintf('-e %s', $END_AT);
push @this, sprintf('-t %s', "$name");
@@ -108,6 +125,7 @@ for my $source (@SOURCES) {
push @this, sprintf('CDEF:%s=d_runningVerified,0,*,%s,+' , 'zeroline' , '0');
push @this, sprintf('%s:%s' , 'LINE1' , 'zeroline' );
+ print "Graphing $hash running.\n" if $VERBOSE;
my ($averages,$xsize,$ysize) = RRDs::graph @this;
warn RRDs::error if RRDs::error;
@@ -118,7 +136,7 @@ for my $source (@SOURCES) {
"platform $platform<br>".
"published $published".
"</blockquote>".
- "<p><img width=\"$xsize\" height=\"$ysize\" alt=\"$name running\" src=\"$IMG_URL"."node-$hash.png\">\n";
+ "<p><img width=\"$xsize\" height=\"$ysize\" alt=\"$name running\" src=\"$IMG_URL"."$subdir/node-$hash.png\">\n";
$index{$section} .= "<li><a href=\"$section.html#$hash\">$name</a></li>\n";
if (-e $source_traffic) {
@@ -159,7 +177,7 @@ for my $source (@SOURCES) {
for my $thumb (0, 1) {
@this = ();
- push @this, sprintf($RESULT_DIR.'/node-'.($thumb ? 'small-' : '').'traf-%s.png', $hash);
+ push @this, sprintf($RESULT_DIR.'/'.$subdir.'/node-'.($thumb ? 'small-' : '').'traf-%s.png', $hash);
#push @this, sprintf('-s %s', '-604800');
push @this, sprintf('-s %s', $START_AT);
push @this, sprintf('-e %s', $END_AT);
@@ -204,12 +222,13 @@ for my $source (@SOURCES) {
#push @this, sprintf('CDEF:%s=read,0,*,%s,+' , 'zeroline' , '0');
#push @this, sprintf('%s:%s' , 'LINE1' , 'zeroline' );
+ print "Graphing $hash traffic $thumb.\n" if $VERBOSE;
($averages,$xsize,$ysize) = RRDs::graph @this;
warn RRDs::error if RRDs::error;
};
- $body{$section} .= " <a href=\"$IMG_URL"."node-traf-$hash.png\">";
- $body{$section} .= "<img width=\"$xsize\" height=\"$ysize\" alt=\"$name traffic\" src=\"$IMG_URL"."node-small-traf-$hash.png\">";
+ $body{$section} .= " <a href=\"$IMG_URL"."$subdir/node-traf-$hash.png\">";
+ $body{$section} .= "<img width=\"$xsize\" height=\"$ysize\" alt=\"$name traffic\" src=\"$IMG_URL"."$subdir/node-small-traf-$hash.png\">";
$body{$section} .= "</a>";
};
#$body{$section} .= "<br><a href=\"#_top\">top</a>";
@@ -253,6 +272,7 @@ sub makeTotalTrafficPic($$$) {
push @totalTraffic, sprintf('CDEF:zeroline=aggread%d,0,*', $traf_item_counter);
push @totalTraffic, sprintf('%s:%s' , 'LINE1' , 'zeroline' );
+ print "Graphing total traffic $file $age $include15min.\n" if $VERBOSE;
my ($averages,$xsize,$ysize) = RRDs::graph @totalTraffic;
warn RRDs::error if RRDs::error;
@@ -307,6 +327,7 @@ sub makeNumbersGraph($$) {
+ print "Graphing numbers $file $age.\n" if $VERBOSE;
my ($averages,$xsize,$ysize) = RRDs::graph @params;
warn RRDs::error if RRDs::error;