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