Debian Codegraph @

src/centreon/common/airespace/snmp/mode/radiusauthservers.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 centreon::common::airespace::snmp::mode::radiusauthservers;
22
23 use base qw(centreon::plugins::templates::counter);
24
25 use strict;
26 use warnings;
27 use Digest::MD5 qw(md5_hex);
28
29 sub prefix_servers_output {
30 my ($self, %options) = @_;
31
32 return "Radius authentication server '" . $options{instance_value}->{name} . "' ";
33 }
34
35 sub set_counters {
36 my ($self, %options) = @_;
37
38 $self->{maps_counters_type} = [
39 { name => 'global', type => 0 },
40 { name => 'servers', type => 1, cb_prefix_output => 'prefix_servers_output', message_multiple => 'All radius authentication servers are ok' }
41 ];
42
43 $self->{maps_counters}->{global} = [
44 { label => 'authservers-total', nlabel => 'radius.authservers.total.count', display_ok => 0, set => {
45 key_values => [ { name => 'total' } ],
46 output_template => 'total authentication servers: %s',
47 perfdatas => [
48 { ltemplate => '%s', min => 0 }
49 ]
50 }
51 }
52 ];
53
54 $self->{maps_counters}->{servers} = [
55 { label => 'authserver-roundtrip-time', nlabel => 'radius.authserver.roundtrip.time.microseconds', set => {
56 key_values => [ { name => 'round_trip_time' }, { name => 'name' } ],
57 output_template => 'round trip time: %s µs',
58 perfdatas => [
59 { template => '%s', min => 0, unit => 'µs', label_extra_instance => 1, instance_use => 'name' }
60 ]
61 }
62 },
63 { label => 'authserver-packets-access-requests', nlabel => 'radius.authserver.packets.access.requests.persecond', set => {
64 key_values => [ { name => 'access_requests', per_second => 1 }, { name => 'name' } ],
65 output_template => 'access requests: %.2f/s',
66 perfdatas => [
67 { template => '%.2f', min => 0, unit => '/s', label_extra_instance => 1, instance_use => 'name' }
68 ]
69 }
70 },
71 { label => 'authserver-packets-access-accepts', nlabel => 'radius.authserver.packets.access.accepts.persecond', set => {
72 key_values => [ { name => 'access_accepts', per_second => 1 }, { name => 'name' } ],
73 output_template => 'access accepts: %.2f/s',
74 perfdatas => [
75 { template => '%.2f', min => 0, unit => '/s', label_extra_instance => 1, instance_use => 'name' }
76 ]
77 }
78 },
79 { label => 'authserver-clients-timeout', nlabel => 'radius.authserver.clients.timeout.count', set => {
80 key_values => [ { name => 'timeouts', diff => '1' }, { name => 'name' } ],
81 output_template => 'clients timeout: %s',
82 perfdatas => [
83 { template => '%s', min => 0, label_extra_instance => 1, instance_use => 'name' }
84 ]
85 }
86 }
87 ];
88 }
89
90 sub new {
91 my ($class, %options) = @_;
92 my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1, statefile => 1);
93 bless $self, $class;
94
95 $options{options}->add_options(arguments => {
96 'filter-name:s' => { name => 'filter_name' }
97 });
98
99 return $self;
100 }
101
102 my $map_server_status = {
103 0 => 'disable', 1 => 'enable'
104 };
105 my $mapping = {
106 address => { oid => '.1.3.6.1.4.1.14179.2.5.1.1.2' }, # bsnRadiusAuthServerAddress
107 port => { oid => '.1.3.6.1.4.1.14179.2.5.1.1.3' }, # bsnRadiusAuthClientServerPortNumber
108 status => { oid => '.1.3.6.1.4.1.14179.2.5.1.1.5', map => $map_server_status } # bsnRadiusAuthServerStatus
109 };
110 my $mapping2 = {
111 round_trip_time => { oid => '.1.3.6.1.4.1.14179.2.5.3.1.6' }, # bsnRadiusAuthClientRoundTripTime
112 access_requests => { oid => '.1.3.6.1.4.1.14179.2.5.3.1.7' }, # bsnRadiusAuthClientAccessRequests
113 access_accepts => { oid => '.1.3.6.1.4.1.14179.2.5.3.1.9' }, # bsnRadiusAuthClientAccessAccepts
114 timeouts => { oid => '.1.3.6.1.4.1.14179.2.5.3.1.15' } # bsnRadiusAuthClientTimeouts
115 };
116 my $oid_bsnRadiusAuthServerEntry = '.1.3.6.1.4.1.14179.2.5.1.1';
117
118 sub manage_selection {
119 my ($self, %options) = @_;
120
121 my $snmp_result = $options{snmp}->get_table(
122 oid => $oid_bsnRadiusAuthServerEntry,
123 start => $mapping->{address}->{oid},
124 end => $mapping->{status}->{oid},
125 nothing_quit => 1
126 );
127
128 $self->{global} = { total => 0 };
129 $self->{servers} = {};
130 foreach my $oid (keys %$snmp_result) {
131 next if ($oid !~ /^$mapping->{status}->{oid}\.(.*)$/);
132 my $instance = $1;
133
134 my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
135 my $name = $result->{address} . ':' . $result->{port};
136 if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
137 $name !~ /$self->{option_results}->{filter_name}/) {
138 $self->{output}->output_add(long_msg => "skipping '" . $name . "': no matching filter.", debug => 1);
139 next;
140 }
141 if ($result->{status} eq 'disable') {
142 $self->{output}->output_add(long_msg => "skipping '" . $name . "': disabled.", debug => 1);
143 next;
144 }
145
146 $self->{servers}->{$instance} = { name => $name };
147 $self->{global}->{total}++;
148 }
149
150 return if (scalar(keys %{$self->{servers}}) <= 0);
151
152 $options{snmp}->load(
153 oids => [ map($_->{oid}, values(%$mapping2)) ],
154 instances => [keys %{$self->{servers}}],
155 instance_regexp => '^(.*)$'
156 );
157 $snmp_result = $options{snmp}->get_leef(nothing_quit => 1);
158
159 foreach (keys %{$self->{servers}}) {
160 my $result = $options{snmp}->map_instance(mapping => $mapping2, results => $snmp_result, instance => $_);
161
162 $self->{servers}->{$_} = { %{$self->{servers}->{$_}}, %$result };
163 }
164
165 $self->{cache_name} = 'cisco_wlc_' . $self->{mode} . '_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' .
166 (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')) . '_' .
167 (defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all'));
168
169 }
170
171 1;
172
173 __END__
174
175 =head1 MODE
176
177 Check radius authentication servers.
178
179 =over 8
180
181 =item B<--filter-counters>
182
183 Only display some counters (regexp can be used).
184 Example: --filter-counters='^total$'
185
186 =item B<--filter-name>
187
188 Filter radius servers by name (can be a regexp).
189
190 =item B<--warning-authservers-total>
191
192 Thresholds.
193
194 =item B<--critical-authservers-total>
195
196 Thresholds.
197
198 =item B<--warning-authserver-roundtrip-time>
199
200 Thresholds.
201
202 =item B<--critical-authserver-roundtrip-time>
203
204 Thresholds.
205
206 =item B<--warning-authserver-packets-access-requests>
207
208 Thresholds.
209
210 =item B<--critical-authserver-packets-access-requests>
211
212 Thresholds.
213
214 =item B<--warning-authserver-packets-access-accepts>
215
216 Thresholds.
217
218 =item B<--critical-authserver-packets-access-accepts>
219
220 Thresholds.
221
222 =item B<--warning-authserver-clients-timeout>
223
224 Thresholds.
225
226 =item B<--critical-authserver-clients-timeout>
227
228 Thresholds.
229
230
231 =back
232
233 =cut