X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=wap-scan.pl;h=75550ff4b315930afefa0054b7747d7baf89fd3f;hb=1ba177c451b5bc0cbf87743bc8d897f4efed5b1b;hp=be5a6e2e08e683dcec2af60ac349ba09d334909c;hpb=34c4916d8402f056ecbbce249bd25e00cbb25791;p=dell-switch diff --git a/wap-scan.pl b/wap-scan.pl index be5a6e2..75550ff 100755 --- a/wap-scan.pl +++ b/wap-scan.pl @@ -4,6 +4,11 @@ use strict; use autodie; use Data::Dump qw(dump); +open(my $dot, '>', '/dev/shm/wap-scan.dot'); +print $dot qq|digraph wap { + +|; + my $stat; sub path2hostname { @@ -41,7 +46,7 @@ foreach my $scan ( glob "/dev/shm/wap/*iw_*_scan" ) { if ( m/^BSS\s(\S+)\(on\s(\S+)\)/ ) { $bss = $1; $stat->{$hostname}->{$bss} = { - if => $2, + #if => $2, }; } elsif ( m/^\s*(freq|signal|SSID):\s*(.+)/ ) { @@ -53,13 +58,33 @@ foreach my $scan ( glob "/dev/shm/wap/*iw_*_scan" ) { warn "# stat = ", dump($stat); +sub _dot { + my $t = shift; + $t =~ s/\W+/_/g; + return $t; +} + +my $ap_freq; +my $freq_count; +my @edges; foreach my $ap ( keys %$stat ) { foreach my $bss ( keys %{ $stat->{$ap} } ) { + my $freq = $stat->{$ap}->{$bss}->{freq}; if ( exists $mac2hostname->{$bss} ) { my $remote = join(',', keys %{ $mac2hostname->{$bss} } ); print "$ap $remote "; + my $len = $stat->{$ap}->{$bss}->{signal} || die "no signal in ",dump($stat->{$ap}->{$bss}); + $len =~ s/ \w+//; + $len = abs($len); + if ( $stat->{$ap}->{$bss}->{SSID} =~ m/eduroam/i && $freq =~ m/^24/ && $len < 90 ) { # FIXME + $freq_count->{$freq}++; + printf $dot qq| %s -> %s:%s [ len = %d, label = "%s" ];\n|, + _dot($ap),_dot($remote),$freq, $len, $len; + } + $ap_freq->{ $remote }->{local}->{$freq}++; } else { + $ap_freq->{ $ap }->{external}->{$freq}++; print "$ap EXTERNAL "; } my $info = dump( $stat->{$ap}->{$bss} ); @@ -68,6 +93,17 @@ foreach my $ap ( keys %$stat ) { } } +warn "# freq_count = ",dump($freq_count); +warn "# ap_freq = ",dump($ap_freq); + +foreach my $node ( sort keys %$ap_freq ) { + print $dot _dot($node), ' [ shape=record, label="', $node, '|{', join('|', map { "<$_>$_ " . $ap_freq->{$node}->{local}->{$_} } sort keys %{ $ap_freq->{$node}->{local} }), '}" ];', "\n"; + +} + +print $dot qq| +} +|; __END__ ls /dev/shm/wap/*iw_*_scan | while read file ; do