Debian Codegraph @

src/network/aruba/instant/snmp/mode/ssidstatus.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::aruba::instant::snmp::mode::ssidstatus;
22
23 use base qw(centreon::plugins::templates::counter);
24
25 use strict;
26 use warnings;
27 use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
28
29 sub custom_status_output {
30 my ($self, %options) = @_;
31
32 return "Status is '" . $self->{result_values}->{status} . "'";
33 }
34
35 sub prefix_output {
36 my ($self, %options) = @_;
37
38 return "SSID '" . $options{instance_value}->{display} . "' ";
39 }
40
41 sub set_counters {
42 my ($self, %options) = @_;
43
44 $self->{maps_counters_type} = [
45 { name => 'ssid', display_long => 1, cb_prefix_output => 'prefix_output',
46 message_multiple => 'All SSIDs are ok', type => 1 }
47 ];
48
49 $self->{maps_counters}->{ssid} = [
50 { label => 'status', type => 2, critical_default => '%{status} !~ /enable/i', set => {
51 key_values => [ { name => 'status' }, { name => 'display' } ],
52 closure_custom_output => $self->can('custom_status_output'),
53 closure_custom_perfdata => sub { return 0; },
54 closure_custom_threshold_check => \&catalog_status_threshold_ng
55 }
56 }
57 ];
58 }
59
60 sub new {
61 my ($class, %options) = @_;
62 my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
63 bless $self, $class;
64
65 $options{options}->add_options(arguments => {
66 'filter-name:s' => { name => 'filter_name' }
67 });
68
69 return $self;
70 }
71
72 my $map_status = {
73 0 => 'enable', 1 => 'disable'
74 };
75
76 my $mapping = {
77 aiSSID => { oid => '.1.3.6.1.4.1.14823.2.3.3.1.1.7.1.2' },
78 aiSSIDStatus => { oid => '.1.3.6.1.4.1.14823.2.3.3.1.1.7.1.3', map => $map_status }
79 };
80 my $oid_aiWlanSSIDEntry = '.1.3.6.1.4.1.14823.2.3.3.1.1.7.1';
81
82 sub manage_selection {
83 my ($self, %options) = @_;
84
85 my $snmp_result = $options{snmp}->get_table(
86 oid => $oid_aiWlanSSIDEntry,
87 start => $mapping->{aiSSID}->{oid},
88 end => $mapping->{aiSSIDStatus}->{oid},
89 nothing_quit => 1
90 );
91
92 $self->{ssid} = {};
93
94 foreach my $oid (keys %{$snmp_result}) {
95 next if ($oid !~ /^$mapping->{aiSSID}->{oid}\.(.*)$/);
96 my $instance = $1;
97
98 my $result = $options{snmp}->map_instance(
99 mapping => $mapping,
100 results => $snmp_result,
101 instance => $instance
102 );
103
104 if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
105 $result->{aiSSID} !~ /$self->{option_results}->{filter_name}/) {
106 $self->{output}->output_add(long_msg => "skipping ssid '" . $result->{aiSSID} . "'.", debug => 1);
107 next;
108 }
109
110 $self->{ssid}->{$result->{aiSSID}} = {
111 status => $result->{aiSSIDStatus},
112 display => $result->{aiSSID}
113 };
114 }
115
116 if (scalar(keys %{$self->{ssid}}) <= 0) {
117 $self->{output}->add_option_msg(short_msg => "No SSID found.");
118 $self->{output}->option_exit();
119 }
120 }
121
122 1;
123
124 __END__
125
126 =head1 MODE
127
128 Check SSID status.
129
130 =over 8
131
132 =item B<--filter-name>
133
134 Filter SSID name (can be a regexp).
135
136 =item B<--warning-status>
137
138 Define the conditions to match for the status to be WARNING (default: '').
139 You can use the following variables: %{status}, %{display}
140
141 =item B<--critical-status>
142
143 Define the conditions to match for the status to be CRITICAL (default: '%{status} !~ /enable/i').
144 You can use the following variables: %{status}, %{display}
145
146 =back
147
148 =cut