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