administratively up but operationally not up.
=cut
-#
-# $Id: check_interfaces,v 1.5 2000/11/29 17:12:49 sljohnson Exp $
# Register the routine with the plugin registry
$PLUGINS{'interfaces'} = \&check_interfaces;
sub check_interfaces {
my ($host ) = @_;
my ($color, $summary, $message ) = ( "green", "", "" );
- my $snmp_session;
+ my( $snmp_session, @skipped_interfaces );
+
my ($snmp_community) = $HOSTS{$host}->{'snmp_community'} ||
$HOSTS_DEFAULTS{'snmp_community'} ||
'public';
+ # Find the list of interfaces to ignore/skip
+ @skipped_interfaces = @{$HOSTS{$host}{'ignore_interfaces'}};
+ @skipped_interfaces = @{$HOSTS_DEFAULTS{'ignore_interfaces'}}
+ if( ! @skipped_interfaces );
+
+ # Append mandatory interfaces to skip
+ @skipped_interfaces = ( @skipped_interfaces,
+ @{$HOSTS_ALL{'ignore_interfaces'}} );
+
$snmp_session = SNMP_Session->open ($host, $snmp_community, 161);
if (! $snmp_session ) {
}
my $index;
+ my $redcount = 0;
foreach $index ( sort { $a <=> $b } keys %sifdesc) {
$message .= "interface $index status:\n";
$message .= "\tifDescr: $sifdesc{$index}\n";
$message .= "\tifAdminStatus: $sifadminstatus{$index}\n";
$message .= "\tifOperStatus: $sifoperstatus{$index}\n";
# If interface is not up and is admin up, we got a problem
- if ($sifoperstatus{$index} != 1 && $sifadminstatus{$index} != 1) {
- $color = "red";
+ 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;
+ }
+ }
+ }
+ $redcount++ unless $skip;
}
}
- if ($color eq "red") {
- $summary = "some interfaces are down";
+ if ($redcount > 0) {
+ $color = "red";
+ $summary = "$redcount interfaces are down";
} else {
$summary = "all interfaces up";
}
=item SNMP Community Name
-The default SNMP Community name is I<public>. To override the default name
-specify a C<snmp_ community> attribute in a host's entry in the I<%HOSTS>
-variabile of the L<spong.conf> configuration file. See the
-L<"EXAMPLES"> for a detailed example.
+The default SNMP Community name is I<public>. To provide an alternate default
+SNMP Community name add it to the
+L<$HOSTS_DEFAULTS|spong.conf/"$HOSTS_DEFAULTS"> entry in the B<spong.conf> file
+(i.e. $HOSTS_DEFAULTS{'snmp_community'} = 'secret';).
+
+To override the default name on a per host basis, specify a C<snmp_ community>
+attribute in a host's entry in the I<%HOSTS> variabile of the L<spong.conf>
+configuration file. See the L<Examples|"EXAMPLES"> section for a detailed
+example.
+
+=item Ignored Interfaces
+
+You can also specify a list of network interfaces for the B<check_interfaces>
+module to ignore. Add an 'ignore_interfaces' attribute to a host entry in
+$HOSTS with a list of network interface to ignore.
+
+A default list of interfaces to ignore is added an 'ignore_interfaces' entry
+to the $HOSTS_DEFAULTS variable. A list of interfaces to ignore in all hosts
+is created by adding an 'ignore_interfaces' entry to the $HOSTS_ALL varirable.
+See the L<Examples|"EXAMPLES> section for a detailed example.
=back
%HOSTS = ( 'hostname.my-inc.com' => { 'services' => 'interfaces',
'ip_addr' => ['192.168.13.123'],
'community' => 'local-read',
+ 'ignore_interfaces' => ['ppp1','ppp2'];
},
);
+ $HOSTS_DEFAULTS{'snmp_community'} = 'mysecret';
+
+ # Ignore the unused default intefaces on more servers
+ $HOSTS_DEFAULTS{'ignore_interfaces'} = ['et0','lan0'];
+
+ # Skip the loopback interface on the linux boxes
+ $HOSTS_ALL('ignore_interfaces} = ['lo0'];
+
=head1 SEE ALSO
L<spong-network>, L<check_snmp>,
L<spong-network Modules Template|spong-network-mod-template>,
-L<Spong Developer Guide|developer-guide>
+L<Spong Developer Guide|develop-guide>
=head1 NOTES