| 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::ups::ees::snmp::mode::rectifier; |
| 22 |
|
| 23 |
use base qw(centreon::plugins::templates::counter); |
| 24 |
|
| 25 |
use strict; |
| 26 |
use warnings; |
| 27 |
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng); |
| 28 |
|
| 29 |
sub rectifier_custom_output { |
| 30 |
my ($self, %options) = @_; |
| 31 |
|
| 32 |
return sprintf( |
| 33 |
"installed: %d, communicating: %d, used capacity: %.2f%%", |
| 34 |
$self->{result_values}->{installed}, |
| 35 |
$self->{result_values}->{communicating}, |
| 36 |
$self->{result_values}->{used_capacity} |
| 37 |
); |
| 38 |
} |
| 39 |
|
| 40 |
sub set_counters { |
| 41 |
my ($self, %options) = @_; |
| 42 |
|
| 43 |
$self->{maps_counters_type} = [ |
| 44 |
{ name => 'rectifier', type => 0 } |
| 45 |
]; |
| 46 |
|
| 47 |
$self->{maps_counters}->{rectifier} = [ |
| 48 |
{ |
| 49 |
label => 'status', |
| 50 |
warning_default => '%{installed} != %{communicating}', |
| 51 |
type => 2, |
| 52 |
set => { |
| 53 |
key_values => [ |
| 54 |
{ name => 'used_capacity' }, |
| 55 |
{ name => 'installed' }, |
| 56 |
{ name => 'communicating' } |
| 57 |
], |
| 58 |
closure_custom_threshold_check => \&catalog_status_threshold_ng, |
| 59 |
closure_custom_perfdata => sub {return 0;}, |
| 60 |
closure_custom_output => $self->can('rectifier_custom_output') |
| 61 |
} |
| 62 |
}, |
| 63 |
{ |
| 64 |
label => 'used-capacity', display_ok => 0, nlabel => 'rectifier.capacity.used.percentage', |
| 65 |
set => { |
| 66 |
key_values => [ { name => 'used_capacity' } ], |
| 67 |
output_template => 'used capacity: %.2f%%', |
| 68 |
perfdatas => [ { template => '%.2f', min => 0, max => 100, unit => '%' } ] |
| 69 |
} |
| 70 |
}, |
| 71 |
{ |
| 72 |
label => 'installed', display_ok => 0, nlabel => 'rectifier.installed.count', |
| 73 |
set => { |
| 74 |
key_values => [ { name => 'installed' } ], |
| 75 |
output_template => 'installed: %d', |
| 76 |
perfdatas => [ { template => '%d', min => 0 } ] |
| 77 |
} |
| 78 |
}, |
| 79 |
{ |
| 80 |
label => 'communicating', display_ok => 0, nlabel => 'rectifier.communicating.count', |
| 81 |
set => { |
| 82 |
key_values => [ { name => 'communicating' } ], |
| 83 |
output_template => 'communicating: %d', |
| 84 |
perfdatas => [ { template => '%d', min => 0 } ] |
| 85 |
} |
| 86 |
} |
| 87 |
]; |
| 88 |
} |
| 89 |
|
| 90 |
sub new { |
| 91 |
my ($class, %options) = @_; |
| 92 |
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); |
| 93 |
bless $self, $class; |
| 94 |
|
| 95 |
$options{options}->add_options(arguments => {}); |
| 96 |
|
| 97 |
return $self; |
| 98 |
} |
| 99 |
|
| 100 |
sub manage_selection { |
| 101 |
my ($self, %options) = @_; |
| 102 |
|
| 103 |
my $oid_numberOfInstalledRectifiers = '.1.3.6.1.4.1.6302.2.1.2.11.1.0'; |
| 104 |
my $oid_numberOfRectifiersCommunicating = '.1.3.6.1.4.1.6302.2.1.2.11.2.0'; |
| 105 |
my $oid_rectifiersUsedCapacity = '.1.3.6.1.4.1.6302.2.1.2.11.3.0'; |
| 106 |
|
| 107 |
my $snmp_result = $options{snmp}->get_leef( |
| 108 |
oids => [ |
| 109 |
$oid_numberOfInstalledRectifiers, |
| 110 |
$oid_numberOfRectifiersCommunicating, |
| 111 |
$oid_rectifiersUsedCapacity |
| 112 |
], |
| 113 |
nothing_quit => 1 |
| 114 |
); |
| 115 |
|
| 116 |
$self->{rectifier} = { |
| 117 |
installed => $snmp_result->{$oid_numberOfInstalledRectifiers}, |
| 118 |
communicating => $snmp_result->{$oid_numberOfRectifiersCommunicating}, |
| 119 |
used_capacity => $snmp_result->{$oid_rectifiersUsedCapacity} |
| 120 |
}; |
| 121 |
} |
| 122 |
|
| 123 |
1; |
| 124 |
|
| 125 |
__END__ |
| 126 |
|
| 127 |
=head1 MODE |
| 128 |
|
| 129 |
Check rectifier. |
| 130 |
|
| 131 |
=over 8 |
| 132 |
|
| 133 |
=item B<--unknown-status> |
| 134 |
|
| 135 |
Define the conditions to match for the status to be UNKNOWN. |
| 136 |
You can use the following variables: %{installed}, %{communicating}, %{used_capacity} |
| 137 |
|
| 138 |
=item B<--warning-status> |
| 139 |
|
| 140 |
Define the conditions to match for the status to be WARNING (default: '%{installed} != %{communicating}'). |
| 141 |
You can use the following variables: %{installed}, %{communicating}, %{used_capacity} |
| 142 |
|
| 143 |
=item B<--critical-status> |
| 144 |
|
| 145 |
Define the conditions to match for the status to be CRITICAL. |
| 146 |
You can use the following variables: %{installed}, %{communicating}, %{used_capacity} |
| 147 |
|
| 148 |
=item B<--warning-*> B<--critical-*> |
| 149 |
|
| 150 |
Thresholds. |
| 151 |
Can be: 'used-capacity', 'installed', 'communicating' |
| 152 |
|
| 153 |
=back |
| 154 |
|
| 155 |
=cut |