This is a Nagios helper utility I wrote to allow Check_wap to be more efficient. It runs on a 5 minute cron.
The point is to poll your Nortel WLAN 2270-based or Airespace WAPs and build a list of what's there. There are some things you need to configure in the script.
- $fullFile - This should be set to the file that Check_wap will look for the WAPs
- $tempFile - Some swap space
- chdir("/home/cricket/wlan"); - You need to replace the path with the path to your mibs
- @WLANSS = ( ); - This will be a list of IP interfaces for your 2270's.
- $READ = "public"; - This will be your SNMP read community.
#!/usr/bin/perl -w
my $fullFile="/usr/local/netcon/var/waps.txt";
my $tempFile="/tmp/waps";
my $READ = "public";
my @WLANSS = (
'10.0.0.1',
'10.0.0.2',
'10.0.0.3',
);
my @lines;
my %waps;
use File::Copy;
chdir("/home/cricket/wlan");
my @namecrap;
for(@WLANSS) {
# Get the names
push @namecrap, `/usr/bin/snmpwalk -m MIB:./BSN-REF-MIB:./WSS2270-SW20-switching.mib:./WSS2270-SW20-wireless.mib -v 2c -O fn -c $READ $_ AIRESPACE-WIRELESS-MIB::bsnAPName`;
}
chomp @nameCrap;
my $c=0;
while($c < @nameCrap) {
unless($nameCrap[$c] =~ /^\./) { $c++; next; }
#.1.3.6.1.4.1.14179.2.2.1.1.3.0.11.133.11.210.176 = STRING: "Satterlee_104"
my($oid,$name)=split(/\s\=\s/,$nameCrap[$c]);
$name =~ s/^STRING: //;
$name =~ s/\"//g; # "
$waps{$name}=1;
$c++;
}
unless(@ARGV) {
# build current list
open(FF,">$tempFile");
print FF join("\n",sort(keys(%waps))),"\n";
close FF;
copy("$tempFile","$fullFile");
} elsif($ARGV[0] eq "WAP") {
if(exists($waps{$ARGV[2]})) {
printf("WAP OK - 2");
exit(0);
} else {
printf("WAP CRITICAL - Down");
exit(2);
}
} else {
print join("\n",sort(keys(%waps))),"\n";
warn scalar(keys(%waps)),"\n";
}