blob: 97b24ef6e1b84b1b3d986eeae6ca09c1b096dbad [file] [log] [blame]
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001#!/usr/bin/perl -w
2#
3# Logwatch script for hostapd
4#
5# Copyright 2005 Henrik Brix Andersen <brix@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
9use strict;
10
11my $debug = $ENV{'LOGWATCH_DEBUG'} || 0;
12my $detail = $ENV{'LOGWATCH_DETAIL_LEVEL'} || 0;
13my $debugcounter = 1;
14
15my %hostapd;
16my @unmatched;
17
18if ($debug >= 5) {
19 print STDERR "\n\nDEBUG: Inside HOSTAPD Filter\n\n";
20}
21
22while (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
40if (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
60if ($#unmatched >= 0) {
61 print "\n**Unmatched Entries**\n";
62 print @unmatched;
63}
64
65exit(0);