| 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::ats::eaton::snmp::mode::outputline; |
| 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 => 'oline', type => 0, cb_prefix_output => 'prefix_line_output', skipped_code => { -10 => 1 } }, |
| 33 |
]; |
| 34 |
|
| 35 |
$self->{maps_counters}->{oline} = [ |
| 36 |
{ label => 'voltage', nlabel => 'line.output.voltage.volt', set => { |
| 37 |
key_values => [ { name => 'voltage' } ], |
| 38 |
output_template => 'Voltage : %.2f V', |
| 39 |
perfdatas => [ |
| 40 |
{ value => 'voltage', template => '%s', |
| 41 |
unit => 'V' }, |
| 42 |
], |
| 43 |
} |
| 44 |
}, |
| 45 |
{ label => 'current', nlabel => 'line.current.ampere', set => { |
| 46 |
key_values => [ { name => 'current' } ], |
| 47 |
output_template => 'current : %s A', |
| 48 |
perfdatas => [ |
| 49 |
{ template => '%s', value => 'current', |
| 50 |
unit => 'A', min => 0 }, |
| 51 |
], |
| 52 |
} |
| 53 |
}, |
| 54 |
]; |
| 55 |
} |
| 56 |
|
| 57 |
sub prefix_line_output { |
| 58 |
my ($self, %options) = @_; |
| 59 |
|
| 60 |
return "Output line "; |
| 61 |
} |
| 62 |
|
| 63 |
sub new { |
| 64 |
my ($class, %options) = @_; |
| 65 |
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); |
| 66 |
bless $self, $class; |
| 67 |
|
| 68 |
$options{options}->add_options(arguments => { |
| 69 |
}); |
| 70 |
|
| 71 |
return $self; |
| 72 |
} |
| 73 |
|
| 74 |
my $oid_atsOutputVoltage = '.1.3.6.1.4.1.534.10.1.3.2.1.0'; |
| 75 |
my $oid_atsOutputCurrent = '.1.3.6.1.4.1.534.10.1.3.2.2.0'; |
| 76 |
my $oid_ats2OutputVoltage = '.1.3.6.1.4.1.534.10.2.2.3.1.0'; |
| 77 |
my $oid_ats2OutputCurrent = '.1.3.6.1.4.1.534.10.2.2.3.2.0'; |
| 78 |
|
| 79 |
sub check_ats2 { |
| 80 |
my ($self, %options) = @_; |
| 81 |
|
| 82 |
return if (!defined($options{result}->{$oid_ats2OutputVoltage})); |
| 83 |
|
| 84 |
$self->{oline} = { |
| 85 |
voltage => $options{result}->{$oid_ats2OutputVoltage} * 0.1, |
| 86 |
current => $options{result}->{$oid_ats2OutputCurrent} * 0.1 |
| 87 |
}; |
| 88 |
} |
| 89 |
|
| 90 |
sub check_ats { |
| 91 |
my ($self, %options) = @_; |
| 92 |
|
| 93 |
return if (defined($self->{oline})); |
| 94 |
|
| 95 |
$self->{oline} = { |
| 96 |
voltage => $options{result}->{$oid_atsOutputVoltage} * 0.1, |
| 97 |
current => $options{result}->{$oid_atsOutputCurrent} * 0.1 |
| 98 |
}; |
| 99 |
} |
| 100 |
|
| 101 |
sub manage_selection { |
| 102 |
my ($self, %options) = @_; |
| 103 |
|
| 104 |
my $snmp_result = $options{snmp}->get_leef(oids => [ |
| 105 |
$oid_atsOutputVoltage, $oid_atsOutputCurrent, |
| 106 |
$oid_ats2OutputVoltage, $oid_ats2OutputCurrent, |
| 107 |
], nothing_quit => 1); |
| 108 |
$self->check_ats2(result => $snmp_result); |
| 109 |
$self->check_ats(result => $snmp_result); |
| 110 |
} |
| 111 |
|
| 112 |
1; |
| 113 |
|
| 114 |
__END__ |
| 115 |
|
| 116 |
=head1 MODE |
| 117 |
|
| 118 |
Check output line. |
| 119 |
|
| 120 |
=over 8 |
| 121 |
|
| 122 |
=item B<--filter-counters> |
| 123 |
|
| 124 |
Only display some counters (regexp can be used). |
| 125 |
Example: --filter-counters='^voltage$' |
| 126 |
|
| 127 |
=item B<--warning-*> B<--critical-*> |
| 128 |
|
| 129 |
Warning threshold. |
| 130 |
Can be: 'voltage', 'current'. |
| 131 |
|
| 132 |
=back |
| 133 |
|
| 134 |
=cut |