diff --git a/centreon-plugins/hardware/pdu/emerson/snmp/mode/globalstatus.pm b/centreon-plugins/hardware/pdu/emerson/snmp/mode/globalstatus.pm index 2fab06d4e..5b582c024 100644 --- a/centreon-plugins/hardware/pdu/emerson/snmp/mode/globalstatus.pm +++ b/centreon-plugins/hardware/pdu/emerson/snmp/mode/globalstatus.pm @@ -65,13 +65,12 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name' }, - "warning-status:s" => { name => 'warning_status', default => '%{status} =~ /normalWithWarning/i' }, - "critical-status:s" => { name => 'critical_status', default => '%{status} =~ /normalWithAlarm|abnormalOperation/i' }, - }); - + $options{options}->add_options(arguments => { + 'filter-name:s' => { name => 'filter_name' }, + 'warning-status:s' => { name => 'warning_status', default => '%{status} =~ /normalWithWarning/i' }, + 'critical-status:s' => { name => 'critical_status', default => '%{status} =~ /normalWithAlarm|abnormalOperation/i' }, + }); + return $self; } @@ -105,10 +104,12 @@ sub manage_selection { my ($self, %options) = @_; $self->{pdu} = {}; - $self->{results} = $options{snmp}->get_table(oid => $oid_lgpPduEntry, - start => $mapping->{lgpPduEntryUsrLabel}->{oid}, - end => $mapping->{lgpPduEntrySysStatus}->{oid}, - nothing_quit => 1); + $self->{results} = $options{snmp}->get_table( + oid => $oid_lgpPduEntry, + start => $mapping->{lgpPduEntryUsrLabel}->{oid}, + end => $mapping->{lgpPduEntrySysStatus}->{oid}, + nothing_quit => 1 + ); foreach my $oid (keys %{$self->{results}}) { next if ($oid !~ /^$mapping->{lgpPduEntrySysStatus}->{oid}\.(.*)$/); diff --git a/centreon-plugins/hardware/pdu/emerson/snmp/mode/psusage.pm b/centreon-plugins/hardware/pdu/emerson/snmp/mode/psusage.pm index a06370f3b..5690e1edc 100644 --- a/centreon-plugins/hardware/pdu/emerson/snmp/mode/psusage.pm +++ b/centreon-plugins/hardware/pdu/emerson/snmp/mode/psusage.pm @@ -30,55 +30,59 @@ sub set_counters { my ($self, %options) = @_; $self->{maps_counters_type} = [ - { name => 'ps', type => 1, cb_prefix_output => 'prefix_ps_output', message_multiple => 'All power sources are ok' }, - { name => 'line', type => 1, cb_prefix_output => 'prefix_line_output', message_multiple => 'All power source lines are ok' }, + { name => 'ps', type => 3, cb_prefix_output => 'prefix_ps_output', cb_long_output => 'ps_long_output', indent_long_output => ' ', message_multiple => 'All power sources are ok', + group => [ + { name => 'global', type => 0, skipped_code => { -10 => 1 } }, + { name => 'line', display_long => 1, cb_prefix_output => 'prefix_line_output', message_multiple => 'All power source lines are ok', type => 1, skipped_code => { -10 => 1 } }, + ] + } ]; - $self->{maps_counters}->{ps} = [ - { label => 'power', set => { - key_values => [ { name => 'PwrTotal' }, { name => 'display' } ], + $self->{maps_counters}->{global} = [ + { label => 'power', nlabel => 'powersource.total.input.power.watt', set => { + key_values => [ { name => 'PwrTotal' } ], output_template => 'Total input power : %s W', output_error_template => "total input power : %s", perfdatas => [ { label => 'power', value => 'PwrTotal_absolute', template => '%s', - unit => 'W', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + unit => 'W', min => 0, label_extra_instance => 1 }, ], } }, - { label => 'energy', set => { - key_values => [ { name => 'EnergyAccum', diff => 1 }, { name => 'display' } ], + { label => 'energy', nlabel => 'powersource.total.accumulated.energy.kilowatthour', set => { + key_values => [ { name => 'EnergyAccum', diff => 1 } ], output_template => 'Total energy : %.3f kWh', output_error_template => "Total energy : %s", perfdatas => [ { label => 'energy', value => 'EnergyAccum_absolute', template => '%.3f', - unit => 'kWh', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + unit => 'kWh', min => 0, label_extra_instance => 1 }, ], } }, - { label => 'current-neutral', set => { - key_values => [ { name => 'EcNeutral' }, { name => 'display' } ], + { label => 'current-neutral', nlabel => 'powersource.neutral.current.ampacrms', set => { + key_values => [ { name => 'EcNeutral' } ], output_template => 'Current neutral : %s Amp AC RMS', output_error_template => "Current neutral : %s", perfdatas => [ { label => 'current_neutral', value => 'EcNeutral_absolute', template => '%s', - unit => 'AmpAcRMS', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + unit => 'AmpAcRMS', min => 0, label_extra_instance => 1 }, ], } }, ]; $self->{maps_counters}->{line} = [ - { label => 'line-load', set => { - key_values => [ { name => 'load' }, { name => 'display' } ], + { label => 'line-load', nlabel => 'line.load.percentage', set => { + key_values => [ { name => 'load' } ], output_template => 'Load : %.2f %%', output_error_template => "Load : %s", perfdatas => [ { label => 'line_load', value => 'load_absolute', template => '%.2f', - unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' }, + unit => '%', min => 0, max => 100, label_extra_instance => 1 }, ], } }, - { label => 'line-current', set => { - key_values => [ { name => 'current' }, { name => 'display' } ], + { label => 'line-current', nlabel => 'line.neutral.current.ampere', set => { + key_values => [ { name => 'current' }], output_template => 'Current : %.2f A', output_error_template => "Current : %s", perfdatas => [ { label => 'line_current', value => 'current_absolute', template => '%.2f', - unit => 'A', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + unit => 'A', min => 0, label_extra_instance => 1 }, ], } }, @@ -91,6 +95,12 @@ sub prefix_ps_output { return "Power source '" . $options{instance_value}->{display} . "' "; } +sub ps_long_output { + my ($self, %options) = @_; + + return "checking power source '" . $options{instance_value}->{display} . "'"; +} + sub prefix_line_output { my ($self, %options) = @_; @@ -102,10 +112,9 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); bless $self, $class; - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name' }, - }); + $options{options}->add_options(arguments => { + 'filter-name:s' => { name => 'filter_name' }, + }); return $self; } @@ -113,17 +122,21 @@ sub new { my %map_phase = (1 => 'phase1', 2 => 'phase2', 3 => 'phase3'); my $mapping = { + lgpPduEntryUsrLabel => { oid => '.1.3.6.1.4.1.476.1.42.3.8.20.1.10' }, + lgpPduEntrySysAssignLabel => { oid => '.1.3.6.1.4.1.476.1.42.3.8.20.1.15' }, +}; +my $mapping2 = { lgpPduPsEntrySysAssignLabel => { oid => '.1.3.6.1.4.1.476.1.42.3.8.30.20.1.15' }, lgpPduPsEntryEnergyAccum => { oid => '.1.3.6.1.4.1.476.1.42.3.8.30.20.1.50' }, # 0.1 Kilowatt-Hour lgpPduPsEntryPwrTotal => { oid => '.1.3.6.1.4.1.476.1.42.3.8.30.20.1.65' }, # Watt lgpPduPsEntryEcNeutral => { oid => '.1.3.6.1.4.1.476.1.42.3.8.30.20.1.70' }, # 0.1 Amp-AC-RMS }; -my $mapping2 = { +my $mapping3 = { lgpPduPsLineEntryLine => { oid => '.1.3.6.1.4.1.476.1.42.3.8.30.40.1.15', map => \%map_phase }, lgpPduPsLineEntryEcHundredths => { oid => '.1.3.6.1.4.1.476.1.42.3.8.30.40.1.22' }, # 0.01 A lgpPduPsLineEntryEcUsedBeforeAlarm => { oid => '.1.3.6.1.4.1.476.1.42.3.8.30.40.1.39' }, # % }; -my $oid_lgpPduEntryUsrLabel = '.1.3.6.1.4.1.476.1.42.3.8.20.1.10'; +my $oid_lgpPduEntry = '.1.3.6.1.4.1.476.1.42.3.8.20.1'; my $oid_lgpPduPsEntry = '.1.3.6.1.4.1.476.1.42.3.8.30.20.1'; my $oid_lgpPduPsLineEntry = '.1.3.6.1.4.1.476.1.42.3.8.30.40.1'; @@ -135,47 +148,54 @@ sub manage_selection { (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); $self->{ps} = {}; - $self->{results} = $options{snmp}->get_multiple_table(oids => [ { oid => $oid_lgpPduEntryUsrLabel }, - { oid => $oid_lgpPduPsEntry }, - { oid => $oid_lgpPduPsLineEntry } - ], - nothing_quit => 1); - foreach my $oid (keys %{$self->{results}->{$oid_lgpPduPsEntry}}) { - next if ($oid !~ /^$mapping->{lgpPduPsEntryPwrTotal}->{oid}\.(\d+)\.(\d+)/); + my $snmp_result = $options{snmp}->get_multiple_table( + oids => [ + { oid => $oid_lgpPduEntry, start => $mapping->{lgpPduEntryUsrLabel}->{oid}, end => $mapping->{lgpPduEntrySysAssignLabel}->{oid} }, + { oid => $oid_lgpPduPsEntry, start => $mapping2->{lgpPduPsEntrySysAssignLabel}->{oid}, end => $mapping2->{lgpPduPsEntryEcNeutral}->{oid} }, + { oid => $oid_lgpPduPsLineEntry, start => $mapping3->{lgpPduPsLineEntryLine}->{oid}, end => $mapping3->{lgpPduPsLineEntryEcUsedBeforeAlarm}->{oid} }, + ], + nothing_quit => 1 + ); + foreach my $oid (keys %{$snmp_result->{$oid_lgpPduPsEntry}}) { + next if ($oid !~ /^$mapping2->{lgpPduPsEntrySysAssignLabel}->{oid}\.(\d+)\.(\d+)/); my ($pdu_index, $ps_index) = ($1, $2); - my $result = $options{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_lgpPduPsEntry}, instance => $pdu_index . '.' . $ps_index); - my $pdu_name = defined($self->{results}->{$oid_lgpPduEntryUsrLabel}->{$oid_lgpPduEntryUsrLabel . '.' . $pdu_index}) && $self->{results}->{$oid_lgpPduEntryUsrLabel}->{$oid_lgpPduEntryUsrLabel . '.' . $pdu_index} ne '' ? - $self->{results}->{$oid_lgpPduEntryUsrLabel}->{$oid_lgpPduEntryUsrLabel . '.' . $pdu_index} : $pdu_index; - my $ps_name = defined($result->{lgpPduPsEntrySysAssignLabel}) && $result->{lgpPduPsEntrySysAssignLabel} ne '' ? - $result->{lgpPduPsEntrySysAssignLabel} : $ps_index; - my $name = $pdu_name . '/' . $ps_name; - + + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result->{$oid_lgpPduEntry}, instance => $pdu_index); + my $result2 = $options{snmp}->map_instance(mapping => $mapping2, results => $snmp_result->{$oid_lgpPduPsEntry}, instance => $pdu_index . '.' . $ps_index); + + my $name = (defined($result->{lgpPduEntryUsrLabel}) && $result->{lgpPduEntryUsrLabel} ne '' ? $result->{lgpPduEntryUsrLabel} : $result->{lgpPduEntrySysAssignLabel}); + $name .= '~' . $result2->{lgpPduPsEntrySysAssignLabel}; + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && $name !~ /$self->{option_results}->{filter_name}/) { $self->{output}->output_add(long_msg => "skipping '" . $name . "': no matching filter.", debug => 1); next; } - - $self->{ps}->{$pdu_index . '.' . $ps_index} = { display => $name, - EnergyAccum => $result->{lgpPduPsEntryEnergyAccum} * 0.1, - PwrTotal => $result->{lgpPduPsEntryPwrTotal}, - EcNeutral => $result->{lgpPduPsEntryEcNeutral} * 0.1}; - } - - $self->{line} = {}; - foreach my $oid (keys %{$self->{results}->{$oid_lgpPduPsLineEntry}}) { - next if ($oid !~ /^$mapping2->{lgpPduPsLineEntryEcUsedBeforeAlarm}->{oid}\.(\d+)\.(\d+)\.(\d+)/); - my ($pdu_index, $ps_index, $line_index) = ($1, $2, $3); - my $result = $options{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$oid_lgpPduPsLineEntry}, instance => $pdu_index . '.' . $ps_index . '.' . $line_index); - next if (!defined($self->{ps}->{$pdu_index . '.' . $ps_index})); - - $self->{line}->{$pdu_index . '.' . $ps_index . '.' . $line_index} = { - display => $self->{ps}->{$pdu_index . '.' . $ps_index}->{display} . '/' . $result->{lgpPduPsLineEntryLine}, - current => $result->{lgpPduPsLineEntryEcHundredths} * 0.01, - load => $result->{lgpPduPsLineEntryEcUsedBeforeAlarm}, + + $self->{ps}->{$name} = { + display => $name, + global => { + display => $name, + EnergyAccum => $result2->{lgpPduPsEntryEnergyAccum} * 0.1, + PwrTotal => $result2->{lgpPduPsEntryPwrTotal}, + EcNeutral => defined($result2->{lgpPduPsEntryEcNeutral}) ? $result2->{lgpPduPsEntryEcNeutral} * 0.1 : undef, + }, + line => {}, }; + + foreach my $oid (keys %{$snmp_result->{$oid_lgpPduPsLineEntry}}) { + next if ($oid !~ /^$mapping3->{lgpPduPsLineEntryEcUsedBeforeAlarm}->{oid}\.$pdu_index\.$ps_index\.(\d+)/); + my $line_index = $1; + my $result3 = $options{snmp}->map_instance(mapping => $mapping3, results => $snmp_result->{$oid_lgpPduPsLineEntry}, instance => $pdu_index . '.' . $ps_index . '.' . $line_index); + + $self->{ps}->{$name}->{line}->{$result3->{lgpPduPsLineEntryLine}} = { + display => $result3->{lgpPduPsLineEntryLine}, + current => defined($result3->{lgpPduPsLineEntryEcHundredths}) ? $result3->{lgpPduPsLineEntryEcHundredths} * 0.01 : undef, + load => $result3->{lgpPduPsLineEntryEcUsedBeforeAlarm}, + }; + } } - + if (scalar(keys %{$self->{ps}}) <= 0) { $self->{output}->add_option_msg(short_msg => "Cannot found power sources."); $self->{output}->option_exit(); diff --git a/centreon-plugins/hardware/pdu/emerson/snmp/mode/rbusage.pm b/centreon-plugins/hardware/pdu/emerson/snmp/mode/rbusage.pm deleted file mode 100644 index 8dce17930..000000000 --- a/centreon-plugins/hardware/pdu/emerson/snmp/mode/rbusage.pm +++ /dev/null @@ -1,190 +0,0 @@ -# -# Copyright 2019 Centreon (http://www.centreon.com/) -# -# Centreon is a full-fledged industry-strength solution that meets -# the needs in IT infrastructure and application monitoring for -# service performance. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -package hardware::pdu::emerson::snmp::mode::rbusage; - -use base qw(centreon::plugins::templates::counter); - -use strict; -use warnings; -use Digest::MD5 qw(md5_hex); - -sub set_counters { - my ($self, %options) = @_; - - $self->{maps_counters_type} = [ - { name => 'rb', type => 1, cb_prefix_output => 'prefix_rb_output', message_multiple => 'All receptacle branches are ok' }, - ]; - - $self->{maps_counters}->{rb} = [ - { label => 'energy', set => { - key_values => [ { name => 'EnergyAccum', diff => 1 }, { name => 'display' } ], - output_template => 'total energy : %.3f kWh', output_error_template => "total energy : %s", - perfdatas => [ - { label => 'energy', value => 'EnergyAccum_absolute', template => '%.3f', - unit => 'kWh', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, - ], - } - }, - { label => 'power-real-neutral', set => { - key_values => [ { name => 'Pwr' }, { name => 'display' } ], - output_template => 'line-to-neutral real power : %s W', output_error_template => "line-to-neutral real power : %s", - perfdatas => [ - { label => 'power_real_neutral', value => 'Pwr_absolute', template => '%s', - unit => 'W', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, - ], - } - }, - { label => 'power-apparent-neutral', set => { - key_values => [ { name => 'Ap' }, { name => 'display' } ], - output_template => 'line-to-neutral apparent power : %s VA', output_error_template => "line-to-neutral apparent power : %s", - perfdatas => [ - { label => 'power_apparent_neutral', value => 'Ap_absolute', template => '%s', - unit => 'VA', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, - ], - } - }, - { label => 'current-neutral', set => { - key_values => [ { name => 'EcHundredths' }, { name => 'display' } ], - output_template => 'line-to-neutral current : %s Amp AC RMS', output_error_template => "line-to-neutral current : %s", - perfdatas => [ - { label => 'current_neutral', value => 'EcHundredths_absolute', template => '%s', - unit => 'AmpAcRMS', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, - ], - } - }, - { label => 'potential-neutral', set => { - key_values => [ { name => 'EpLNTenths' }, { name => 'display' } ], - output_template => 'line-to-neutral potential : %s VoltRMS', output_error_template => "line-to-neutral potential : %s", - perfdatas => [ - { label => 'potential_neutral', value => 'EpLNTenths_absolute', template => '%s', - unit => 'VoltRMS', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, - ], - } - }, - ]; -} - -sub prefix_rb_output { - my ($self, %options) = @_; - - return "Receptacle branch '" . $options{instance_value}->{display} . "' "; -} - -sub new { - my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); - bless $self, $class; - - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name' }, - }); - - return $self; -} - -my $mapping = { - lgpPduRbEntryUsrLabel => { oid => '.1.3.6.1.4.1.476.1.42.3.8.40.20.1.8' }, - lgpPduRbEntryEnergyAccum => { oid => '.1.3.6.1.4.1.476.1.42.3.8.40.20.1.85' }, # 0.1 Kilowatt-Hour - lgpPduRbEntryEpLNTenths => { oid => '.1.3.6.1.4.1.476.1.42.3.8.40.20.1.100' }, # 0.1 VoltRMS - lgpPduRbEntryPwr => { oid => '.1.3.6.1.4.1.476.1.42.3.8.40.20.1.115' }, # Watt - lgpPduRbEntryAp => { oid => '.1.3.6.1.4.1.476.1.42.3.8.40.20.1.120' }, # VoltAmp - lgpPduRbEntryEcHundredths => { oid => '.1.3.6.1.4.1.476.1.42.3.8.40.20.1.130' }, # 0.01 Amp-AC-RMS -}; -my $oid_lgpPduEntryUsrLabel = '.1.3.6.1.4.1.476.1.42.3.8.20.1.10'; -my $oid_lgpPduRbEntry = '.1.3.6.1.4.1.476.1.42.3.8.40.20.1'; - -sub manage_selection { - my ($self, %options) = @_; - - $self->{cache_name} = "pdu_emerson_" . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' . - (defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all')) . '_' . - (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); - - $self->{rb} = {}; - $self->{results} = $options{snmp}->get_multiple_table(oids => [ { oid => $oid_lgpPduEntryUsrLabel }, - { oid => $oid_lgpPduRbEntry }, - ], - nothing_quit => 1); - foreach my $oid (keys %{$self->{results}->{$oid_lgpPduRbEntry}}) { - next if ($oid !~ /^$mapping->{lgpPduRbEntryPwr}->{oid}\.(\d+)\.(\d+)/); - my ($pdu_index, $rb_index) = ($1, $2); - my $result = $options{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_lgpPduRbEntry}, instance => $pdu_index . '.' . $rb_index); - my $pdu_name = defined($self->{results}->{$oid_lgpPduEntryUsrLabel}->{$oid_lgpPduEntryUsrLabel . '.' . $pdu_index}) && $self->{results}->{$oid_lgpPduEntryUsrLabel}->{$oid_lgpPduEntryUsrLabel . '.' . $pdu_index} ne '' ? - $self->{results}->{$oid_lgpPduEntryUsrLabel}->{$oid_lgpPduEntryUsrLabel . '.' . $pdu_index} : $pdu_index; - my $rb_name = defined($result->{lgpPduRbEntryUsrLabel}) && $result->{lgpPduRbEntryUsrLabel} ne '' ? - $result->{lgpPduRbEntryUsrLabel} : $rb_index; - my $name = $pdu_name . '/' . $rb_name; - - if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && - $name !~ /$self->{option_results}->{filter_name}/) { - $self->{output}->output_add(long_msg => "skipping '" . $name . "': no matching filter.", debug => 1); - next; - } - - $self->{rb}->{$pdu_index . '.' . $rb_index} = { display => $name, - EnergyAccum => $result->{lgpPduRbEntryEnergyAccum} * 0.1, - EpLNTenths => $result->{lgpPduRbEntryEpLNTenths} * 0.1, - Pwr => $result->{lgpPduRbEntryPwr}, - Ap => $result->{lgpPduRbEntryAp}, - EcHundredths => $result->{lgpPduRbEntryEcHundredths} * 0.01}; - } - - if (scalar(keys %{$self->{rb}}) <= 0) { - $self->{output}->add_option_msg(short_msg => "Cannot found receptacle branches."); - $self->{output}->option_exit(); - } -} - -1; - -__END__ - -=head1 MODE - -Check receptacle branch usage. - -=over 8 - -=item B<--filter-name> - -Filter receptacle branch name (can be a regexp). - -=item B<--filter-counters> - -Only display some counters (regexp can be used). -Example: --filter-counters='^(energy)$' - -=item B<--warning-*> - -Threshold warning. -Can be: 'energy', 'power-real-neutral', 'power-apparent-neutral', -'current-neutral', 'potential-neutral'. - -=item B<--critical-*> - -Threshold critical. -Can be: 'energy', 'power-real-neutral', 'power-apparent-neutral', -'current-neutral', 'potential-neutral'. - -=back - -=cut diff --git a/centreon-plugins/hardware/pdu/liebert/snmp/mode/receptacles.pm b/centreon-plugins/hardware/pdu/emerson/snmp/mode/receptacles.pm similarity index 81% rename from centreon-plugins/hardware/pdu/liebert/snmp/mode/receptacles.pm rename to centreon-plugins/hardware/pdu/emerson/snmp/mode/receptacles.pm index cc5516a95..5246d3c7f 100644 --- a/centreon-plugins/hardware/pdu/liebert/snmp/mode/receptacles.pm +++ b/centreon-plugins/hardware/pdu/emerson/snmp/mode/receptacles.pm @@ -18,7 +18,27 @@ # limitations under the License. # -package hardware::pdu::liebert::snmp::mode::receptacles; +# +# Copyright 2019 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package hardware::pdu::emerson::snmp::mode::receptacles; use base qw(centreon::plugins::templates::counter); @@ -47,7 +67,7 @@ sub set_counters { { name => 'global', type => 0, skipped_code => { -10 => 1 } }, { name => 'rcp', display_long => 1, cb_prefix_output => 'prefix_rcp_output', message_multiple => 'All receptacles are ok', type => 1, skipped_code => { -10 => 1 } }, ] - } + } ]; $self->{maps_counters}->{global} = [ @@ -69,7 +89,7 @@ sub set_counters { ], } }, - { label => 'line2neutral-apparent-power', nlabel => 'powersource.line2neutral.apparent.power.voltampere', set => { + { label => 'line2neutral-apparent-power', nlabel => 'receptaclebranch.line2neutral.apparent.power.voltampere', set => { key_values => [ { name => 'lgpPduRbEntryAp' } ], output_template => 'line-to-neutral apparent power : %s VA', perfdatas => [ @@ -78,6 +98,24 @@ sub set_counters { ], } }, + { label => 'current-neutral', nlabel => 'receptaclebranch.line2neutral.current.ampacrms', set => { + key_values => [ { name => 'lgpPduRbEntryEcHundredths' } ], + output_template => 'line-to-neutral current : %s Amp AC RMS', + perfdatas => [ + { value => 'lgpPduRbEntryEcHundredths_absolute', template => '%s', + unit => 'AmpAcRMS', min => 0, label_extra_instance => 1 }, + ], + } + }, + { label => 'potential-neutral', nlabel => 'receptaclebranch.line2neutral.potential.voltrms', set => { + key_values => [ { name => 'lgpPduRbEntryEpLNTenths' } ], + output_template => 'line-to-neutral potential : %s VoltRMS', + perfdatas => [ + { value => 'lgpPduRbEntryEpLNTenths_absolute', template => '%s', + unit => 'VoltRMS', min => 0, label_extra_instance => 1 }, + ], + } + }, ]; $self->{maps_counters}->{rcp} = [ @@ -146,8 +184,10 @@ sub manage_selection { lgpPduRbEntryUsrLabel => { oid => '.1.3.6.1.4.1.476.1.42.3.8.40.20.1.8' }, lgpPduRbEntrySysAssignLabel => { oid => '.1.3.6.1.4.1.476.1.42.3.8.40.20.1.20' }, lgpPduRbEntryEnergyAccum => { oid => '.1.3.6.1.4.1.476.1.42.3.8.40.20.1.85' }, # 0.1 Kilowatt-Hour + lgpPduRbEntryEpLNTenths => { oid => '.1.3.6.1.4.1.476.1.42.3.8.40.20.1.100' }, lgpPduRbEntryPwr => { oid => '.1.3.6.1.4.1.476.1.42.3.8.40.20.1.115' }, # Watt lgpPduRbEntryAp => { oid => '.1.3.6.1.4.1.476.1.42.3.8.40.20.1.120' }, # VA + lgpPduRbEntryEcHundredths => { oid => '.1.3.6.1.4.1.476.1.42.3.8.40.20.1.130' }, }; my $mapping3 = { lgpPduRcpEntryUsrLabel => { oid => '.1.3.6.1.4.1.476.1.42.3.8.50.20.1.10' }, @@ -162,7 +202,7 @@ sub manage_selection { my $snmp_result = $options{snmp}->get_multiple_table( oids => [ { oid => $oid_lgpPduEntry, start => $mapping->{lgpPduEntryUsrLabel}->{oid}, end => $mapping->{lgpPduEntrySysAssignLabel}->{oid} }, - { oid => $oid_lgpPduRbEntry, start => $mapping2->{lgpPduRbEntryUsrLabel}->{oid}, end => $mapping2->{lgpPduRbEntryAp}->{oid} }, + { oid => $oid_lgpPduRbEntry, start => $mapping2->{lgpPduRbEntryUsrLabel}->{oid}, end => $mapping2->{lgpPduRbEntryEcHundredths}->{oid} }, { oid => $oid_lgpPduRcpEntry, start => $mapping3->{lgpPduRcpEntryUsrLabel}->{oid}, end => $mapping3->{lgpPduRcpEntryOperationCondition}->{oid} }, ], nothing_quit => 1, @@ -186,6 +226,8 @@ sub manage_selection { } $result2->{lgpPduRbEntryEnergyAccum} /= 10; + $result2->{lgpPduRbEntryEcHundredths} *= 0.01 if (defined($result2->{lgpPduRbEntryEcHundredths})); + $result2->{lgpPduRbEntryEpLNTenths} *= 0.1 if (defined($result2->{lgpPduRbEntryEpLNTenths})); $self->{rb}->{$name} = { display => $name, global => { %$result2 }, diff --git a/centreon-plugins/hardware/pdu/emerson/snmp/plugin.pm b/centreon-plugins/hardware/pdu/emerson/snmp/plugin.pm index 332f112ed..0589649b5 100644 --- a/centreon-plugins/hardware/pdu/emerson/snmp/plugin.pm +++ b/centreon-plugins/hardware/pdu/emerson/snmp/plugin.pm @@ -31,10 +31,10 @@ sub new { $self->{version} = '1.0'; %{$self->{modes}} = ( - 'global-status' => 'hardware::pdu::emerson::snmp::mode::globalstatus', - 'ps-usage' => 'hardware::pdu::emerson::snmp::mode::psusage', - 'rb-usage' => 'hardware::pdu::emerson::snmp::mode::rbusage', - ); + 'global-status' => 'hardware::pdu::emerson::snmp::mode::globalstatus', + 'ps-usage' => 'hardware::pdu::emerson::snmp::mode::psusage', + 'receptacles' => 'hardware::pdu::emerson::snmp::mode::receptacles', + ); return $self; } diff --git a/centreon-plugins/hardware/pdu/liebert/snmp/mode/powersources.pm b/centreon-plugins/hardware/pdu/liebert/snmp/mode/powersources.pm deleted file mode 100644 index 2382f82aa..000000000 --- a/centreon-plugins/hardware/pdu/liebert/snmp/mode/powersources.pm +++ /dev/null @@ -1,164 +0,0 @@ -# -# Copyright 2019 Centreon (http://www.centreon.com/) -# -# Centreon is a full-fledged industry-strength solution that meets -# the needs in IT infrastructure and application monitoring for -# service performance. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -package hardware::pdu::liebert::snmp::mode::powersources; - -use base qw(centreon::plugins::templates::counter); - -use strict; -use warnings; -use Digest::MD5 qw(md5_hex); - -sub set_counters { - my ($self, %options) = @_; - - $self->{maps_counters_type} = [ - { name => 'ps', type => 1, cb_prefix_output => 'prefix_ps_output', message_multiple => 'All power sources are ok', skipped_code => { -10 => 1 } } - ]; - - $self->{maps_counters}->{ps} = [ - { label => 'total-accumulated-energy', nlabel => 'powersource.total.accumulated.energy.kilowatthour', set => { - key_values => [ { name => 'lgpPduPsEntryEnergyAccum', diff => 1 }, { name => 'display' } ], - output_template => 'total input power : %s kWh', - perfdatas => [ - { template => '%s', value => 'lgpPduPsEntryEnergyAccum_absolute', - unit => 'kWh', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, - ], - } - }, - { label => 'total-input-power', nlabel => 'powersource.total.input.power.watt', set => { - key_values => [ { name => 'lgpPduPsEntryPwrTotal' }, { name => 'display' } ], - output_template => 'total input power : %s W', - perfdatas => [ - { template => '%s', value => 'lgpPduPsEntryPwrTotal_absolute', - unit => 'W', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, - ], - } - }, - { label => 'total-apparent-power', nlabel => 'powersource.total.apparent.power.voltampere', set => { - key_values => [ { name => 'lgpPduPsEntryApTotal' }, { name => 'display' } ], - output_template => 'total apparent power : %s VA', - perfdatas => [ - { template => '%s', value => 'lgpPduPsEntryApTotal_absolute', - unit => 'VA', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, - ], - } - }, - ]; -} - -sub prefix_ps_output { - my ($self, %options) = @_; - - return "Power source '" . $options{instance_value}->{display} . "' "; -} - -sub new { - my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1, statefile => 1); - bless $self, $class; - - $options{options}->add_options(arguments => { - 'filter-name:s' => { name => 'filter_name' }, - }); - - return $self; -} - -sub manage_selection { - my ($self, %options) = @_; - - my $mapping = { - lgpPduEntryUsrLabel => { oid => '.1.3.6.1.4.1.476.1.42.3.8.20.1.10' }, - lgpPduEntrySysAssignLabel => { oid => '.1.3.6.1.4.1.476.1.42.3.8.20.1.15' }, - }; - my $mapping2 = { - lgpPduPsEntrySysAssignLabel => { oid => '.1.3.6.1.4.1.476.1.42.3.8.30.20.1.15' }, - lgpPduPsEntryEnergyAccum => { oid => '.1.3.6.1.4.1.476.1.42.3.8.30.20.1.50' }, # 0.1 Kilowatt-Hour - lgpPduPsEntryPwrTotal => { oid => '.1.3.6.1.4.1.476.1.42.3.8.30.20.1.65' }, # Watt - lgpPduPsEntryApTotal => { oid => '.1.3.6.1.4.1.476.1.42.3.8.30.20.1.90' }, # VoltAmp - }; - - my $oid_lgpPduEntry = '.1.3.6.1.4.1.476.1.42.3.8.20.1'; - my $oid_lgpPduPsEntry = '.1.3.6.1.4.1.476.1.42.3.8.30.20.1'; - my $snmp_result = $options{snmp}->get_multiple_table( - oids => [ - { oid => $oid_lgpPduEntry, start => $mapping->{lgpPduEntryUsrLabel}->{oid}, end => $mapping->{lgpPduEntrySysAssignLabel}->{oid} }, - { oid => $oid_lgpPduPsEntry, start => $mapping2->{lgpPduPsEntrySysAssignLabel}->{oid}, end => $mapping2->{lgpPduPsEntryApTotal}->{oid} }, - ], - nothing_quit => 1, - ); - - $self->{ps} = {}; - foreach my $oid (keys %{$snmp_result->{$oid_lgpPduPsEntry}}) { - next if ($oid !~ /^$mapping2->{lgpPduPsEntrySysAssignLabel}->{oid}\.(.*?)\.(.*)$/); - my ($pdu_index, $ps_index) = ($1, $2); - - my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result->{$oid_lgpPduEntry}, instance => $pdu_index); - my $result2 = $options{snmp}->map_instance(mapping => $mapping2, results => $snmp_result->{$oid_lgpPduPsEntry}, instance => $pdu_index . '.' . $ps_index); - - my $name = (defined($result->{lgpPduEntryUsrLabel}) && $result->{lgpPduEntryUsrLabel} ne '' ? $result->{lgpPduEntryUsrLabel} : $result->{lgpPduEntrySysAssignLabel}); - $name .= '~' . $result2->{lgpPduPsEntrySysAssignLabel}; - - if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && - $name !~ /$self->{option_results}->{filter_name}/) { - $self->{output}->output_add(long_msg => "skipping power source '" . $name . "'.", debug => 1); - next; - } - - $result2->{lgpPduPsEntryEnergyAccum} /= 10; - $self->{ps}->{$name} = { - display => $name, - %$result2 - }; - } - - if (scalar(keys %{$self->{ps}}) <= 0) { - $self->{output}->add_option_msg(short_msg => "No power source found."); - $self->{output}->option_exit(); - } - - $self->{cache_name} = "pdu_liebert_" . $self->{mode} . '_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . - (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')) . '_' . - (defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all')); -} - -1; - -__END__ - -=head1 MODE - -Check power sources - -=over 8 - -=item B<--filter-name> - -Filter power source name (can be a regexp). - -=item B<--warning-*> B<--critical-*> - -Thresholds. -Can be: 'total-accumulated-energy', 'total-input-power', 'total-apparent-power'. - -=back - -=cut diff --git a/centreon-plugins/hardware/pdu/liebert/snmp/plugin.pm b/centreon-plugins/hardware/pdu/liebert/snmp/plugin.pm deleted file mode 100644 index 7e00edd31..000000000 --- a/centreon-plugins/hardware/pdu/liebert/snmp/plugin.pm +++ /dev/null @@ -1,49 +0,0 @@ -# -# Copyright 2019 Centreon (http://www.centreon.com/) -# -# Centreon is a full-fledged industry-strength solution that meets -# the needs in IT infrastructure and application monitoring for -# service performance. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -package hardware::pdu::liebert::snmp::plugin; - -use strict; -use warnings; -use base qw(centreon::plugins::script_snmp); - -sub new { - my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); - bless $self, $class; - - $self->{version} = '0.1'; - %{$self->{modes}} = ( - 'power-sources' => 'hardware::pdu::liebert::snmp::mode::powersources', - 'receptacles' => 'hardware::pdu::liebert::snmp::mode::receptacles', - ); - - return $self; -} - -1; - -__END__ - -=head1 PLUGIN DESCRIPTION - -Check Liebert PDU in SNMP. - -=cut