SourceForge.net Logo

F.16. syslog:/etc/log.d/scripts/services/hostapd

#!/usr/bin/perl
# GPL $Id: hostapd,v 1.3 2005/03/20 22:59:30 cvonk Exp $
# script for SISO logwatch for service hostapd
# 

$Show          = $ENV{'hostapd_show'} || 1;
$ShowUnmatched = $ENV{'hostapd_show_unmatched'} || 1;

while (defined($ThisLine = <STDIN>)) {

    if ( ($MAC,$Layer,$Details) = 
	 ($ThisLine =~ /ath0: STA (.*?) (.*?): (.*?)$/i ) ) {

	$HOSTAPD->{$MAC}->{$Layer}->{$Details}++;

    } else {
	# Report any unmatched entries...
	push @OtherList,$ThisLine;
    }
}

if ($Show) {
    if (keys %{$HOSTAPD}) {
	foreach	$MAC (sort {$a cmp $b} keys %{$HOSTAPD}) {
	    print "\n" . $MAC . "\n";
	    foreach $Layer (sort {$a cmp $b} keys %{$HOSTAPD->{$MAC}}) {
		print "\t" . $Layer . "\n";
		foreach $Details (sort {$a cmp $b} keys %{$HOSTAPD->{$MAC}->{$Layer}}) {
		    print "\t\t" . $Details;
		    $count = $HOSTAPD->{$MAC}->{$Layer}->{$Details};
		    if ( $count > 1 ) {
			print " (" . $count . " times)";
		    } 
		    print "\n";
		}
	    }
	}
    }
}

if (($#OtherList >= 0) and ($ShowUnmatched)) {
   print "\n**Unmatched Entries**\n";
   print @OtherList;
}

exit(0);
# 

Example F.16. syslog:/etc/log.d/scripts/services/hostapd