Debian Codegraph @

src/hardware/devices/aeg/acm/snmp/mode/loadstatus.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 hardware::devices::aeg::acm::snmp::mode::loadstatus;
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 => 'global', type => 0, skipped_code => { -10 => 1 } },
33 ];
34
35 $self->{maps_counters}->{global} = [
36 { label => 'voltage', set => {
37 key_values => [ { name => 'loadVoltage' } ],
38 output_template => 'Voltage : %s V',
39 perfdatas => [
40 { label => 'voltage', value => 'loadVoltage', template => '%s',
41 unit => 'V' },
42 ],
43 }
44 },
45 { label => 'current', set => {
46 key_values => [ { name => 'loadCurrent' } ],
47 output_template => 'Current : %s A',
48 perfdatas => [
49 { label => 'current', value => 'loadCurrent', template => '%s',
50 min => 0, unit => 'A' },
51 ],
52 }
53 },
54 { label => 'power', set => {
55 key_values => [ { name => 'loadPower' } ],
56 output_template => 'Power : %s W',
57 perfdatas => [
58 { label => 'power', value => 'loadPower', template => '%s',
59 unit => 'w'},
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
75 return $self;
76 }
77
78 sub check_options {
79 my ($self, %options) = @_;
80 $self->SUPER::check_options(%options);
81 }
82
83 my $mapping_acm1000 = {
84 loadVoltage => { oid => '.1.3.6.1.4.1.15416.37.3.1', divider => '100' },
85 loadCurrent => { oid => '.1.3.6.1.4.1.15416.37.3.2', divider => '100' },
86 loadPower => { oid => '.1.3.6.1.4.1.15416.37.3.3' },
87 };
88 my $mapping_acmi1000 = {
89 loadVoltage => { oid => '.1.3.6.1.4.1.15416.38.3.1', divider => '100' },
90 loadCurrent => { oid => '.1.3.6.1.4.1.15416.38.3.2', divider => '100' },
91 loadPower => { oid => '.1.3.6.1.4.1.15416.38.3.3' },
92 };
93 my $mapping_acm1d = {
94 loadVoltage => { oid => '.1.3.6.1.4.1.15416.29.4.1' },
95 loadCurrent => { oid => '.1.3.6.1.4.1.15416.29.4.2' },
96 };
97 my $oid_acm1000Load = '.1.3.6.1.4.1.15416.37.3';
98 my $oid_acmi1000Load = '.1.3.6.1.4.1.15416.38.3';
99 my $oid_acm1dLoad = '.1.3.6.1.4.1.15416.29.4';
100
101 sub manage_selection {
102 my ($self, %options) = @_;
103
104 $self->{global} = {};
105 $self->{results} = $options{snmp}->get_multiple_table(oids => [ { oid => $oid_acm1000Load },
106 { oid => $oid_acmi1000Load },
107 { oid => $oid_acm1dLoad },
108 ],
109 nothing_quit => 1);
110
111 my $result_acm1000 = $options{snmp}->map_instance(mapping => $mapping_acm1000, results => $self->{results}->{$oid_acm1000Load}, instance => '0');
112 my $result_acmi1000 = $options{snmp}->map_instance(mapping => $mapping_acmi1000, results => $self->{results}->{$oid_acmi1000Load}, instance => '0');
113 my $result_acm1d = $options{snmp}->map_instance(mapping => $mapping_acm1d, results => $self->{results}->{$oid_acm1dLoad}, instance => '0');
114
115 foreach my $name (keys %{$mapping_acm1000}) {
116 if (defined($result_acm1000->{$name})) {
117 $self->{global}->{$name} = $result_acm1000->{$name};
118 $self->{global}->{$name} = $result_acm1000->{$name} / $mapping_acm1000->{$name}->{divider} if defined($mapping_acm1000->{$name}->{divider});
119 }
120 }
121 foreach my $name (keys %{$mapping_acmi1000}) {
122 if (defined($result_acmi1000->{$name})) {
123 $self->{global}->{$name} = $result_acmi1000->{$name};
124 $self->{global}->{$name} = $result_acmi1000->{$name} / $mapping_acmi1000->{$name}->{divider} if defined($mapping_acmi1000->{$name}->{divider});
125 }
126 }
127 foreach my $name (keys %{$mapping_acm1d}) {
128 $self->{global}->{$name} = $result_acm1d->{$name} unless (!defined($result_acm1d->{$name}));
129 }
130 }
131
132 1;
133
134 __END__
135
136 =head1 MODE
137
138 Check load plant statistics.
139
140 =over 8
141
142 =item B<--filter-counters>
143
144 Only display some counters (regexp can be used).
145 Example: --filter-counters='^current$'
146
147 =item B<--warning-*>
148
149 Warning threshold.
150 Can be: 'voltage', 'current', 'power'.
151
152 =item B<--critical-*>
153
154 Critical threshold.
155 Can be: 'voltage', 'current', 'power'.
156
157 =back
158
159 =cut