OSPF
Kermito le kermit
angeolivier2003 at yahoo.fr
Tue Jul 15 11:42:04 CEST 2008
hello all,
i configure my cisco router
router ospf 1
network 10.1.3.0 0.255.255.255 area 1
when i lunch ./check_ospf.pl 10.1.3.133 nothing work help me please
my ospf.pl
#!/usr/bin/perl
#########################################################################
# SCRIPT TO CHECK OSPF neighbors status on a router. #
#-----------------------------------------------------------------------#
# Version 1.00 (16-09-2002) #
# - First release #
# #
# #
# #
# #
#########################################################################
use Net::SNMP(qw(oid_lex_sort));
# use warnings;
use strict;
#############################
# Declaration of variables. #
#############################
my $community = "public";
my $port = 161;
my $version = "v2c"; Uncomment to use with Version 2 SNMP
my $version = "v1";
my $timeout = 20; # seconds
my $retries = 2; # times
my $ospfstate = ".1.3.6.1.2.1.14.10.1.6"; # ospfNbrState (Integer)
my $localaddr = ".1.3.6.1.2.1.14.10.1.1"; # ospfNbrIpAddr (IpAddress)
my $remoteaddr = ".1.3.6.1.2.1.14.10.1.3"; # ospfNbrRtrId (IpAddress)
my $ospfstatus = ".1.3.6.1.2.1.14.10.1.9"; # ospfNBMANbrStatus (Integer)
my $session;
my $error;
my %DataTable;
my $tmp;
my $pctwarning = 98; # Minimum percent of Neighbors Established before a warning is generated.
my $pctalert = 75; # Minimum percent of Neighbors Establisted before an alert is generated.
# Get the ipaddress from the parameters.
# --------------------------------------
my $arg_router = $ARGV[0];
# Get the data from the router.
# -----------------------------
# Open SNMP session on the router.
($session, $error) = Net::SNMP->session( -hostname => $arg_router,
-community => $community,
-port => $port,
-version => $version,
-timeout => $timeout,
-retries => $retries );
# Exit if no session could be opened.
if (!defined ($session)) {
print "Error\n";
exit 1;
}
# Get the Neighbor Status.
# ------------------
my %OSPFStatus = &snmptableget($ospfstatus);
my %LocalIp = &snmptableget($localaddr);
my %RemoteIp = &snmptableget($remoteaddr);
my %OSPFState = &snmptableget($ospfstate);
# Calculate the Neighbor Data.
my $TotalNeighbor = scalar (keys %OSPFState);
if ($TotalNeighbor != 0) {
my $Down=0;
my $Attempt=0;
my $Init=0;
my $TwoWay=0;
my $ExchangeStart=0;
my $Exchange=0;
my $Loading=0;
my $Full=0;
foreach $tmp (sort keys %OSPFState) {
# Neighbors Down
if ($OSPFState{$tmp} == 1) {
$Down++;
}
# Neighbors Attempt
if ($OSPFState{$tmp} == 2) {
$Attempt++;
}
# Neighbors Init
if ($OSPFState{$tmp} == 3) {
$Init++;
}
# Neighbors TwoWay
if ($OSPFState{$tmp} == 4) {
$TwoWay++;
}
# Neighbors ExchangeStart
if ($OSPFState{$tmp} == 5) {
$ExchangeStart++;
}
# Neighbors Exchange
if ($OSPFState{$tmp} == 6) {
$Exchange++;
}
# Neighbors Loading
if ($OSPFState{$tmp} == 7) {
$Loading++;
}
# Neighbors Full
if ($OSPFState{$tmp} == 8) {
$Full++;
}
}
# Print the data.
# ---------------
my $msgcolor;
my $pctDown = int (($Down / $TotalNeighbor) * 100);
my $pctAttempt = int (($Attempt / $TotalNeighbor) * 100);
my $pctInit = int (($Init / $TotalNeighbor) * 100);
my $pctTwoWay = int (($TwoWay / $TotalNeighbor) * 100);
my $pctExchangeStart = int (($ExchangeStart / $TotalNeighbor) * 100);
my $pctExchange = int (($Exchange / $TotalNeighbor) * 100);
my $pctLoading = int (($Loading / $TotalNeighbor) * 100);
my $pctFull = int (($Full / $TotalNeighbor) * 100);
my $pctTotal = int ($pctFull + $pctTwoWay);
if ($pctTotal > $pctwarning) {
$msgcolor = "green";
}
if ($pctTotal <= $pctalert) {
$msgcolor = "red";
}
if ($pctTotal <= $pctwarning) {
$msgcolor = "yellow";
}
if (!$msgcolor) {
$msgcolor = "purple";
}
print "$msgcolor\n";
print "<br> <br>";
print "<table border=\"1\">";
print "<tr> <td> Number of Neighbors </td> <td> $TotalNeighbor </td> </tr>";
print "<tr> <td> Neighbor Down </td> <td> $Down ($pctDown\%) </td> </tr>";
print "<tr> <td> Neighbor Attempt </td> <td> $Attempt ($pctAttempt\%) </td> </tr>";
print "<tr> <td> Neighbor Init </td> <td> $Init ($pctInit\%) </td> </tr>";
print "<tr> <td> Neighbor TwoWay </td> <td> $TwoWay ($pctTwoWay\%) </td> </tr>";
print "<tr> <td> Neighbor ExchangeStart </td> <td> $ExchangeStart ($pctExchangeStart\%) </td> </tr>";
print "<tr> <td> Neighbor Exchange </td> <td> $Exchange ($pctExchange\%) </td> </tr>";
print "<tr> <td> Neighbor Loading </td> <td> $Loading ($pctLoading\%) </td> </tr>";
print "<tr> <td> Neighbor Full </td> <td> $Full ($pctFull\%) </td> </tr>";
print "</table>";
print "<br> <small> Total may not equal 100% </small> <br>";
print "<br> Table for neighbor NOT full <br>";
print "<table border=\"1\">";
print "<tr> <th> Source </th> <th> Dest </th> <th> Status </th> </tr>";
foreach $tmp (sort keys %OSPFState) {
if ($OSPFState{$tmp} != "8") {
my $Status = &getstatus($OSPFState{$tmp});
print "<tr> <td> $LocalIp{$tmp} </td> <td> $RemoteIp{$tmp} </td> <td> $Status </td> </tr>";
}
}
print "</table>";
} else {
print "purple\n";
print "<br>Error while fetching data or no OSPF data found...\n";
}
###########################
# SUBROUTINES START HERE. #
###########################
sub snmptableget ($) {
my $snmpvar = shift;
my $index;
my %snmpresult;
my $response = $session->get_table($snmpvar);
foreach (keys %snmpresult) { delete $snmpresult{$_}; } # old values need to be deleted.
if (defined ($response)) {
foreach (oid_lex_sort(keys(%{$response}))) {
$snmpresult{$_} = $response->{$_};
}
}
foreach $index (sort keys %snmpresult) {
$index =~ /$snmpvar\./;
$DataTable{$'} = $snmpresult{$index};
}
return (%DataTable);
}
sub getstatus($) {
return {
'1' => 'Down'
,'2' => 'Attempt'
,'3' => 'Init'
,'4' => 'TwoWay'
,'5' => 'ExchangeStart'
,'6' => 'Established'
,'7' => 'Loading'
,'8' => 'Full'
}->{(shift)};
}
C'est pas parce que c'est difficile qu'on n'ose pas,
c'est parce qu'on ose pas que c'est difficile !
----- Message d'origine ----
De : Alex Dehaini <alexdehaini at gmail.com>
À : Ange AMBEMOU <angeolivier2003 at yahoo.fr>; Nagios Users Mailinglist <nagios-users at lists.sourceforge.net>
Envoyé le : Vendredi, 11 Juillet 2008, 11h32mn 05s
Objet : Re: [Nagios-users] OSPF
Yes it is. Check the nagiosexchange site for this plugin.
Lex
On Fri, Jul 11, 2008 at 10:29 AM, Ange AMBEMOU <angeolivier2003 at yahoo.fr> wrote:
helo all,
i want to know if is possible to nagios to check the OSPF on router thanks
________________________________
Envoyé avec Yahoo! Mail.
Une boite mail plus intelligente.
-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue.
::: Messages without supporting info will risk being sent to /dev/null
--
Alex Dehaini
Developer
Team - www.konolabs.com
Site - www.alexdehaini.com
Email - alexdehaini at gmail.com
_____________________________________________________________________________
Envoyez avec Yahoo! Mail. Une boite mail plus intelligente http://mail.yahoo.fr
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.monitoring-lists.org/archive/users/attachments/20080715/6e68df30/attachment.html>
-------------- next part --------------
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
-------------- next part --------------
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue.
::: Messages without supporting info will risk being sent to /dev/null
More information about the Users
mailing list