| 1 |
# |
| 2 |
# Copyright 2024 Centreon (http://www.centreon.com/) |
| 3 |
# |
| 4 |
# Centreon is a full-fledged industry-strength solution that meets |
| 5 |
# the needs in IT infrastructure and application monitoring for |
| 6 |
# service performance. |
| 7 |
# |
| 8 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
| 9 |
# you may not use this file except in compliance with the License. |
| 10 |
# You may obtain a copy of the License at |
| 11 |
# |
| 12 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 13 |
# |
| 14 |
# Unless required by applicable law or agreed to in writing, software |
| 15 |
# distributed under the License is distributed on an "AS IS" BASIS, |
| 16 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 17 |
# See the License for the specific language governing permissions and |
| 18 |
# limitations under the License. |
| 19 |
# |
| 20 |
|
| 21 |
package network::nokia::timos::snmp::mode::listisis; |
| 22 |
|
| 23 |
use base qw(centreon::plugins::mode); |
| 24 |
|
| 25 |
use strict; |
| 26 |
use warnings; |
| 27 |
|
| 28 |
sub new { |
| 29 |
my ($class, %options) = @_; |
| 30 |
my $self = $class->SUPER::new(package => __PACKAGE__, %options); |
| 31 |
bless $self, $class; |
| 32 |
|
| 33 |
$options{options}->add_options(arguments => |
| 34 |
{ |
| 35 |
}); |
| 36 |
return $self; |
| 37 |
} |
| 38 |
|
| 39 |
sub check_options { |
| 40 |
my ($self, %options) = @_; |
| 41 |
$self->SUPER::init(%options); |
| 42 |
} |
| 43 |
|
| 44 |
my %map_status = (1 => 'unknown', 2 => 'inService', 3 => 'outOfService', 4 => 'transition'); |
| 45 |
my $oid_vRtrName = '.1.3.6.1.4.1.6527.3.1.2.3.1.1.4'; |
| 46 |
my $mapping = { |
| 47 |
tmnxIsisOperState => { oid => '.1.3.6.1.4.1.6527.3.1.2.88.1.1.1.12', map => \%map_status }, |
| 48 |
}; |
| 49 |
|
| 50 |
sub manage_selection { |
| 51 |
my ($self, %options) = @_; |
| 52 |
|
| 53 |
my $snmp_result = $options{snmp}->get_multiple_table(oids => [ |
| 54 |
{ oid => $oid_vRtrName }, |
| 55 |
{ oid => $mapping->{tmnxIsisOperState}->{oid} }, |
| 56 |
], return_type => 1, nothing_quit => 1); |
| 57 |
$self->{isis} = {}; |
| 58 |
foreach my $oid (keys %$snmp_result) { |
| 59 |
next if ($oid !~ /^$mapping->{tmnxIsisOperState}->{oid}\.(\d+)\.(\d+)$/); |
| 60 |
my ($vrtr_id, $isis_id) = ($1, $2); |
| 61 |
|
| 62 |
my $vrtr_name = $snmp_result->{$oid_vRtrName . '.' . $vrtr_id}; |
| 63 |
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $vrtr_id . '.' . $isis_id); |
| 64 |
|
| 65 |
$self->{isis}->{$vrtr_id . '.' . $isis_id} = { |
| 66 |
name => $vrtr_name . '.' . $isis_id, |
| 67 |
status => $result->{tmnxIsisOperState} |
| 68 |
}; |
| 69 |
} |
| 70 |
} |
| 71 |
|
| 72 |
sub run { |
| 73 |
my ($self, %options) = @_; |
| 74 |
|
| 75 |
$self->manage_selection(%options); |
| 76 |
foreach my $instance (sort keys %{$self->{isis}}) { |
| 77 |
$self->{output}->output_add(long_msg => "[name = '" . $self->{isis}->{$instance}->{name} . |
| 78 |
"'] [status = '" . $self->{isis}->{$instance}->{status} . |
| 79 |
'"]'); |
| 80 |
} |
| 81 |
|
| 82 |
$self->{output}->output_add(severity => 'OK', |
| 83 |
short_msg => 'List IS-IS:'); |
| 84 |
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1); |
| 85 |
$self->{output}->exit(); |
| 86 |
} |
| 87 |
|
| 88 |
sub disco_format { |
| 89 |
my ($self, %options) = @_; |
| 90 |
|
| 91 |
$self->{output}->add_disco_format(elements => ['name', 'status']); |
| 92 |
} |
| 93 |
|
| 94 |
sub disco_show { |
| 95 |
my ($self, %options) = @_; |
| 96 |
|
| 97 |
$self->manage_selection(%options); |
| 98 |
foreach my $instance (sort keys %{$self->{isis}}) { |
| 99 |
$self->{output}->add_disco_entry(name => $self->{isis}->{$instance}->{name}, |
| 100 |
status => $self->{isis}->{$instance}->{status}, |
| 101 |
); |
| 102 |
} |
| 103 |
} |
| 104 |
|
| 105 |
1; |
| 106 |
|
| 107 |
__END__ |
| 108 |
|
| 109 |
=head1 MODE |
| 110 |
|
| 111 |
List IS-IS instances. |
| 112 |
|
| 113 |
=over 8 |
| 114 |
|
| 115 |
=back |
| 116 |
|
| 117 |
=cut |
| 118 |
|