| 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::pdu::clever::snmp::mode::psusage; |
| 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 }, |
| 33 |
]; |
| 34 |
$self->{maps_counters}->{global} = [ |
| 35 |
{ label => 'power', set => { |
| 36 |
key_values => [ { name => 'power' } ], |
| 37 |
output_template => 'Input power : %s W', |
| 38 |
perfdatas => [ |
| 39 |
{ label => 'power', value => 'power', template => '%s', |
| 40 |
unit => 'W', min => 0 }, |
| 41 |
], |
| 42 |
} |
| 43 |
}, |
| 44 |
{ label => 'current', set => { |
| 45 |
key_values => [ { name => 'current' } ], |
| 46 |
output_template => 'Current : %s A', |
| 47 |
perfdatas => [ |
| 48 |
{ label => 'current', value => 'current', template => '%s', |
| 49 |
unit => 'A', min => 0 }, |
| 50 |
], |
| 51 |
} |
| 52 |
}, |
| 53 |
{ label => 'voltage', set => { |
| 54 |
key_values => [ { name => 'voltage' } ], |
| 55 |
output_template => 'Voltage : %s V', |
| 56 |
perfdatas => [ |
| 57 |
{ label => 'voltage', value => 'voltage', template => '%s', |
| 58 |
unit => 'V', min => 0 }, |
| 59 |
], |
| 60 |
} |
| 61 |
}, |
| 62 |
]; |
| 63 |
} |
| 64 |
|
| 65 |
sub new { |
| 66 |
my ($class, %options) = @_; |
| 67 |
my $self = $class->SUPER::new(package => __PACKAGE__, %options); |
| 68 |
bless $self, $class; |
| 69 |
|
| 70 |
$options{options}->add_options(arguments => |
| 71 |
{ |
| 72 |
}); |
| 73 |
|
| 74 |
return $self; |
| 75 |
} |
| 76 |
|
| 77 |
my $oid_current = '.1.3.6.1.4.1.30966.1.2.1.6.0'; |
| 78 |
my $oid_voltage = '.1.3.6.1.4.1.30966.1.2.1.9.0'; |
| 79 |
|
| 80 |
sub manage_selection { |
| 81 |
my ($self, %options) = @_; |
| 82 |
|
| 83 |
my $result = $options{snmp}->get_leef(oids => [ $oid_current, $oid_voltage ], |
| 84 |
nothing_quit => 1); |
| 85 |
$self->{global} = { current => $result->{$oid_current}, voltage => $result->{$oid_voltage}, |
| 86 |
power => $result->{$oid_current} * $result->{$oid_voltage} }; |
| 87 |
} |
| 88 |
|
| 89 |
1; |
| 90 |
|
| 91 |
__END__ |
| 92 |
|
| 93 |
=head1 MODE |
| 94 |
|
| 95 |
Check power source usage. |
| 96 |
|
| 97 |
=over 8 |
| 98 |
|
| 99 |
=item B<--warning-*> |
| 100 |
|
| 101 |
Warning threshold. |
| 102 |
Can be: 'current', 'power', 'voltage'. |
| 103 |
|
| 104 |
=item B<--critical-*> |
| 105 |
|
| 106 |
Critical threshold. |
| 107 |
Can be: 'current', 'power', 'voltage'. |
| 108 |
|
| 109 |
=back |
| 110 |
|
| 111 |
=cut |