Debian Codegraph @

src/network/rad/airmux/snmp/mode/radiostatus.pm

raw
1 #
2 # Copyright 2018 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::rad::airmux::snmp::mode::radiostatus;
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 custom_badframes_calc {
30 my ($self, %options) = @_;
31
32 my $delta_value = $options{new_datas}->{$self->{instance} . '_bad_frames'} - $options{old_datas}->{$self->{instance} . '_bad_frames'};
33 my $delta_total = $options{new_datas}->{$self->{instance} . '_total_frames'} - $options{old_datas}->{$self->{instance} . '_total_frames'};
34
35 $self->{result_values}->{bad_prct} = 0;
36 if ($delta_total > 0) {
37 $self->{result_values}->{bad_prct} = $delta_value * 100 / $delta_total;
38 }
39 return 0;
40 }
41
42 sub set_counters {
43 my ($self, %options) = @_;
44
45 $self->{maps_counters_type} = [
46 { name => 'global', type => 0 },
47 ];
48 $self->{maps_counters}->{global} = [
49 { label => 'rx-power', set => {
50 key_values => [ { name => 'rx_power' } ],
51 output_template => 'Received signal strength: %s Dbm',
52 perfdatas => [
53 { label => 'rx_power', value => 'rx_power', template => '%s', min => 0 , unit => 'Dbm' },
54 ],
55 }
56 },
57 { label => 'tx-power', set => {
58 key_values => [ { name => 'tx_power' } ],
59 output_template => 'Current transmit power: %s Dbm',
60 perfdatas => [
61 { label => 'tx_power', value => 'tx_power', template => '%s', min => 0 , unit => 'Dbm' },
62 ],
63 }
64 },
65 { label => 'bad-frames', set => {
66 key_values => [ { name => 'total_frames', diff => 1 }, { name => 'bad_frames', diff => 1 } ],
67 closure_custom_calc => $self->can('custom_badframes_calc'),
68 output_template => 'Bad frames: %.2f %%', output_use => 'bad_prct', threshold_use => 'bad_prct',
69 perfdatas => [
70 { label => 'bad_frames', value => 'bad_prct', template => '%.2f', min => 0, max => 100,
71 unit => '%' },
72 ],
73 }
74 },
75 ];
76 }
77
78 sub new {
79 my ($class, %options) = @_;
80 my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1);
81 bless $self, $class;
82
83 $options{options}->add_options(arguments => {
84 });
85
86 return $self;
87 }
88
89 sub manage_selection {
90 my ($self, %options) = @_;
91
92 my $oid_radwllMilOduAirCurrentTxPower = '.1.3.6.1.4.1.4458.1000.1.5.12.0';
93 my $oid_radwllMilOduAirRxPower = '.1.3.6.1.4.1.4458.1000.1.5.9.1.0';
94 my $oid_radwllMilOduAirBadFrames = '.1.3.6.1.4.1.4458.1000.1.5.9.3.0';
95 my $oid_radwllMilOduAirTotalFrames = '.1.3.6.1.4.1.4458.1000.1.5.9.2.0';
96 my $result = $options{snmp}->get_leef(oids => [
97 $oid_radwllMilOduAirCurrentTxPower, $oid_radwllMilOduAirRxPower, $oid_radwllMilOduAirBadFrames, $oid_radwllMilOduAirTotalFrames
98 ], nothing_quit => 1);
99
100 $self->{cache_name} = "rad_airmux_" . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' .
101 (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all'));
102
103 $self->{global} = {
104 tx_power => $result->{$oid_radwllMilOduAirCurrentTxPower},
105 rx_power => $result->{$oid_radwllMilOduAirRxPower},
106 bad_frames => $result->{$oid_radwllMilOduAirBadFrames},
107 total_frames => $result->{$oid_radwllMilOduAirTotalFrames},
108 };
109 }
110
111 1;
112
113 __END__
114
115 =head1 MODE
116
117 Check radio signal.
118
119 =over 8
120
121 =item B<--filter-counters>
122
123 Only display some counters (regexp can be used).
124 Example: --filter-counters='rx-power'
125
126 =item B<--warning-*>
127
128 Warning threshold.
129 Can be: 'tx-power', 'rx-power', 'bad-frames'.
130
131 =item B<--critical-*>
132
133 Critical threshold.
134 Can be: 'tx-power', 'rx-power', 'bad-frames'.
135
136 =back
137
138 =cut