1 #!/usr/bin/perl -w 2 # 3 # Logwatch script for hostapd 4 # 5 # Copyright 2005 Henrik Brix Andersen <brix (at] gentoo.org> 6 # Distributed under the terms of the GNU General Public License v2 7 # Alternatively, this file may be distributed under the terms of the BSD License 8 9 use strict; 10 11 my $debug = $ENV{'LOGWATCH_DEBUG'} || 0; 12 my $detail = $ENV{'LOGWATCH_DETAIL_LEVEL'} || 0; 13 my $debugcounter = 1; 14 15 my %hostapd; 16 my @unmatched; 17 18 if ($debug >= 5) { 19 print STDERR "\n\nDEBUG: Inside HOSTAPD Filter\n\n"; 20 } 21 22 while (defined(my $line = <STDIN>)) { 23 if ($debug >= 5) { 24 print STDERR "DEBUG($debugcounter): $line"; 25 $debugcounter++; 26 } 27 chomp($line); 28 29 if (my ($iface,$mac,$layer,$details) = ($line =~ /(.*?): STA (.*?) (.*?): (.*?)$/i)) { 30 unless ($detail == 10) { 31 # collapse association events 32 $details =~ s/^(associated) .*$/$1/i; 33 } 34 $hostapd{$iface}->{$mac}->{$layer}->{$details}++; 35 } else { 36 push @unmatched, "$line\n"; 37 } 38 } 39 40 if (keys %hostapd) { 41 foreach my $iface (sort keys %hostapd) { 42 print "Interface $iface:\n"; 43 foreach my $mac (sort keys %{$hostapd{$iface}}) { 44 print " Client MAC Address $mac:\n"; 45 foreach my $layer (sort keys %{$hostapd{$iface}->{$mac}}) { 46 print " $layer:\n"; 47 foreach my $details (sort keys %{$hostapd{$iface}->{$mac}->{$layer}}) { 48 print " $details"; 49 my $count = $hostapd{$iface}->{$mac}->{$layer}->{$details}; 50 if ($count > 1) { 51 print ": " . $count . " Times"; 52 } 53 print "\n"; 54 } 55 } 56 } 57 } 58 } 59 60 if ($#unmatched >= 0) { 61 print "\n**Unmatched Entries**\n"; 62 print @unmatched; 63 } 64 65 exit(0); 66