Index: /trunk/tools/parse_apache_log.pl
===================================================================
--- /trunk/tools/parse_apache_log.pl	(revision 30492)
+++ /trunk/tools/parse_apache_log.pl	(revision 30492)
@@ -0,0 +1,81 @@
+#!/usr/bin/env perl
+
+use warnings;
+use DateTime;
+
+%months = ('Jan' => 1, 'Feb' => 2, 'Mar' => 3, 'Apr' => 4,
+	   'May' => 5, 'Jun' => 6, 'Jul' => 7, 'Aug' => 8,
+	   'Sep' => 9, 'Oct' => 10, 'Nov' => 11, 'Dec' => 12);
+
+my ($ip,$day,$month,$year,$hour,$min,$sec,$bytes);
+
+while (<>) {
+    chomp;
+#	print STDERR "$i\n";
+    if ($_ =~ /POST \/nebulous HTTP\/1.1/) { # This is a nebulous query
+	s/(\d+?\.\d+?\.\d+?\.\d+?) - - \[(\d\d)\/(\w\w\w)\/(\d\d\d\d)\:(\d\d)\:(\d\d)\:(\d\d).*\] "POST \/nebulous HTTP\/1.1" 200 (\d+?)/$1 $2 $3 $4 $5 $6 $7 $8/;
+	($ip,$day,$month,$year,$hour,$min,$sec,$bytes) = split / /;
+	$month = $months{$month};
+	$type  = size_to_type($bytes);
+	count_it($type,$year,$month,$day,$hour,$min,$sec);
+    }
+}
+
+print "#epoch\t";
+foreach $tag (keys %tags) {
+    print "$tag\t";
+}
+print "\n";
+foreach $time (sort {$a <=> $b} (keys %data)) {
+    print "$time\t";
+    foreach $tag (sort (keys %tags)) {
+        unless (exists($data{$time}{$tag})) {
+            $data{$time}{$tag} = 0;
+        }
+        print "$data{$time}{$tag}\t";
+    }
+    print "\n";
+}
+
+sub size_to_type {
+    my $bytes = shift;
+    if ($bytes == 488) { # == 488
+	return("delete");
+    }
+    elsif ($bytes > 1800) { # 1577 + 3*ext_key for stat, 1597 + 3*ext_key for delete
+	return("failure_stat");
+    }
+    elsif ($bytes > 850) {  # 819 + ext_key for stat
+	return("stat");
+    }
+    elsif ($bytes > 650) {  # 600 + ext_key
+	return("find_instance");
+    }
+    elsif ($bytes > 575) { # 526 + ext_key
+	return("create");
+    }
+#    else {
+#	print "$bytes\n";
+#    }
+    return("unknown");
+}
+
+sub count_it {
+    my $tag = shift;
+    my $year = shift;
+    my $month = shift;
+    my $day = shift;
+    my $hour = shift;
+    my $min = shift;
+    my $sec = shift;
+    
+    # Truncate to hours;
+    $sec = 0;
+    $min = int($min / 10) * 10;
+#    $min = 0;
+    my $dt = DateTime->new( year => $year, month => $month, day => $day, hour => $hour, minute => $min, second => $sec);
+    my $time = $dt->epoch;
+
+    $data{$time}{$tag} += 1;
+    $tags{$tag} = 1;
+}
Index: /trunk/tools/parse_nebulous_logs.pl
===================================================================
--- /trunk/tools/parse_nebulous_logs.pl	(revision 30492)
+++ /trunk/tools/parse_nebulous_logs.pl	(revision 30492)
@@ -0,0 +1,114 @@
+#!/usr/bin/env perl
+
+use warnings;
+
+use Getopt::Std;
+use DateTime;
+
+getopts('a:e:m:',\%opt);
+
+%months = ('Jan' => 1, 'Feb' => 2, 'Mar' => 3, 'Apr' => 4,
+	   'May' => 5, 'Jun' => 6, 'Jul' => 7, 'Aug' => 8,
+	   'Sep' => 9, 'Oct' => 10, 'Nov' => 11, 'Dec' => 12);
+$i = 0;
+if (exists($opt{a})) {
+    print STDERR "opening $opt{a}\n";
+    open(A,"$opt{a}");
+    while (<A>) {
+	chomp;
+#	print STDERR "$i\n";
+	if ($_ =~ /POST \/nebulous HTTP\/1.1/) { # This is a nebulous query
+	    ($ip_string,$date_data_string) = split /\[/; # ]/;
+	    ($date_string,$data_string) = split /\]/, $date_data_string;
+#	    $data_string =~ s/\"//g;
+#	    ($request_string,$http_string) = split /\"/, $data_string;
+#	    ($http_code,$bytes) = split /\s+/, $http_string;
+#	    ($ip_addr,$user,$pass) = split /\s+/, $ip_string;
+	    ($date_string2,$tz) = split /\s+/, $date_string;
+	    ($date,$hour,$min,$sec) = split /:/, $date_string2;  #/;
+	    ($day,$month,$year) = split /\//, $date;
+	    $month = $months{$month};
+	    count_it("apache",$year,$month,$day,$hour,$min,$sec);
+	}
+	$i++;
+    }
+    close(A);
+    print STDERR "closing $opt{a}\n";
+}
+if (exists($opt{e})) {
+    print STDERR "opening $opt{e}\n";
+    open(E,"$opt{e}");
+    while (<E>) {
+	chomp;
+	if ($_ =~ /\] \[/) {
+	    ($date_string,$message_string) = split /\] \[/; # ]/;
+	    $date_string =~ s/\[//;
+	    ($dow,$month,$day,$time_string,$year) = split /\s+/, $date_string;
+	    ($hour,$min,$sec) = split /:/, $time_string; #/;
+	    $month = $months{$month};
+#	print "$_ -> $year $month $day $hour $min $sec\n";
+	    count_it("apache_error",$year,$month,$day,$hour,$min,$sec);
+	}
+    }
+    close(E);
+    print STDERR "closing $opt{e}\n";
+}
+if (exists($opt{m})) {
+    print STDERR "opening $opt{m}\n";
+    open(M,"$opt{m}");
+    ($year,$month,$day,$hour,$min,$sec) = (1970,1,1,0,0,0);
+    while (<M>) {
+	chomp;
+	if ($_ =~ /^# Time:/) {  # This is a time statement
+	    ($trash,$trash2,$date_string,$time_string) = split /\s+/;
+	    $year = int($date_string / 10000);
+	    $month = int( ($date_string - ($year * 10000)) / 100);
+	    $day   = int( ($date_string - ($year * 10000) - ($month * 100)));
+	    $year += 2000;
+	    ($hour,$min,$sec) = split /:/, $time_string; #/;
+#	    print "$date_string >> $time_string :: $year $month $day $hour $min $sec\n";
+	}
+	elsif ($_ =~ /^# Query_time:/) { # This is an increment at that time;
+	    count_it("mysql_slow",$year,$month,$day,$hour,$min,$sec);
+	}
+    }
+    close(M);
+    print STDERR "closing $opt{m}\n";
+}
+
+print "#epoch\t";
+foreach $tag (keys %tags) {
+    print "$tag\t";
+}
+print "\n";
+foreach $time (sort {$a <=> $b} (keys %data)) {
+    print "$time\t";
+    foreach $tag (keys %tags) {
+	unless (exists($data{$time}{$tag})) {
+	    $data{$time}{$tag} = 0;
+	}
+	print "$data{$time}{$tag}\t";
+    }
+    print "\n";
+}
+
+
+sub count_it {
+    my $tag = shift;
+    my $year = shift;
+    my $month = shift;
+    my $day = shift;
+    my $hour = shift;
+    my $min = shift;
+    my $sec = shift;
+    
+    # Truncate to hours;
+    $sec = 0;
+    $min = int($min / 10) * 10;
+#    $min = 0;
+    my $dt = DateTime->new( year => $year, month => $month, day => $day, hour => $hour, minute => $min, second => $sec);
+    my $time = $dt->epoch;
+
+    $data{$time}{$tag} += 1;
+    $tags{$tag} = 1;
+}
