You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #!/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. use strict;
  9. my $debug = $ENV{'LOGWATCH_DEBUG'} || 0;
  10. my $detail = $ENV{'LOGWATCH_DETAIL_LEVEL'} || 0;
  11. my $debugcounter = 1;
  12. my %hostapd;
  13. my @unmatched;
  14. if ($debug >= 5) {
  15. print STDERR "\n\nDEBUG: Inside HOSTAPD Filter\n\n";
  16. }
  17. while (defined(my $line = <STDIN>)) {
  18. if ($debug >= 5) {
  19. print STDERR "DEBUG($debugcounter): $line";
  20. $debugcounter++;
  21. }
  22. chomp($line);
  23. if (my ($iface,$mac,$layer,$details) = ($line =~ /(.*?): STA (.*?) (.*?): (.*?)$/i)) {
  24. unless ($detail == 10) {
  25. # collapse association events
  26. $details =~ s/^(associated) .*$/$1/i;
  27. }
  28. $hostapd{$iface}->{$mac}->{$layer}->{$details}++;
  29. } else {
  30. push @unmatched, "$line\n";
  31. }
  32. }
  33. if (keys %hostapd) {
  34. foreach my $iface (sort keys %hostapd) {
  35. print "Interface $iface:\n";
  36. foreach my $mac (sort keys %{$hostapd{$iface}}) {
  37. print " Client MAC Address $mac:\n";
  38. foreach my $layer (sort keys %{$hostapd{$iface}->{$mac}}) {
  39. print " $layer:\n";
  40. foreach my $details (sort keys %{$hostapd{$iface}->{$mac}->{$layer}}) {
  41. print " $details";
  42. my $count = $hostapd{$iface}->{$mac}->{$layer}->{$details};
  43. if ($count > 1) {
  44. print ": " . $count . " Times";
  45. }
  46. print "\n";
  47. }
  48. }
  49. }
  50. }
  51. }
  52. if ($#unmatched >= 0) {
  53. print "\n**Unmatched Entries**\n";
  54. print @unmatched;
  55. }
  56. exit(0);