Debian Codegraph @

src/hardware/devices/timelinkmicro/tms6001/snmp/mode/antenna.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 # Authors : Thomas Gourdin [email protected]
21
22 package hardware::devices::timelinkmicro::tms6001::snmp::mode::antenna;
23
24 use base qw(centreon::plugins::templates::counter);
25
26 use strict;
27 use warnings;
28 use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc);
29
30 sub custom_status_output {
31 my ($self, %options) = @_;
32
33 return 'antenna status: ' . $self->{result_values}->{status};
34 }
35
36 sub set_counters {
37 my ($self, %options) = @_;
38
39 $self->{maps_counters_type} = [
40 { name => 'global', type => 0 }
41 ];
42
43 $self->{maps_counters}->{global} = [
44 { label => 'status', threshold => 0, set => {
45 key_values => [ { name => 'status' } ],
46 closure_custom_calc => \&catalog_status_calc,
47 closure_custom_output => $self->can('custom_status_output'),
48 closure_custom_perfdata => sub { return 0; },
49 closure_custom_threshold_check => \&catalog_status_threshold,
50 }
51 }
52 ];
53 }
54
55 sub new {
56 my ($class, %options) = @_;
57 my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
58 bless $self, $class;
59
60 $options{options}->add_options(arguments => {
61 'unknown-status:s' => { name => 'unknown_status', default => '' },
62 'warning-status:s' => { name => 'warning_status', default => '%{status} =~ /shorted/i' },
63 'critical-status:s' => { name => 'critical_status', default => '%{status} =~ /notConnected/i' }
64 });
65
66 return $self;
67 }
68
69 sub check_options {
70 my ($self, %options) = @_;
71 $self->SUPER::check_options(%options);
72
73 $self->change_macros(macros => ['warning_status', 'critical_status', 'unknown_status']);
74 }
75
76 my $mapping_status = {
77 C => 'connected',
78 S => 'shorted/poweroff',
79 N => 'notConnected'
80 };
81
82 sub manage_selection {
83 my ($self, %options) = @_;
84
85 my $oid_tsGNSSAntenna = '.1.3.6.1.4.1.22641.100.4.1.4.0';
86 my $snmp_result = $options{snmp}->get_leef(oids => [ $oid_tsGNSSAntenna ], nothing_quit => 1);
87
88 $self->{global} = {
89 status => $mapping_status->{ $snmp_result->{$oid_tsGNSSAntenna} }
90 };
91 }
92
93 1;
94
95 __END__
96
97 =head1 MODE
98
99 Check antenna.
100
101 =over 8
102
103 =item B<--unknown-status>
104
105 Define the conditions to match for the status to be UNKNOWN.
106 You can use the following variables: %{status}
107
108 =item B<--warning-status>
109
110 Define the conditions to match for the status to be WARNING (default: '%{status} =~ /shorted/i').
111 You can use the following variables: %{status}
112
113 =item B<--critical-status>
114
115 Define the conditions to match for the status to be CRITICAL (default: '%{status} =~ /notConnected/i').
116 You can use the following variables: %{status}
117
118 =back
119
120 =cut