Check wap
From M@Wiki

Main Page | About | Help | FAQ | Special pages | Log in

Categories: Perl | Nagios
Printable version | Disclaimers | Privacy policy


This is a Nagios check utility to check the status of your Nortel WLAN 2270-based or Airespace WAPs. There are some things you need to configure in the script.

  • chdir("/home/cricket/wlan"); - You need to replace the path with the path to your mibs
  • $LIVE=0; - If this is set to 1, the checker will check your 2270's LIVE. This is fine, as long as you understand this statement. If set to 0, then:
  • $UNLIVEFILE="/usr/local/netcon/var/waps.txt - If you're not checking live, then this is the path to a file that lists off the WAPs that are up. This is built using my Get_waps script.
  • @WLANSS = ( ); - If $LIVE, this will be a list of IP interfaces for your 2270's.
  • $READ = "public"; - If $LIVE, this will be your SNMP read community.



use strict;
use lib "/usr/local/nagios/libexec" ;
use utils qw($TIMEOUT %ERRORS &print_revision &support);
use vars qw($PROGNAME);
use Getopt::Long;
use vars qw($opt_V $opt_h $opt_C $opt_H);

$PROGNAME = "check_wap";
sub print_help ();
sub print_usage ();

$ENV{'PATH'}='';
$ENV{'BASH_ENV'}='';
$ENV{'ENV'}='';

Getopt::Long::Configure('bundling');
GetOptions
        ("V"   => \$opt_V, "version"    => \$opt_V,
         "h"   => \$opt_h, "help"       => \$opt_h,
         "H=s" => \$opt_H, "hostname=s" => \$opt_H);

if ($opt_V) {
        print_revision($PROGNAME,'$Revision: 1.4 $'); #'
        exit $ERRORS{'OK'};
}

if ($opt_h) {
        print_help();chdir("/home/cricket/wlan");
        exit $ERRORS{'OK'};
}

$opt_H = shift unless ($opt_H);
print_usage() unless ($opt_H);
my $host = $opt_H;
print_usage() unless ($host);


# This is where the MIB files are
chdir("/home/cricket/wlan");

my $FOUND=0;
my @snmpcrap;

# if($LIVE), then the WLAN Security Switches will be polled for their lists, the
# lists will be be checked for a WAP, and that is that. Not very resource friendly if
# you have dozens of WAPs (we have 72).
# So, if(!$LIVE), a file is consulted ($UNLIVEFILE), and if the name is in that file, all
# is good. If not, well, all is bad. The file can be generated by the getWaps.pl program.
my $LIVE=0;
my $UNLIVEFILE="/usr/local/netcon/var/waps.txt";

if($LIVE) {
	# Go getum, tiger
	
	# In case you have multiple WLAN Security Switches
	my @WLANSS=(
			'10.0.0.1',
			'10.0.0.2',
                        '10.0.0.3',
			);
	
	# Your SNMP Read community		
	my $READ="public";
			
	for(@WLANSS) {
		push(@snmpcrap,`/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`);
	}

	for(@snmpcrap) {
		chomp;
		my $crapline=$_;
		unless($crapline =~ /^\./) { 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/,$crapline);	
		$name =~ s/^STRING: //;
		$name =~ s/\"//g; # "
		if($host eq $name) { $FOUND=1; last; }
	}
} else {
	# Parse a file. WAY more reasonable for large installations.
	open(ULF,"<$UNLIVEFILE");
	while(<ULF>) {
		chomp;
		if($host eq $_) { $FOUND=1; last; }
	}
	close ULF;
}

if($FOUND) {
	printf("WAP OK - 2");
	exit(0);
} else {
	printf("WAP CRITICAL - Down");
	exit(2);
}


sub print_usage () {
        print "Usage: $PROGNAME -H <host>\n";
        exit(0);
}

sub print_help () {
        print_revision($PROGNAME,'$Revision: 1.4 $');
        print "Check the status of your Nortel WLAN 2270-based or Airespace WAP\n";
        print "Copyright (c) 2005 Matthew Keller\n";
        print "\n";
        print_usage();
        print "\n";
        print "<host> = High-level name of the WAP (bsnAPName).\n\n";
        support();
}

Retrieved from "http://mattwork.potsdam.edu/projects/wiki/index.php/Check_wap"

This page has been accessed 3,211 times. This page was last modified 14:29, 11 August 2006.