Check Plugin: Avaya AP2000 Access Point

Example services.cfg:

# Access Point SNMP (SSIDs) Service Definition
define service{
        use                             generic-service
        host_name                       APIckford1,APIckford2
        service_description             SSID
        is_volatile                     0
        check_period                    24x7
        max_check_attempts              3
        normal_check_interval           5
        retry_check_interval            1
        contact_groups                  nagios-admins
        notification_interval           60
        notification_period             24x7
        notification_options            c,r
        check_command                   check_ap2000!public
        }

Perl code:

#!/usr/bin/perl -w
use strict;
use Net::SNMP;
use Getopt::Long;
use Pod::Usage;

=head1 NAME

check_ap2000.pl - Show Proxim AP2000 radio SSIDs 

=head1 SYNOPSIS

	check_ap2000.pl -H host [-p community]
	
	host:      IP address of the access point
	community: Community string for host (default: public)

=head1 DESCRIPTION
                                                                                
Uses SNMP query to get the access point's SSIDs.

=head1 AUTHOR

Nigel Bruin. 2005

=cut

###############################################################################
#
# Constants and global variables

my $OutputTag = 'SSIDs:';

# SNMP Port
my $PORT = 161;

# OIDs for Proxim radio parameters
my $OID_IndexA = '1.3.6.1.4.1.11898.2.1.2.1.2.1.1.3';
my $OID_IndexB = '1.3.6.1.4.1.11898.2.1.2.1.2.1.1.4';

my $OID_RadioA = '1.3.6.1.4.1.11898.2.1.2.1.3.1.2.3.1';
my $OID_RadioB = '1.3.6.1.4.1.11898.2.1.2.1.3.1.2.4.1';

# Nagios return codes
my $NagiosOK       = 0;
my $NagiosWarning  = 1;
my $NagiosCritical = 2;
my $NagiosUnknown  = 3;

my ( $host, $community, $oid );

###############################################################################
#
# The actual query control, depending on the type.
sub snmpQuery {
    my ( $session, $result, $resultval, $query );
    ( $session, $query ) = @_;
    $result = $session->get_request( -varbindlist => [$query]);

    if (!defined($result)) {
      return;
      }
    $resultval = $result->{$query};
    return $resultval;
};

###############################################################################
#
# Main routine

GetOptions(
	"H=s" => \$host,
	"p=s" => \$community
);

# Enforce parameter defaults
if(!$community) { $community = 'public' };

# Do some command line options checking
if ( !$host ){
	pod2usage("$OutputTag Not enough arguments.\n");
	exit $NagiosUnknown;
	}

# Start the SNMP session
my ($session, $error) = Net::SNMP->session(
	    -hostname  => shift || $host,
            -community => shift || $community,
            -port      => shift || $PORT,
            -version   => 1,
            -timeout   => 2,
            -retries   => 2);

my $numSSID = 0;

if (!defined($session))
  # Persistent failure - give up.
  { print "$OutputTag CRITICAL - No response from $host \n"; exit $NagiosCritical; };

my $radioAssid = '';
my $idx = snmpQuery($session, $OID_IndexA);
if (defined($idx))
  {
  my $ssid = snmpQuery($session, $OID_RadioA);
  if (defined($ssid))
    { $radioAssid = '"'.$radioAssid.$ssid.'"'; $numSSID++ };
  };

my $radioBssid = '';
$idx = snmpQuery($session, $OID_IndexB);
if (defined($idx))
  {
  my $ssid = snmpQuery($session, $OID_RadioB);
  if (defined($ssid))
    { $radioBssid = '"'.$radioBssid.$ssid.'"'; $numSSID++ }
  };

# Generate answer
if ($numSSID == 0)
  { print "$OutputTag CRITICAL - No response from $host \n"; exit $NagiosCritical };

print "$OutputTag OK - $radioAssid  $radioBssid\n";
exit $NagiosOK;