my $index;
my $redcount = 0;
foreach $index ( sort { $a <=> $b } keys %sifdesc) {
- $message .= "interface $index status:\n";
- $message .= "\tifDescr: $sifdesc{$index}\n";
- $message .= "\tifType: $siftype{$index}\n";
- $message .= "\tifAdminStatus: $sifadminstatus{$index}\n";
- $message .= "\tifOperStatus: $sifoperstatus{$index}\n";
+ my ($rstart,$rend) = ();
+ my $inrange = 0;
# If interface is not up and is admin up, we got a problem
if ($sifoperstatus{$index} != 1 && $sifadminstatus{$index} == 1) {
my $skip = 0;
if( @skipped_interfaces ) {
foreach my $intf (@skipped_interfaces) {
- if( $sifdesc{$index} eq $intf ) {
- $skip = 1; last;
+ # handle ranges in interface to ignore value
+ if ($intf =~ /(\d+)-(\d+)/) {
+ $rstart = $1;
+ $rend = $2;
+ }
+
+ ($inrange) = ( ($index >= $rstart) && ($index <= $rend) ) if (defined($rstart) && defined($rend));
+ debug("$rstart - $rend [$index] ($inrange)");
+
+ if( ($sifdesc{$index} eq $intf) || ($index eq $intf) || ($inrange) ) {
+ $skip = 1; last; $inrange = 0;
}
}
}
$redcount++ unless $skip;
+
+ if (!$skip) {
+ $message .= "interface $index status:\n";
+ $message .= "\tifDescr: $sifdesc{$index}\n";
+ $message .= "\tifType: $siftype{$index}\n";
+ $message .= "\tifAdminStatus: $sifadminstatus{$index}\n";
+ $message .= "\tifOperStatus: $sifoperstatus{$index}\n";
+ }
}
}
if ($redcount > 0) {
$color = "red";
- $summary = "$redcount interfaces are down";
+ if ($redcount == 1) {
+ $summary = "$redcount interface is down";
+ } else {
+ $summary = "$redcount interfaces are down";
+ }
} else {
$summary = "all interfaces up";
}
%HOSTS = ( 'hostname.my-inc.com' => { 'services' => 'interfaces',
'ip_addr' => ['192.168.13.123'],
'community' => 'local-read',
- 'ignore_interfaces' => ['ppp1','ppp2'];
+ 'ignore_interfaces' => ['ppp1','ppp2', '5-7'];
},
);