new functionnality : if interface down, a message is printed
git-svn-id: http://svn.centreon.com/Plugins/Dev@2768 6bcd3966-0018-0410-8128-fd23d134de7e
This commit is contained in:
parent
7428a3ba9d
commit
82beffb6a2
|
@ -154,6 +154,8 @@ if ($critical <= $warning){
|
|||
##
|
||||
|
||||
my $OID_DESC =$oreon{MIB2}{IF_DESC};
|
||||
my $OID_OPERSTATUS =$oreon{MIB2}{IF_OPERSTATUS};
|
||||
my @operstatus = ("up","down","testing", "unknown", "dormant", "notPresent", "lowerLayerDown");
|
||||
|
||||
# create a SNMP session
|
||||
my ($session, $error);
|
||||
|
@ -202,17 +204,32 @@ my $OID_SPEED = $oreon{MIB2}{IF_SPEED}.".".$interface;
|
|||
|
||||
if ($opt_s) {
|
||||
my $result = $session->get_table(Baseoid => $OID_DESC);
|
||||
if (!defined($result)) {
|
||||
if (!defined($result)) {
|
||||
printf("ERROR: Description Table : %s.\n", $session->error);
|
||||
$session->close;
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
foreach my $key ( oid_lex_sort(keys %$result)) {
|
||||
}
|
||||
foreach my $key ( oid_lex_sort(keys %$result)) {
|
||||
my @oid_list = split (/\./,$key);
|
||||
my $index = pop (@oid_list) ;
|
||||
print "Interface $index :: $$result{$key}\n";
|
||||
my $interface_status = $session->get_request(-varbindlist => [$OID_OPERSTATUS.".".$index]);
|
||||
if (!defined($result)) {
|
||||
printf("ERROR: Interface Status Request : %s", $session->error);
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
exit $ERRORS{'OK'};
|
||||
print "Interface $index :: $$result{$key} :: ".$operstatus[$interface_status->{$OID_OPERSTATUS.".".$index} - 1]."\n";
|
||||
}
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
|
||||
my $interface_status = $session->get_request(-varbindlist => [$OID_OPERSTATUS.".".$interface]);
|
||||
if (!defined($interface_status)) {
|
||||
printf("ERROR: Interface Status Request : %s", $session->error);
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
if ($operstatus[$interface_status->{$OID_OPERSTATUS.".".$interface} - 1] ne "up") {
|
||||
print "Error : interface is not ready - status : ".$operstatus[$interface_status->{$OID_OPERSTATUS.".".$interface} - 1]."\n";
|
||||
exit $ERRORS{'CRITICAL'};
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue