Debian Codegraph @

src/network/alcatel/pss/1830/snmp/mode/listsap.pm

raw
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::alcatel::pss::1830::snmp::mode::listsap;
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
37 return $self;
38 }
39
40 sub check_options {
41 my ($self, %options) = @_;
42 $self->SUPER::init(%options);
43 }
44
45 my $oid_tnSapDescription = '.1.3.6.1.4.1.7483.6.1.2.4.3.2.1.5';
46 my $oid_tnSvcName = '.1.3.6.1.4.1.7483.6.1.2.4.2.2.1.28';
47
48 sub manage_selection {
49 my ($self, %options) = @_;
50
51 $self->{sap} = {};
52 my $snmp_result = $self->{snmp}->get_multiple_table(oids => [ { oid => $oid_tnSapDescription }, { oid => $oid_tnSvcName } ],
53 nothing_quit => 1);
54 foreach my $oid (keys %{$snmp_result->{$oid_tnSapDescription}}) {
55 next if ($oid !~ /^$oid_tnSapDescription\.(.*?)\.(.*?)\.(.*?)\.(.*?)$/);
56 my ($SysSwitchId, $SvcId, $SapPortId, $SapEncapValue) = ($1, $2, $3, $4);
57
58 $self->{sap}->{$SysSwitchId . '.' . $SvcId . '.' . $SapPortId . '.' . $SapEncapValue} = {
59 SysSwitchId => $SysSwitchId,
60 SvcId => $SvcId,
61 SapPortId => $SapPortId,
62 SapEncapValue => $SapEncapValue,
63 SapDescription => $snmp_result->{$oid_tnSapDescription}->{$oid},
64 SvcName => defined($snmp_result->{$oid_tnSvcName}->{$oid_tnSvcName . '.' . $SysSwitchId . '.' . $SvcId}) ?
65 $snmp_result->{$oid_tnSvcName}->{$oid_tnSvcName . '.' . $SysSwitchId . '.' . $SvcId} : ''
66 };
67 }
68 }
69
70 sub run {
71 my ($self, %options) = @_;
72
73 $self->{snmp} = $options{snmp};
74 $self->manage_selection();
75 foreach my $instance (sort keys %{$self->{sap}}) {
76 my $msg = '';
77 $self->{output}->output_add(long_msg =>
78 "[SysSwitchId = " . $self->{sap}->{$instance}->{SysSwitchId} . "]" .
79 "[SvcId = " . $self->{sap}->{$instance}->{SvcId} . "]" .
80 "[SapPortId = " . $self->{sap}->{$instance}->{SapPortId} . "]" .
81 "[SapEncapValue = " . $self->{sap}->{$instance}->{SapEncapValue} . "]" .
82 "[SapDescription = " . $self->{sap}->{$instance}->{SapDescription} . "]" .
83 "[SvcName = " . $self->{sap}->{$instance}->{SvcName} . "]"
84 );
85 }
86
87 $self->{output}->output_add(severity => 'OK',
88 short_msg => 'List SAP:');
89 $self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
90 $self->{output}->exit();
91 }
92
93 sub disco_format {
94 my ($self, %options) = @_;
95
96 $self->{output}->add_disco_format(elements => ['SysSwitchId', 'SvcId', 'SapPortId', 'SapEncapValue', 'SapDescription', 'SvcName']);
97 }
98
99 sub disco_show {
100 my ($self, %options) = @_;
101 $self->{snmp} = $options{snmp};
102
103 $self->manage_selection(disco => 1);
104 foreach my $instance (sort keys %{$self->{sap}}) {
105 $self->{output}->add_disco_entry(%{$self->{sap}->{$instance}});
106 }
107 }
108
109 1;
110
111 __END__
112
113 =head1 MODE
114
115 List SAP.
116
117 =over 8
118
119 =back
120
121 =cut
122