Blame logwatch.script.crossfire
|
Michael Thomas |
75390c7 |
##########################################################################
|
|
Michael Thomas |
75390c7 |
##########################################################################
|
|
Michael Thomas |
75390c7 |
|
|
Michael Thomas |
75390c7 |
use strict;
|
|
Michael Thomas |
75390c7 |
|
|
Michael Thomas |
75390c7 |
my ($junk, $Msg, $total);
|
|
Michael Thomas |
75390c7 |
my %Action = ();
|
|
Michael Thomas |
75390c7 |
my %Start = ();
|
|
Michael Thomas |
75390c7 |
my %Login = ();
|
|
Michael Thomas |
75390c7 |
my %TakeChar = ();
|
|
Michael Thomas |
75390c7 |
my %DropChar = ();
|
|
Michael Thomas |
75390c7 |
my %Logout = ();
|
|
Michael Thomas |
75390c7 |
|
|
Michael Thomas |
75390c7 |
my $Detail = $ENV{'LOGWATCH_DETAIL_LEVEL'} || 0;
|
|
Michael Thomas |
75390c7 |
|
|
Michael Thomas |
75390c7 |
# Interesting events:
|
|
Michael Thomas |
75390c7 |
# 05/22/07 20:46:47 [Info] LOGIN: New player named wart from ip 192.168.1.7
|
|
Michael Thomas |
75390c7 |
# 05/22/07 21:01:12 [Info] LOGIN: Player named wart from ip 192.168.1.7
|
|
Michael Thomas |
75390c7 |
# 05/22/07 21:00:34 [Info] LOGOUT: Player named wart from ip 192.168.1.7
|
|
Michael Thomas |
75390c7 |
|
|
Michael Thomas |
75390c7 |
|
|
Michael Thomas |
75390c7 |
while (defined(my $ThisLine = <STDIN>)) {
|
|
Michael Thomas |
75390c7 |
chomp($ThisLine);
|
|
Michael Thomas |
75390c7 |
if ( ($Msg) = ($ThisLine =~ /LOGIN: (.*)$/)) {
|
|
Michael Thomas |
75390c7 |
$Login{$Msg}++;
|
|
Michael Thomas |
75390c7 |
}
|
|
Michael Thomas |
75390c7 |
if ( ($Msg) = ($ThisLine =~ /LOGOUT: (.*)$/)) {
|
|
Michael Thomas |
75390c7 |
$Logout{$Msg}++;
|
|
Michael Thomas |
75390c7 |
}
|
|
Michael Thomas |
75390c7 |
}
|
|
Michael Thomas |
75390c7 |
|
|
Michael Thomas |
75390c7 |
if (keys %Login) {
|
|
Michael Thomas |
75390c7 |
if ($Detail >= 5) {
|
|
Michael Thomas |
75390c7 |
foreach my $Msg (sort keys %Login) {
|
|
Michael Thomas |
75390c7 |
if ($Login{$Msg} > 1) {
|
|
Michael Thomas |
75390c7 |
print "$Msg ($Login{$Msg} times)\n"
|
|
Michael Thomas |
75390c7 |
} else {
|
|
Michael Thomas |
75390c7 |
print "$Msg\n"
|
|
Michael Thomas |
75390c7 |
}
|
|
Michael Thomas |
75390c7 |
}
|
|
Michael Thomas |
75390c7 |
} else {
|
|
Michael Thomas |
75390c7 |
my $total;
|
|
Michael Thomas |
75390c7 |
foreach my $Msg (sort keys %Login) {
|
|
Michael Thomas |
75390c7 |
$total += $Login{$Msg};
|
|
Michael Thomas |
75390c7 |
}
|
|
Michael Thomas |
75390c7 |
print "$total Users logged in\n";
|
|
Michael Thomas |
75390c7 |
}
|
|
Michael Thomas |
75390c7 |
}
|
|
Michael Thomas |
75390c7 |
|
|
Michael Thomas |
75390c7 |
if (keys %Logout) {
|
|
Michael Thomas |
75390c7 |
if ($Detail >= 5) {
|
|
Michael Thomas |
75390c7 |
foreach my $Msg (sort keys %Logout) {
|
|
Michael Thomas |
75390c7 |
if ($Logout{$Msg} > 1) {
|
|
Michael Thomas |
75390c7 |
print "$Msg ($Logout{$Msg} times)\n"
|
|
Michael Thomas |
75390c7 |
} else {
|
|
Michael Thomas |
75390c7 |
print "$Msg\n"
|
|
Michael Thomas |
75390c7 |
}
|
|
Michael Thomas |
75390c7 |
}
|
|
Michael Thomas |
75390c7 |
} else {
|
|
Michael Thomas |
75390c7 |
my $total;
|
|
Michael Thomas |
75390c7 |
foreach my $Msg (sort keys %Logout) {
|
|
Michael Thomas |
75390c7 |
$total += $Logout{$Msg};
|
|
Michael Thomas |
75390c7 |
}
|
|
Michael Thomas |
75390c7 |
print "$total players logged out\n";
|
|
Michael Thomas |
75390c7 |
}
|
|
Michael Thomas |
75390c7 |
}
|
|
Michael Thomas |
75390c7 |
|
|
Michael Thomas |
75390c7 |
exit(0);
|
|
Michael Thomas |
75390c7 |
|
|
Michael Thomas |
75390c7 |
# vi: shiftwidth=3 tabstop=3 syntax=perl et
|
|
Michael Thomas |
75390c7 |
|