#!/usr/bin/perl -w # # $Id: makeimages.pl,v 1.1 2003/03/03 11:39:38 kjc Exp $ # # usage: makeimages.pl [-l logdir] timestamp [timestamp2 ...] # # create daily and weekly plot graphs under the current directory. # timestamp should be "yyyymmdd". # for example, if "20010806" is specified, it creates 4 png files, # 2001/08/06/20010806.{saddr,daddr,sport,dport}.png, from # "$agurilogdir/2001/08/06/??/*.agr". # use POSIX; $agurilogdir = "."; # assume logdir is cur dir or use of -l option $plotdata = "$agurilogdir/plotdata"; $aguri = "/usr/local/bin/aguri"; $makeplot = "/usr/local/lib/aguri/makeplot.pl"; $gnuplot = "/usr/local/bin/gnuplot"; $numflows = 15; $create_weekimg = 1; # # usually, you don't need to edit below this line # umask(022); chomp($cwd = `pwd`); while ($tstamp = shift @ARGV) { if ($tstamp eq "-l") { $agurilogdir = shift @ARGV; $tstamp = shift @ARGV } chdir $cwd or die "can't cd to $cwd\n"; $year = substr $tstamp, 0, 4; $month = substr $tstamp, 4, 2; $day = substr $tstamp, 6, 2; # # create directories if they don't exist. # mkdir "$year", 0755 unless -d "$year"; mkdir "$year/$month", 0755 unless -d "$year/$month"; mkdir "$year/$month/$day", 0755 unless -d "$year/$month/$day"; chdir "$agurilogdir" or die "can't cd to $agurilogdir\n"; chomp($agurilogdir = `pwd`); chdir "$year/$month/$day" or die "can't cd to $agurilogdir/$year/$month/$day\n"; @agrfiles = glob("??/*.agr"); unless ($#agrfiles >= 0) { die "can't find .agr files!\n"; } $agrs = join ' ', @agrfiles; # src address plot system "$aguri -P -xs -yM -n $numflows $agrs > $plotdata"; system "$makeplot $plotdata | $gnuplot > $cwd/$year/$month/$day/$tstamp.saddr.png"; system "$makeplot -3D $plotdata | $gnuplot > $cwd/$year/$month/$day/$tstamp.saddr-3d.png"; # dst address plot system "$aguri -P -xd -yM -n $numflows $agrs > $plotdata"; system "$makeplot $plotdata | $gnuplot > $cwd/$year/$month/$day/$tstamp.daddr.png"; system "$makeplot -3D $plotdata | $gnuplot > $cwd/$year/$month/$day/$tstamp.daddr-3d.png"; # src port plot system "$aguri -P -xS -yM -n $numflows $agrs > $plotdata"; system "$makeplot $plotdata | $gnuplot > $cwd/$year/$month/$day/$tstamp.sproto.png"; system "$makeplot -3D $plotdata | $gnuplot > $cwd/$year/$month/$day/$tstamp.sproto-3d.png"; # dst port plot system "$aguri -P -xD -yM -n $numflows $agrs > $plotdata"; system "$makeplot $plotdata | $gnuplot > $cwd/$year/$month/$day/$tstamp.dproto.png"; system "$makeplot -3D $plotdata | $gnuplot > $cwd/$year/$month/$day/$tstamp.dproto-3d.png"; # # create an index file # open(HOUT,"> $cwd/$year/$month/$day/index.html"); print HOUT "\n"; print HOUT "
\n"; print HOUT "
\n";
print HOUT "
\n";
print HOUT "
\n";
print HOUT "
\n";
print HOUT "
\n";
print HOUT "
\n";
print HOUT "
\n";
print HOUT "
\n";
print HOUT "
\n";
print HOUT "
\n";
print HOUT "
\n";
print HOUT "
\n";
print HOUT "
\n";
print HOUT "
\n";
print HOUT "
\n";
print HOUT "
\n";
print HOUT "\n"; print HOUT "