Debian Codegraph @

src/network/mikrotik/snmp/mode/signal.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::mikrotik::snmp::mode::signal;
22
23 use base qw(centreon::plugins::templates::counter);
24
25 use strict;
26 use warnings;
27
28 sub set_counters {
29 my ($self, %options) = @_;
30
31 $self->{maps_counters_type} = [
32 { name => 'wreg', type => 1, cb_prefix_output => 'prefix_wreg_output', message_multiple => 'All wireless registrations are ok', skipped_code => { -10 => 1 } },
33 ];
34
35 $self->{maps_counters}->{wreg} = [
36 { label => 'rx-strength', set => {
37 key_values => [ { name => 'mtxrWlRtabStrength' }, { name => 'display' } ],
38 output_template => 'signal strength Rx: %s dBm',
39 perfdatas => [
40 { label => 'signal_rx', value => 'mtxrWlRtabStrength', template => '%s', unit => 'dBm',
41 label_extra_instance => 1, instance_use => 'display' },
42 ],
43 }
44 },
45 { label => 'tx-strength', set => {
46 key_values => [ { name => 'mtxrWlRtabTxStrength' }, { name => 'display' } ],
47 output_template => 'signal strength Tx: %s dBm',
48 perfdatas => [
49 { label => 'signal_tx', value => 'mtxrWlRtabTxStrength', template => '%s', unit => 'dBm',
50 label_extra_instance => 1, instance_use => 'display' },
51 ],
52 }
53 },
54 { label => 'signal2noise', set => {
55 key_values => [ { name => 'mtxrWlRtabSignalToNoise', no_value => 0 }, { name => 'display' } ],
56 output_template => 'signal to noise: %s dB',
57 perfdatas => [
58 { label => 'signal_noise', value => 'mtxrWlRtabSignalToNoise', template => '%s', unit => 'dB',
59 label_extra_instance => 1, instance_use => 'display' },
60 ],
61 }
62 }
63 ];
64 }
65
66 sub new {
67 my ($class, %options) = @_;
68 my $self = $class->SUPER::new(package => __PACKAGE__, %options);
69 bless $self, $class;
70
71 $options{options}->add_options(arguments => {
72 });
73
74 return $self;
75 }
76
77 sub prefix_wreg_output {
78 my ($self, %options) = @_;
79
80 return "MAC '" . $options{instance_value}->{display} . "' ";
81 }
82
83 my $mapping = {
84 mtxrWlRtabAddr => { oid => '.1.3.6.1.4.1.14988.1.1.1.2.1.1' },
85 mtxrWlRtabStrength => { oid => '.1.3.6.1.4.1.14988.1.1.1.2.1.3' }, # dBm
86 mtxrWlRtabSignalToNoise => { oid => '.1.3.6.1.4.1.14988.1.1.1.2.1.12' }, # dB
87 mtxrWlRtabTxStrength => { oid => '.1.3.6.1.4.1.14988.1.1.1.2.1.19' }, # dBm
88 };
89
90 sub manage_selection {
91 my ($self, %options) = @_;
92
93 my $snmp_result = $options{snmp}->get_multiple_table(
94 oids => [
95 map({ oid => $_->{oid} }, values(%$mapping))
96 ],
97 return_type => 1,
98 nothing_quit => 1
99 );
100
101 $self->{wreg} = {};
102 foreach my $oid (keys %$snmp_result) {
103 next if ($oid !~ /^$mapping->{mtxrWlRtabAddr}->{oid}\.(.*)$/);
104 my $instance = $1;
105 my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
106
107 my $macaddress = unpack('H*', $result->{mtxrWlRtabAddr});
108 $macaddress =~ s/(..)(?=.)/$1:/g;
109
110 $self->{wreg}->{$instance} = {
111 display => $macaddress,
112 %$result
113 };
114 }
115 }
116
117 1;
118
119 __END__
120
121 =head1 MODE
122
123 Check wireless registration signals.
124
125 =over 8
126
127 =item B<--warning-*> B<--critical-*>
128
129 Can be: 'rx-strength', 'tx-strength', 'signal2noise'
130
131 =back
132
133 =cut