Michael Thomas 378ef72
##########################################################################
Michael Thomas 378ef72
##########################################################################
Michael Thomas 378ef72
Michael Thomas 378ef72
use strict;
Michael Thomas 378ef72
Michael Thomas 378ef72
my ($junk, $Msg, $total);
Michael Thomas 378ef72
my %Action = ();
Michael Thomas 378ef72
my %Start = ();
Michael Thomas 378ef72
my %Login = ();
Michael Thomas 378ef72
my %TakeChar = ();
Michael Thomas 378ef72
my %DropChar = ();
Michael Thomas 378ef72
my %Logout = ();
Michael Thomas 378ef72
Michael Thomas 378ef72
my $Detail = $ENV{'LOGWATCH_DETAIL_LEVEL'} || 0;
Michael Thomas 378ef72
Michael Thomas 378ef72
# Interesting events:
Michael Thomas 378ef72
#2007-02-17 12:45:22 START - - - Standalone server startup
Michael Thomas 378ef72
#2007-02-17 12:56:58 LOGIN 2158 2159 - Create account wart
Michael Thomas 378ef72
#2007-02-17 12:57:03 TAKE_CHAR 2158 2159 2160 Created character wart(settler) by account wart
Michael Thomas 378ef72
#2007-02-17 12:57:43 DROP_CHAR 2158 - 2160 Logout character wart(settler)
Michael Thomas 378ef72
#2007-02-17 12:57:43 LOGOUT 2158 2159 - Logout account wart
Michael Thomas 378ef72
Michael Thomas 378ef72
Michael Thomas 378ef72
while (defined(my $ThisLine = <STDIN>)) {
Michael Thomas 378ef72
   chomp($ThisLine);
Michael Thomas 378ef72
   if ( ($Msg) = ($ThisLine =~ /START - - - (.*)$/)) {
Michael Thomas 378ef72
      $Start{$Msg}++;
Michael Thomas 378ef72
   }
Michael Thomas 378ef72
   if ( ($Msg) = ($ThisLine =~ /LOGIN [-0-9]+ [-0-9]+ [-0-9]+ (.*)$/)) {
Michael Thomas 378ef72
      $Login{$Msg}++;
Michael Thomas 378ef72
   }
Michael Thomas 378ef72
   if ( ($Msg) = ($ThisLine =~ /TAKE_CHAR [-0-9]+ [-0-9]+ [-0-9]+ (.*)$/)) {
Michael Thomas 378ef72
      $TakeChar{$Msg}++;
Michael Thomas 378ef72
   }
Michael Thomas 378ef72
   if ( ($Msg) = ($ThisLine =~ /DROP_CHAR [-0-9]+ [-0-9]+ [-0-9]+ (.*)$/)) {
Michael Thomas 378ef72
      $DropChar{$Msg}++;
Michael Thomas 378ef72
   }
Michael Thomas 378ef72
   if ( ($Msg) = ($ThisLine =~ /LOGOUT [-0-9]+ [-0-9]+ [-0-9]+ (.*)$/)) {
Michael Thomas 378ef72
      $Logout{$Msg}++;
Michael Thomas 378ef72
   }
Michael Thomas 378ef72
}
Michael Thomas 378ef72
Michael Thomas 378ef72
if (keys %Start) {
Michael Thomas 378ef72
   if ($Detail >= 5) {
Michael Thomas 378ef72
      foreach my $Msg (sort keys %Start) {
Michael Thomas 378ef72
         if ($Start{$Msg} > 1) {
Michael Thomas 378ef72
            print "$Msg ($Start{$Msg} times)\n"
Michael Thomas 378ef72
         } else {
Michael Thomas 378ef72
            print "$Msg\n"
Michael Thomas 378ef72
         }
Michael Thomas 378ef72
      }
Michael Thomas 378ef72
   } else {
Michael Thomas 378ef72
      my $total;
Michael Thomas 378ef72
      foreach my $Msg (sort keys %Start) {
Michael Thomas 378ef72
         $total += $Start{$Msg};
Michael Thomas 378ef72
      }
Michael Thomas 378ef72
      print "Server started $total times\n";
Michael Thomas 378ef72
   }
Michael Thomas 378ef72
}
Michael Thomas 378ef72
Michael Thomas 378ef72
if (keys %Login) {
Michael Thomas 378ef72
   if ($Detail >= 5) {
Michael Thomas 378ef72
      foreach my $Msg (sort keys %Login) {
Michael Thomas 378ef72
         if ($Login{$Msg} > 1) {
Michael Thomas 378ef72
            print "$Msg ($Login{$Msg} times)\n"
Michael Thomas 378ef72
         } else {
Michael Thomas 378ef72
            print "$Msg\n"
Michael Thomas 378ef72
         }
Michael Thomas 378ef72
      }
Michael Thomas 378ef72
   } else {
Michael Thomas 378ef72
      my $total;
Michael Thomas 378ef72
      foreach my $Msg (sort keys %Login) {
Michael Thomas 378ef72
         $total += $Login{$Msg};
Michael Thomas 378ef72
      }
Michael Thomas 378ef72
      print "$total Users logged in\n";
Michael Thomas 378ef72
   }
Michael Thomas 378ef72
}
Michael Thomas 378ef72
Michael Thomas 378ef72
if (keys %TakeChar) {
Michael Thomas 378ef72
   if ($Detail >= 5) {
Michael Thomas 378ef72
      foreach my $Msg (sort keys %TakeChar) {
Michael Thomas 378ef72
         if ($TakeChar{$Msg} > 1) {
Michael Thomas 378ef72
            print "$Msg ($TakeChar{$Msg} times)\n"
Michael Thomas 378ef72
         } else {
Michael Thomas 378ef72
            print "$Msg\n"
Michael Thomas 378ef72
         }
Michael Thomas 378ef72
      }
Michael Thomas 378ef72
   } else {
Michael Thomas 378ef72
      my $total;
Michael Thomas 378ef72
      foreach my $Msg (sort keys %TakeChar) {
Michael Thomas 378ef72
         $total += $TakeChar{$Msg};
Michael Thomas 378ef72
      }
Michael Thomas 378ef72
      print "$total characters entered the world\n";
Michael Thomas 378ef72
   }
Michael Thomas 378ef72
}
Michael Thomas 378ef72
Michael Thomas 378ef72
if (keys %DropChar) {
Michael Thomas 378ef72
   if ($Detail >= 5) {
Michael Thomas 378ef72
      foreach my $Msg (sort keys %DropChar) {
Michael Thomas 378ef72
         if ($DropChar{$Msg} > 1) {
Michael Thomas 378ef72
            print "$Msg ($DropChar{$Msg} times)\n"
Michael Thomas 378ef72
         } else {
Michael Thomas 378ef72
            print "$Msg\n"
Michael Thomas 378ef72
         }
Michael Thomas 378ef72
      }
Michael Thomas 378ef72
   } else {
Michael Thomas 378ef72
      my $total;
Michael Thomas 378ef72
      foreach my $Msg (sort keys %DropChar) {
Michael Thomas 378ef72
         $total += $DropChar{$Msg};
Michael Thomas 378ef72
      }
Michael Thomas 378ef72
      print "$total characters left the world\n";
Michael Thomas 378ef72
   }
Michael Thomas 378ef72
}
Michael Thomas 378ef72
Michael Thomas 378ef72
if (keys %Logout) {
Michael Thomas 378ef72
   if ($Detail >= 5) {
Michael Thomas 378ef72
      foreach my $Msg (sort keys %Logout) {
Michael Thomas 378ef72
         if ($Logout{$Msg} > 1) {
Michael Thomas 378ef72
            print "$Msg ($Logout{$Msg} times)\n"
Michael Thomas 378ef72
         } else {
Michael Thomas 378ef72
            print "$Msg\n"
Michael Thomas 378ef72
         }
Michael Thomas 378ef72
      }
Michael Thomas 378ef72
   } else {
Michael Thomas 378ef72
      my $total;
Michael Thomas 378ef72
      foreach my $Msg (sort keys %Logout) {
Michael Thomas 378ef72
         $total += $Logout{$Msg};
Michael Thomas 378ef72
      }
Michael Thomas 378ef72
      print "$total players logged out\n";
Michael Thomas 378ef72
   }
Michael Thomas 378ef72
}
Michael Thomas 378ef72
Michael Thomas 378ef72
exit(0);
Michael Thomas 378ef72
Michael Thomas 378ef72
# vi: shiftwidth=3 tabstop=3 syntax=perl et
Michael Thomas 378ef72