2014-08-22 10:10:21 +02:00
|
|
|
#
|
2019-01-09 09:57:11 +01:00
|
|
|
# Copyright 2019 Centreon (http://www.centreon.com/)
|
2015-07-21 11:51:02 +02:00
|
|
|
#
|
|
|
|
# Centreon is a full-fledged industry-strength solution that meets
|
|
|
|
# the needs in IT infrastructure and application monitoring for
|
|
|
|
# service performance.
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
#
|
2014-08-22 10:10:21 +02:00
|
|
|
|
2017-02-06 11:22:59 +01:00
|
|
|
package network::f5::bigip::snmp::mode::listnodes;
|
2014-08-22 10:10:21 +02:00
|
|
|
|
|
|
|
use base qw(centreon::plugins::mode);
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
2017-06-07 14:45:21 +02:00
|
|
|
my $oid_ltmNodeAddrName = '.1.3.6.1.4.1.3375.2.2.4.1.2.1.17'; # old
|
|
|
|
my $oid_ltmNodeAddrStatusName = '.1.3.6.1.4.1.3375.2.2.4.3.2.1.7'; # new
|
2014-08-22 10:10:21 +02:00
|
|
|
|
|
|
|
sub new {
|
|
|
|
my ($class, %options) = @_;
|
|
|
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
|
|
|
bless $self, $class;
|
|
|
|
|
|
|
|
$self->{version} = '1.0';
|
|
|
|
$options{options}->add_options(arguments =>
|
|
|
|
{
|
2017-06-07 14:45:21 +02:00
|
|
|
"filter-name:s" => { name => 'filter_name' },
|
2014-08-22 10:10:21 +02:00
|
|
|
});
|
|
|
|
return $self;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub check_options {
|
|
|
|
my ($self, %options) = @_;
|
|
|
|
$self->SUPER::init(%options);
|
|
|
|
}
|
|
|
|
|
|
|
|
sub manage_selection {
|
|
|
|
my ($self, %options) = @_;
|
|
|
|
|
2017-06-07 14:45:21 +02:00
|
|
|
my $snmp_result = $self->{snmp}->get_multiple_table(oids => [ { oid => $oid_ltmNodeAddrName }, { oid => $oid_ltmNodeAddrStatusName } ], nothing_quit => 1);
|
|
|
|
|
|
|
|
my ($branch_name) = ($oid_ltmNodeAddrStatusName);
|
|
|
|
if (!defined($snmp_result->{$oid_ltmNodeAddrStatusName}) || scalar(keys %{$snmp_result->{$oid_ltmNodeAddrStatusName}}) == 0) {
|
|
|
|
($branch_name) = ($oid_ltmNodeAddrName);
|
|
|
|
}
|
|
|
|
|
|
|
|
$self->{node} = {};
|
|
|
|
foreach my $oid (keys %{$snmp_result->{$branch_name}}) {
|
|
|
|
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
|
|
|
$snmp_result->{$branch_name}->{$oid} !~ /$self->{option_results}->{filter_name}/) {
|
|
|
|
$self->{output}->output_add(long_msg => "skipping service class '" . $snmp_result->{$branch_name}->{$oid} . "'.", debug => 1);
|
2014-08-22 10:10:21 +02:00
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
2017-06-07 14:45:21 +02:00
|
|
|
$self->{node}->{$snmp_result->{$branch_name}->{$oid}} = { name => $snmp_result->{$branch_name}->{$oid} };
|
2014-08-22 10:10:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sub run {
|
|
|
|
my ($self, %options) = @_;
|
|
|
|
$self->{snmp} = $options{snmp};
|
|
|
|
|
|
|
|
$self->manage_selection();
|
2017-06-07 14:45:21 +02:00
|
|
|
foreach my $name (sort keys %{$self->{node}}) {
|
2014-08-22 10:10:21 +02:00
|
|
|
$self->{output}->output_add(long_msg => "'" . $name . "'");
|
|
|
|
}
|
|
|
|
|
|
|
|
$self->{output}->output_add(severity => 'OK',
|
|
|
|
short_msg => 'List Nodes:');
|
|
|
|
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
|
|
|
|
$self->{output}->exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
sub disco_format {
|
|
|
|
my ($self, %options) = @_;
|
|
|
|
|
|
|
|
$self->{output}->add_disco_format(elements => ['name']);
|
|
|
|
}
|
|
|
|
|
|
|
|
sub disco_show {
|
|
|
|
my ($self, %options) = @_;
|
|
|
|
$self->{snmp} = $options{snmp};
|
|
|
|
|
2017-06-07 14:45:21 +02:00
|
|
|
$self->manage_selection();
|
|
|
|
foreach my $name (sort keys %{$self->{node}}) {
|
2014-08-22 10:10:21 +02:00
|
|
|
$self->{output}->add_disco_entry(name => $name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
1;
|
|
|
|
|
|
|
|
__END__
|
|
|
|
|
|
|
|
=head1 MODE
|
|
|
|
|
2017-06-07 14:45:21 +02:00
|
|
|
List nodes.
|
2014-08-22 10:10:21 +02:00
|
|
|
|
|
|
|
=over 8
|
|
|
|
|
2017-06-07 14:45:21 +02:00
|
|
|
=item B<--filter-name>
|
2014-08-22 10:10:21 +02:00
|
|
|
|
2017-06-07 14:45:21 +02:00
|
|
|
Filter by node name.
|
2014-08-22 10:10:21 +02:00
|
|
|
|
|
|
|
=back
|
|
|
|
|
|
|
|
=cut
|