disable port using nagios core

An open discussion forum for obtaining help with Nagios Core. Nagios Core users of all experience levels are welcome here. Subforum have been created for the discussion of Nagios Core and Nagios Plugin development.

NOTE: The SourceForge.net mailing lists have been deprecated in favor of this forum in order to expedite support and provide additional features not available on the old mailing list.

disable port using nagios core

Postby DOkuwa » Thu Nov 09, 2017 10:42 am

I use Nagios Core and want a device not to show any status or information on a particular port of a device e.g port is down or interface is down
In other NMS we disable the port using the OID (SNMP)
Is there any way Nagios can do this
DOkuwa
 
Posts: 90
Joined: Tue Aug 15, 2017 3:54 pm

Re: disable port using nagios core

Postby npolovenko » Thu Nov 09, 2017 1:14 pm

Hello, @DOkuwa. How are you monitoring the device? Do you have separate service checks defined for each port of the device? Or are you using SNMP trap?
User avatar
npolovenko
 
Posts: 396
Joined: Mon May 15, 2017 5:00 pm

Re: disable port using nagios core

Postby DOkuwa » Thu Nov 09, 2017 4:15 pm

we are using snmp to monitor the devices
we have a check for all the ports for a group of devices but Nagios keeps reporting that a some specific port is down which is correct because they are alcatel devices which it's port cannot be disabled from the terminal
so we want nagios to exclude monitoring this specific port using the sysOID
or maybe put in in maintenance mode for this group of devices
DOkuwa
 
Posts: 90
Joined: Tue Aug 15, 2017 3:54 pm

Re: disable port using nagios core

Postby npolovenko » Fri Nov 10, 2017 10:18 am

@DOkuwa, Can you upload the snmptt.conf file from your Nagios server?
Code: Select all
/etc/snmp/snmptt.conf
Usually that configuration file defines how your trap information is processed by Nagios. So we might be able to modify it..
Also, please share with us a screenshot of your SNMP check output on Service Detail page.
User avatar
npolovenko
 
Posts: 396
Joined: Mon May 15, 2017 5:00 pm

Re: disable port using nagios core

Postby DOkuwa » Fri Nov 10, 2017 11:24 am

The first service is the actual service that monitors the port
the second service is the generic services it uses and the third is the script that the service uses
I have the snmp oid which relates to the desired port on the alcatel devices that needs to be filtered out and don't know if this can be adjusted in the script


Code: Select all
define service{
        name                            alcatel-network-ports
        service_description             Alcatel_Network_Ports
        use                             generic-service
        is_volatile                     0
        check_command                   check_alcatel_network_ports
        max_check_attempts                      3
        normal_check_interval           3
        retry_check_interval            1
        active_checks_enabled           1
        check_period                    24x7
        parallelize_check                       1
        obsess_over_service             0
        check_freshness                 0
        flap_detection_enabled          0
        process_perf_data                       0
        retain_status_information               1
        retain_nonstatus_information    0
        notification_interval           180
        notification_period             24x7
        notification_options            w,c,r
        notifications_enabled           1
        contact_groups                  Core_Team
        register                                0
}
define service{
        name                            generic-service
        service_description             generic-service
        is_volatile                     0
        max_check_attempts                      3
        normal_check_interval           5
        retry_check_interval            1
        active_checks_enabled           1
        passive_checks_enabled          0
        check_period                    24x7
        parallelize_check                       1
        obsess_over_service             0
        process_perf_data                       1
        retain_status_information               1
        retain_nonstatus_information    0
        notification_interval           60
        notification_period             24x7

Code: Select all
more check_alcatel_ports.pl
#!/usr/bin/perl

=pod

=head1 NAME

check_alcatel_ports.pl


=head1 SYNOPSIS

check_alcatel_ports.pl community-string agent


=head1 DESCRIPTION

Uses Net::SNMP to query an Alcatel 7450 VPLS switch to find status of the
network ports. Alarms critical if the ports are UP/DOWN.

=head1 NOTES

=head1 TODO

=head1 REFERENCES

TIMETRA-PORT-MIB.mib

=cut

# Modules
use strict;
use warnings;
use Net::SNMP;
use Getopt::Long;
Getopt::Long::Configure("bundling");
use lib qw( /usr/local/nagios/libexec );
use utils qw($TIMEOUT %ERRORS &print_revision &support);

# Globals
use vars qw|$PROGNAME $DEBUG $VERSION|;
$DEBUG = 0;
$VERSION = '01.00';
$PROGNAME = "$0";

my $agent;
my $comm_string;
my $ok;
my $state = $ERRORS{'OK'};
my ($opt_V, $opt_h);

# Just in case of problems, let's not hang Nagios
$SIG{'ALRM'} = sub {
     print ("ERROR: Unable to get status from $agent (alarm timeout)\n");
     exit $ERRORS{"UNKNOWN"};
};
alarm($TIMEOUT);

#Option checking
$ok = GetOptions(
                "V"   => \$opt_V,   "version"    => \$opt_V,
                "h"   => \$opt_h,   "help"       => \$opt_h,
                "H=s" => \$agent,  "hostname=s" => \$agent,
                "C=s" => \$comm_string, "community=s" => \$comm_string,
                );

unless ( $ok ) {
    exit $ERRORS{'OK'};
}

if ($opt_V) {
    exit $ERRORS{'OK'};
}

if ($opt_h) {
    exit $ERRORS{'OK'};
}

if (!$comm_string) {
    print STDERR "No community string specified!\n";
    exit $ERRORS{'UNKNOWN'};
}

unless ( utils::is_hostname($agent) ) {
    print "Invalid hostname\n";
    exit $ERRORS{"UNKNOWN"};
}

# Alcatel OIDs
my $port_name_oid = '1.3.6.1.4.1.6527.3.1.2.2.4.2.1.6';
my $port_desc_oid = '1.3.6.1.4.1.6527.3.1.2.2.4.2.1.5';
my $port_mode_oid = '1.3.6.1.4.1.6527.3.1.2.2.4.2.1.11';
my $port_admin_oid = '1.3.6.1.4.1.6527.3.1.2.2.4.2.1.37';
my $port_oper_oid = '1.3.6.1.4.1.6527.3.1.2.2.4.2.1.38';
my $port_state_oid = '1.3.6.1.4.1.6527.3.1.2.2.4.2.1.39';

my %ports;
my $answer = '';
my $error = 0;

# Initiate SNMP session
my $session = Net::SNMP->session(
              -hostname => $agent,
              -version => 'snmpv2c',
              -community => $comm_string,
              -port => 161,
              -timeout => 2,
              -retries => 1,
              -maxmsgsize => 20000,
);

# Port Name
my $table = $session->get_table( -baseoid => $port_name_oid );
if ($session->error) {
    print $session->error . "\n";
    exit(1);
}

foreach my $entry (sort keys %{$table}) {
        my $index = (split /\./, $entry)[16];
        $ports{$index} = [ $table->{$entry} ];
}

# Port Mode
$table = $session->get_table( -baseoid => $port_mode_oid );
if ($session->error) {
    print $session->error . "\n";
    exit(1);
}

foreach my $entry (sort keys %{$table}) {
        my $index = (split /\./, $entry)[16];
        $ports{$index}->[1] = $table->{$entry};
}


# Port Admin Status
$table = $session->get_table( -baseoid => $port_admin_oid );
if ($session->error) {
    print $session->error . "\n";
    exit(1);
}

foreach my $entry (sort keys %{$table}) {
        my $index = (split /\./, $entry)[16];
        $ports{$index}->[2] = $table->{$entry};
}

# Port Oper Status
$table = $session->get_table( -baseoid => $port_oper_oid );
if ($session->error) {
    print $session->error . "\n";
    exit(1);
}

foreach my $entry (sort keys %{$table}) {
        my $index = (split /\./, $entry)[16];
        $ports{$index}->[3] = $table->{$entry};
}

# Port Desc
$table = $session->get_table( -baseoid => $port_desc_oid );
if ($session->error) {
    print $session->error;
    exit(1);
}

foreach my $entry (sort keys %{$table}) {
        my $index = (split /\./, $entry)[16];
        $ports{$index}->[4] = $table->{$entry};
}

# Port State
$table = $session->get_table( -baseoid => $port_state_oid );
if ($session->error) {
    print $session->error;
    exit(1);
}

foreach my $entry (sort keys %{$table}) {
        my $index = (split /\./, $entry)[16];
        $ports{$index}->[5] = $table->{$entry};
}


foreach my $port (sort keys %ports) {

    my $name = $ports{$port}->[0];
    my $desc = $ports{$port}->[4];
    my $mode = $ports{$port}->[1];
    my $admin = $ports{$port}->[2];
    my $oper = $ports{$port}->[3];
        my $port_state = $ports{$port}->[5];


# Skip if not network port
    if ($mode != 2) {
        next;
    }

# Skip if admin down
    elsif ($admin == 3) {
        next;
    }

# Skip if state is 'ghost' (port provisioned by not physically present)
    elsif ($port_state == 2){
        next;
        }

# Alarm if oper down
    elsif ($oper != 2) {
        $error = 1;
        $state = $ERRORS{'CRITICAL'};
        $answer .= "[$desc OperStatus down] ";
        next;
    }

}

if (!$error) {
    $answer .= "All ports OK.";
    print $answer;
}

else {
    print "$answer";
}

exit $state;




Last edited by dwhitfield on Fri Nov 10, 2017 3:50 pm, edited 1 time in total.
Reason: breaking up the code block since it's two different things
DOkuwa
 
Posts: 90
Joined: Tue Aug 15, 2017 3:54 pm

Re: disable port using nagios core

Postby npolovenko » Fri Nov 10, 2017 12:03 pm

@DOkuwa, I'm not a pro at programming but I think you could add a new else if statement to the script to filter out that particular port based on some criteria? I haven't seen the actual output of this script so it's hard to tell. As an option, you could email customer support for a custom development.
User avatar
npolovenko
 
Posts: 396
Joined: Mon May 15, 2017 5:00 pm

Re: disable port using nagios core

Postby DOkuwa » Fri Nov 10, 2017 12:34 pm

yes this is true
I will need to figure this out
DOkuwa
 
Posts: 90
Joined: Tue Aug 15, 2017 3:54 pm

Re: disable port using nagios core

Postby dwhitfield » Fri Nov 10, 2017 3:53 pm

I'm not seeing any references online to this plugin. Where did you get it from? Did it originally have a different name? Is it just something someone in your organization wrote? I ask because there might be newer versions with the features you want.
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
dwhitfield
The Doctor
 
Posts: 3963
Joined: Wed Sep 21, 2016 10:29 am
Location: Nagios Enterprises, LLC

Re: disable port using nagios core

Postby DOkuwa » Fri Nov 10, 2017 4:41 pm

i have not seen any plugin for this but i might need to modify the check_alcatel_ports.pl
This request has been ordered by the network team as the alarms caused by this network port down is flooding their mails
and hence this needs to be removed/disabled
DOkuwa
 
Posts: 90
Joined: Tue Aug 15, 2017 3:54 pm

Re: disable port using nagios core

Postby tacolover101 » Mon Nov 13, 2017 1:30 am

you need to modify the plugin, and build logic to handle the returned message properly.
User avatar
tacolover101
 
Posts: 326
Joined: Mon Apr 10, 2017 11:55 am

Next

Return to Nagios Core

Who is online

Users browsing this forum: No registered users and 10 guests