From d3fa0fde0ed7ce7ebca98ab7899fc1ead0660db9 Mon Sep 17 00:00:00 2001 From: qgarnier Date: Wed, 15 Jun 2022 14:31:41 +0200 Subject: [PATCH] (plugin) network::alcatel::omniswitch::snmp - add temperature metrics (#3738) --- .../snmp/mode/components/backplane.pm | 4 +- .../snmp/mode/components/chassis.pm | 188 ++++++++++++++++-- .../snmp/mode/components/container.pm | 4 +- .../omniswitch/snmp/mode/components/fan.pm | 10 +- .../omniswitch/snmp/mode/components/module.pm | 4 +- .../omniswitch/snmp/mode/components/other.pm | 4 +- .../omniswitch/snmp/mode/components/psu.pm | 10 +- .../snmp/mode/components/resources.pm | 23 ++- .../omniswitch/snmp/mode/components/sensor.pm | 12 +- .../omniswitch/snmp/mode/components/stack.pm | 4 +- .../snmp/mode/components/unknown.pm | 4 +- .../alcatel/omniswitch/snmp/mode/hardware.pm | 73 ++++--- 12 files changed, 268 insertions(+), 72 deletions(-) diff --git a/centreon-plugins/network/alcatel/omniswitch/snmp/mode/components/backplane.pm b/centreon-plugins/network/alcatel/omniswitch/snmp/mode/components/backplane.pm index 2ac722a12..3214cedcf 100644 --- a/centreon-plugins/network/alcatel/omniswitch/snmp/mode/components/backplane.pm +++ b/centreon-plugins/network/alcatel/omniswitch/snmp/mode/components/backplane.pm @@ -59,9 +59,9 @@ sub check { if ($result->{chasEntPhysPower} > 0) { $self->{output}->perfdata_add( - label => "power", unit => 'W', nlabel => 'hardware.backplane.power.watt', - instances => $instance, + unit => 'W', + instances => [$result->{entPhysicalName}, $result->{entPhysicalDescr}, $instance], value => $result->{chasEntPhysPower}, min => 0 ); diff --git a/centreon-plugins/network/alcatel/omniswitch/snmp/mode/components/chassis.pm b/centreon-plugins/network/alcatel/omniswitch/snmp/mode/components/chassis.pm index 4ad37e21d..1477022f7 100644 --- a/centreon-plugins/network/alcatel/omniswitch/snmp/mode/components/chassis.pm +++ b/centreon-plugins/network/alcatel/omniswitch/snmp/mode/components/chassis.pm @@ -26,6 +26,157 @@ use network::alcatel::omniswitch::snmp::mode::components::resources qw(%oids $ma sub load {} +sub check_temp_aos6 { + my ($self, %options) = @_; + + my $mapping_temp = { + boardTemp => { oid => '.1.3.6.1.4.1.6486.800.1.1.1.3.1.1.3.1.4', default => -1 }, # chasHardwareBoardTemp + threshold => { oid => '.1.3.6.1.4.1.6486.800.1.1.1.3.1.1.3.1.7', default => -1 }, # chasTempThreshold + danger => { oid => '.1.3.6.1.4.1.6486.800.1.1.1.3.1.1.3.1.8', default => -1 } # chasDangerTempThreshold + }; + + my $result = $self->{snmp}->map_instance(mapping => $mapping_temp, results => $self->{results}->{entity}, instance => $options{instance}); + + return if ($result->{boardTemp} <= 0); + + $self->{output}->output_add( + long_msg => sprintf( + "chassis '%s/%s' [instance: %s] board temperature is %s degree centigrade", + $options{name}, + $options{descr}, + $options{instance}, + $result->{boardTemp} + ) + ); + + my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $options{instance}, value => $result->{boardTemp}); + if ($checked == 0) { + my $warn_th = $result->{threshold} > 0 ? $result->{threshold} : ''; + my $crit_th = $result->{danger} > 0 ? $result->{danger} : ''; + + $self->{perfdata}->threshold_validate(label => 'warning-temperature-instance-' . $options{instance}, value => $warn_th); + $self->{perfdata}->threshold_validate(label => 'critical-temperature-instance-' . $options{instance}, value => $crit_th); + + $exit = $self->{perfdata}->threshold_check( + value => $result->{boardTemp}, + threshold => [ + { label => 'critical-temperature-instance-' . $options{instance}, exit_litteral => 'critical' }, + { label => 'warning-temperature-instance-' . $options{instance}, exit_litteral => 'warning' } + ] + ); + + $warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-temperature-instance-' . $options{instance}); + $crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-temperature-instance-' . $options{instance}) + } + + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf( + "chassis '%s/%s/%s' board temperature is %s degree centigrade", + $options{name}, + $options{descr}, + $options{instance}, + $result->{boardTemp} + ) + ); + } + + $self->{output}->perfdata_add( + nlabel => 'hardware.temperature.celsius', + unit => 'C', + instances => [$options{name}, $options{descr}, $options{instance}, 'Chassis'], + value => $result->{boardTemp}, + warning => $warn, + critical => $crit + ); +} + +sub check_temp_aos7 { + my ($self, %options) = @_; + + my $mapping_temp = { + threshold => { oid => '.1.3.6.1.4.1.6486.801.1.1.1.3.1.1.3.1.5', default => -1 }, # chasTempThreshold + danger => { oid => '.1.3.6.1.4.1.6486.801.1.1.1.3.1.1.3.1.6', default => -1 }, # chasDangerTempThreshold + CPMA => { oid => '.1.3.6.1.4.1.6486.801.1.1.1.3.1.1.3.1.8', default => -1 }, # chasCPMAHardwareBoardTemp + CFMA => { oid => '.1.3.6.1.4.1.6486.801.1.1.1.3.1.1.3.1.9', default => -1 }, # chasCFMAHardwareBoardTemp + CPMB => { oid => '.1.3.6.1.4.1.6486.801.1.1.1.3.1.1.3.1.10', default => -1 }, # chasCPMBHardwareBoardTemp + CFMB => { oid => '.1.3.6.1.4.1.6486.801.1.1.1.3.1.1.3.1.11', default => -1 }, # chasCFMBHardwareBoardTemp + CFMC => { oid => '.1.3.6.1.4.1.6486.801.1.1.1.3.1.1.3.1.12', default => -1 }, # chasCFMCHardwareBoardTemp + CFMD => { oid => '.1.3.6.1.4.1.6486.801.1.1.1.3.1.1.3.1.13', default => -1 }, # chasCFMDHardwareBoardTemp + FanTray1 => { oid => '.1.3.6.1.4.1.6486.801.1.1.1.3.1.1.3.1.14', default => -1 }, # chasFTAHardwareBoardTemp + FanTray2 => { oid => '.1.3.6.1.4.1.6486.801.1.1.1.3.1.1.3.1.15', default => -1 }, # chasFTBHardwareBoardTemp + NI1 => { oid => '.1.3.6.1.4.1.6486.801.1.1.1.3.1.1.3.1.16', default => -1 }, # chasNI1HardwareBoardTemp + NI2 => { oid => '.1.3.6.1.4.1.6486.801.1.1.1.3.1.1.3.1.17', default => -1 }, # chasNI2HardwareBoardTemp + NI3 => { oid => '.1.3.6.1.4.1.6486.801.1.1.1.3.1.1.3.1.18', default => -1 }, # chasNI3HardwareBoardTemp + NI4 => { oid => '.1.3.6.1.4.1.6486.801.1.1.1.3.1.1.3.1.19', default => -1 }, # chasNI4HardwareBoardTemp + NI5 => { oid => '.1.3.6.1.4.1.6486.801.1.1.1.3.1.1.3.1.20', default => -1 }, # chasNI5HardwareBoardTemp + NI6 => { oid => '.1.3.6.1.4.1.6486.801.1.1.1.3.1.1.3.1.21', default => -1 }, # chasNI6HardwareBoardTemp + NI7 => { oid => '.1.3.6.1.4.1.6486.801.1.1.1.3.1.1.3.1.22', default => -1 }, # chasNI7HardwareBoardTemp + NI8 => { oid => '.1.3.6.1.4.1.6486.801.1.1.1.3.1.1.3.1.23', default => -1 } # chasNI8HardwareBoardTemp + }; + + my $result = $self->{snmp}->map_instance(mapping => $mapping_temp, results => $self->{results}->{entity}, instance => $options{instance}); + + foreach my $sensor ('CPMA', 'CFMA', 'CPMB', 'CFMB', 'CFMC', 'CFMD', 'FanTray1', 'FanTray2', 'NI1', 'NI2', 'NI3', 'NI4', 'NI5', 'NI6', 'NI7', 'NI8') { + next if ($result->{$sensor} <= 0); + + $self->{output}->output_add( + long_msg => sprintf( + "chassis '%s/%s/%s/%s' temperature is %s degree centigrade", + $options{name}, + $options{descr}, + $options{instance}, + $sensor, + $result->{$sensor} + ) + ); + + my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $options{instance}, value => $result->{$sensor}); + if ($checked == 0) { + my $warn_th = $result->{threshold} > 0 ? $result->{threshold} : ''; + my $crit_th = $result->{danger} > 0 ? $result->{danger} : ''; + + $self->{perfdata}->threshold_validate(label => 'warning-temperature-instance-' . $options{instance}, value => $warn_th); + $self->{perfdata}->threshold_validate(label => 'critical-temperature-instance-' . $options{instance}, value => $crit_th); + + $exit = $self->{perfdata}->threshold_check( + value => $result->{$sensor}, + threshold => [ + { label => 'critical-temperature-instance-' . $options{instance}, exit_litteral => 'critical' }, + { label => 'warning-temperature-instance-' . $options{instance}, exit_litteral => 'warning' } + ] + ); + + $warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-temperature-instance-' . $options{instance}); + $crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-temperature-instance-' . $options{instance}) + } + + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf( + "chassis '%s/%s/%s/%s' temperature is %s degree centigrade", + $options{name}, + $options{descr}, + $options{instance}, + $sensor, + $result->{$sensor} + ) + ); + } + + $self->{output}->perfdata_add( + nlabel => 'hardware.temperature.celsius', + unit => 'C', + instances => [$options{name}, $options{descr}, $options{instance}, $sensor], + value => $result->{$sensor}, + warning => $warn, + critical => $crit + ); + } +} + sub check { my ($self) = @_; @@ -34,46 +185,57 @@ sub check { return if ($self->check_filter(section => 'chassis')); my @instances = (); - foreach my $key (keys %{$self->{results}->{$oids{common}->{entPhysicalClass}}}) { - if ($self->{results}->{$oids{common}->{entPhysicalClass}}->{$key} == 3) { + foreach my $key (keys %{$self->{results}->{ $oids{common}->{entPhysicalClass} }}) { + if ($self->{results}->{ $oids{common}->{entPhysicalClass} }->{$key} == 3) { next if ($key !~ /^$oids{common}->{entPhysicalClass}\.(.*)$/); push @instances, $1; } } foreach my $instance (@instances) { - next if (!defined($self->{results}->{entity}->{$oids{$self->{type}}{chasEntPhysAdminStatus} . '.' . $instance})); + next if (!defined($self->{results}->{entity}->{ $oids{ $self->{type} }->{chasEntPhysAdminStatus} . '.' . $instance })); - my $result = $self->{snmp}->map_instance(mapping => $mapping->{$self->{type}}, results => $self->{results}->{entity}, instance => $instance); + my $result = $self->{snmp}->map_instance(mapping => $mapping->{ $self->{type} }, results => $self->{results}->{entity}, instance => $instance); next if ($self->check_filter(section => 'chassis', instance => $instance)); $self->{components}->{chassis}->{total}++; $self->{output}->output_add( long_msg => sprintf( - "chassis '%s/%s' [instance: %s, admin status: %s] operationnal status is %s.", - $result->{entPhysicalName}, $result->{entPhysicalDescr}, $instance, - $result->{chasEntPhysAdminStatus}, $result->{chasEntPhysOperStatus} + "chassis '%s/%s' [instance: %s, admin status: %s] operationnal status is %s", + $result->{entPhysicalName}, + $result->{entPhysicalDescr}, + $instance, + $result->{chasEntPhysAdminStatus}, + $result->{chasEntPhysOperStatus} ) ); if ($result->{chasEntPhysPower} > 0) { $self->{output}->perfdata_add( - label => "power", unit => 'W', nlabel => 'hardware.chassis.power.watt', - instances => $instance, + unit => 'W', + instances => [$result->{entPhysicalName}, $result->{entPhysicalDescr}, $instance], value => $result->{chasEntPhysPower}, min => 0 ); } - + + if ($self->{type} eq 'aos6') { + check_temp_aos6($self, instance => $instance, name => $result->{entPhysicalName}, descr => $result->{entPhysicalDescr}); + } else { + check_temp_aos7($self, instance => $instance, name => $result->{entPhysicalName}, descr => $result->{entPhysicalDescr}); + } + my $exit = $self->get_severity(label => 'admin', section => 'chassis.admin', value => $result->{chasEntPhysAdminStatus}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { $self->{output}->output_add( severity => $exit, short_msg => sprintf( "chassis '%s/%s/%s' admin status is %s", - $result->{entPhysicalName}, $result->{entPhysicalDescr}, $instance, + $result->{entPhysicalName}, + $result->{entPhysicalDescr}, + $instance, $result->{chasEntPhysAdminStatus} ) ); @@ -86,7 +248,9 @@ sub check { severity => $exit, short_msg => sprintf( "chassis '%s/%s/%s' operational status is %s", - $result->{entPhysicalName}, $result->{entPhysicalDescr}, $instance, + $result->{entPhysicalName}, + $result->{entPhysicalDescr}, + $instance, $result->{chasEntPhysOperStatus} ) ); diff --git a/centreon-plugins/network/alcatel/omniswitch/snmp/mode/components/container.pm b/centreon-plugins/network/alcatel/omniswitch/snmp/mode/components/container.pm index ddd502ef5..caf814eb3 100644 --- a/centreon-plugins/network/alcatel/omniswitch/snmp/mode/components/container.pm +++ b/centreon-plugins/network/alcatel/omniswitch/snmp/mode/components/container.pm @@ -59,9 +59,9 @@ sub check { if ($result->{chasEntPhysPower} > 0) { $self->{output}->perfdata_add( - label => "power", unit => 'W', nlabel => 'hardware.container.power.watt', - instances => $instance, + unit => 'W', + instances => [$result->{entPhysicalName}, $result->{entPhysicalDescr}, $instance], value => $result->{chasEntPhysPower}, min => 0 ); diff --git a/centreon-plugins/network/alcatel/omniswitch/snmp/mode/components/fan.pm b/centreon-plugins/network/alcatel/omniswitch/snmp/mode/components/fan.pm index 51b46164d..8b8318d68 100644 --- a/centreon-plugins/network/alcatel/omniswitch/snmp/mode/components/fan.pm +++ b/centreon-plugins/network/alcatel/omniswitch/snmp/mode/components/fan.pm @@ -40,7 +40,7 @@ sub check { return if ($self->check_filter(section => 'fan')); my @instances = (); - foreach my $key (keys %{$self->{results}->{$oids{common}->{entPhysicalClass}}}) { + foreach my $key (keys %{$self->{results}->{ $oids{common}->{entPhysicalClass} }}) { if ($self->{results}->{$oids{common}->{entPhysicalClass}}->{$key} == 7) { next if ($key !~ /^$oids{common}->{entPhysicalClass}\.(.*)$/); push @instances, $1; @@ -48,7 +48,7 @@ sub check { } foreach my $instance (@instances) { - next if (!defined($self->{results}->{entity}->{$oids{$self->{type}}{chasEntPhysAdminStatus} . '.' . $instance})); + next if (!defined($self->{results}->{entity}->{ $oids{ $self->{type} }->{chasEntPhysAdminStatus} . '.' . $instance })); my $result = $self->{snmp}->map_instance(mapping => $mapping->{$self->{type}}, results => $self->{results}->{entity}, instance => $instance); @@ -67,7 +67,7 @@ sub check { $self->{output}->perfdata_add( label => "power", unit => 'W', nlabel => 'hardware.fan.power.watt', - instances => $instance, + instances => [$result->{entPhysicalName}, $result->{entPhysicalDescr}, $instance], value => $result->{chasEntPhysPower}, min => 0 ); @@ -99,7 +99,9 @@ sub check { } } - foreach my $key (keys %{$self->{results}->{$oids{$self->{type}}->{alaChasEntPhysFanStatus}}}) { + return if ($self->{type} eq ''); + + foreach my $key (keys %{$self->{results}->{ $oids{ $self->{type} }->{alaChasEntPhysFanStatus} } }) { next if ($key !~ /^$oids{$self->{type}}->{alaChasEntPhysFanStatus}\.(.*?)\.(.*?)$/); my ($phys_index, $loc_index) = ($1, $2); my $status = $self->{results}->{$oids{$self->{type}}->{alaChasEntPhysFanStatus}}->{$key}; diff --git a/centreon-plugins/network/alcatel/omniswitch/snmp/mode/components/module.pm b/centreon-plugins/network/alcatel/omniswitch/snmp/mode/components/module.pm index ccf0cc081..a9ea63590 100644 --- a/centreon-plugins/network/alcatel/omniswitch/snmp/mode/components/module.pm +++ b/centreon-plugins/network/alcatel/omniswitch/snmp/mode/components/module.pm @@ -59,9 +59,9 @@ sub check { if ($result->{chasEntPhysPower} > 0) { $self->{output}->perfdata_add( - label => "power", unit => 'W', nlabel => 'hardware.module.power.watt', - instances => $instance, + unit => 'W', + instances => [$result->{entPhysicalName}, $result->{entPhysicalDescr}, $instance], value => $result->{chasEntPhysPower}, min => 0 ); diff --git a/centreon-plugins/network/alcatel/omniswitch/snmp/mode/components/other.pm b/centreon-plugins/network/alcatel/omniswitch/snmp/mode/components/other.pm index 19e025612..79677bd8c 100644 --- a/centreon-plugins/network/alcatel/omniswitch/snmp/mode/components/other.pm +++ b/centreon-plugins/network/alcatel/omniswitch/snmp/mode/components/other.pm @@ -59,9 +59,9 @@ sub check { if ($result->{chasEntPhysPower} > 0) { $self->{output}->perfdata_add( - label => "power", unit => 'W', nlabel => 'hardware.other.power.watt', - instances => $instance, + unit => 'W', + instances => [$result->{entPhysicalName}, $result->{entPhysicalDescr}, $instance], value => $result->{chasEntPhysPower}, min => 0 ); diff --git a/centreon-plugins/network/alcatel/omniswitch/snmp/mode/components/psu.pm b/centreon-plugins/network/alcatel/omniswitch/snmp/mode/components/psu.pm index 20ffcec0f..cd8f1d01d 100644 --- a/centreon-plugins/network/alcatel/omniswitch/snmp/mode/components/psu.pm +++ b/centreon-plugins/network/alcatel/omniswitch/snmp/mode/components/psu.pm @@ -34,7 +34,7 @@ sub check { return if ($self->check_filter(section => 'psu')); my @instances = (); - foreach my $key (keys %{$self->{results}->{$oids{common}->{entPhysicalClass}}}) { + foreach my $key (keys %{$self->{results}->{ $oids{common}->{entPhysicalClass} }}) { if ($self->{results}->{$oids{common}->{entPhysicalClass}}->{$key} == 6) { next if ($key !~ /^$oids{common}->{entPhysicalClass}\.(.*)$/); push @instances, $1; @@ -42,9 +42,9 @@ sub check { } foreach my $instance (@instances) { - next if (!defined($self->{results}->{entity}->{$oids{$self->{type}}{chasEntPhysAdminStatus} . '.' . $instance})); + next if (!defined($self->{results}->{entity}->{ $oids{ $self->{type} }->{chasEntPhysAdminStatus} . '.' . $instance })); - my $result = $self->{snmp}->map_instance(mapping => $mapping->{$self->{type}}, results => $self->{results}->{entity}, instance => $instance); + my $result = $self->{snmp}->map_instance(mapping => $mapping->{ $self->{type} }, results => $self->{results}->{entity}, instance => $instance); next if ($self->check_filter(section => 'psu', instance => $instance)); $self->{components}->{psu}->{total}++; @@ -59,9 +59,9 @@ sub check { if ($result->{chasEntPhysPower} > 0) { $self->{output}->perfdata_add( - label => "power", unit => 'W', nlabel => 'hardware.powersupply.power.watt', - instances => $instance, + unit => 'W', + instances => [$result->{entPhysicalName}, $result->{entPhysicalDescr}, $instance], value => $result->{chasEntPhysPower}, min => 0 ); diff --git a/centreon-plugins/network/alcatel/omniswitch/snmp/mode/components/resources.pm b/centreon-plugins/network/alcatel/omniswitch/snmp/mode/components/resources.pm index 1102f0431..73943ca39 100644 --- a/centreon-plugins/network/alcatel/omniswitch/snmp/mode/components/resources.pm +++ b/centreon-plugins/network/alcatel/omniswitch/snmp/mode/components/resources.pm @@ -82,29 +82,32 @@ our @EXPORT_OK = qw(%physical_class %phys_oper_status %phys_admin_status %oids $ }, aos6 => { entreprise_alcatel_base => '.1.3.6.1.4.1.6486.800', - + + version => '.1.3.6.1.4.1.6486.800.1.1.1.2.1.1.3.17.0', # systemHardwareUbootVersion + + chasPhysBase => '.1.3.6.1.4.1.6486.800.1.1.1.1.1.1.1', chasEntPhysAdminStatus => '.1.3.6.1.4.1.6486.800.1.1.1.1.1.1.1.1', chasEntPhysOperStatus => '.1.3.6.1.4.1.6486.800.1.1.1.1.1.1.1.2', chasEntPhysPower => '.1.3.6.1.4.1.6486.800.1.1.1.1.1.1.1.4', - - chasHardwareBoardTemp => '.1.3.6.1.4.1.6486.800.1.1.1.3.1.1.3.1.4', - chasTempThreshold => '.1.3.6.1.4.1.6486.800.1.1.1.3.1.1.3.1.7', - chasDangerTempThreshold => '.1.3.6.1.4.1.6486.800.1.1.1.3.1.1.3.1.8', + + chasChassisEntry => '.1.3.6.1.4.1.6486.800.1.1.1.3.1.1.3.1', alaChasEntPhysFanStatus => '.1.3.6.1.4.1.6486.800.1.1.1.3.1.1.11.1.2' }, aos7 => { entreprise_alcatel_base => '.1.3.6.1.4.1.6486.801', - + + version => '.1.3.6.1.4.1.6486.801.1.1.1.2.1.1.3.17.0', # systemHardwareUbootVersion + + chasPhysBase => '.1.3.6.1.4.1.6486.801.1.1.1.1.1.1.1', chasEntPhysAdminStatus => '.1.3.6.1.4.1.6486.801.1.1.1.1.1.1.1.1', chasEntPhysOperStatus => '.1.3.6.1.4.1.6486.801.1.1.1.1.1.1.1.2', chasEntPhysPower => '.1.3.6.1.4.1.6486.801.1.1.1.1.1.1.1.3', - - chasTempThreshold => '.1.3.6.1.4.1.6486.801.1.1.1.3.1.1.3.1.5', - chasDangerTempThreshold => '.1.3.6.1.4.1.6486.801.1.1.1.3.1.1.3.1.6', + + chasChassisEntry => '.1.3.6.1.4.1.6486.801.1.1.1.3.1.1.3.1', alaChasEntPhysFanStatus => '.1.3.6.1.4.1.6486.801.1.1.1.3.1.1.11.1.2' - }, + } ); $mapping = { diff --git a/centreon-plugins/network/alcatel/omniswitch/snmp/mode/components/sensor.pm b/centreon-plugins/network/alcatel/omniswitch/snmp/mode/components/sensor.pm index 3c71ec0f7..c85f40435 100644 --- a/centreon-plugins/network/alcatel/omniswitch/snmp/mode/components/sensor.pm +++ b/centreon-plugins/network/alcatel/omniswitch/snmp/mode/components/sensor.pm @@ -40,12 +40,12 @@ sub check { push @instances, $1; } } - + foreach my $instance (@instances) { next if (!defined($self->{results}->{entity}->{$oids{$self->{type}}{chasEntPhysAdminStatus} . '.' . $instance})); - + my $result = $self->{snmp}->map_instance(mapping => $mapping->{$self->{type}}, results => $self->{results}->{entity}, instance => $instance); - + next if ($self->check_filter(section => 'sensor', instance => $instance)); $self->{components}->{sensor}->{total}++; @@ -59,14 +59,14 @@ sub check { if ($result->{chasEntPhysPower} > 0) { $self->{output}->perfdata_add( - label => "power", unit => 'W', nlabel => 'hardware.sensor.power.watt', - instances => $instance, + unit => 'W', + instances => [$result->{entPhysicalName}, $result->{entPhysicalDescr}, $instance], value => $result->{chasEntPhysPower}, min => 0 ); } - + my $exit = $self->get_severity(label => 'admin', section => 'sensor.admin', value => $result->{chasEntPhysAdminStatus}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { $self->{output}->output_add( diff --git a/centreon-plugins/network/alcatel/omniswitch/snmp/mode/components/stack.pm b/centreon-plugins/network/alcatel/omniswitch/snmp/mode/components/stack.pm index 0afb9c2b8..f7ced6b1f 100644 --- a/centreon-plugins/network/alcatel/omniswitch/snmp/mode/components/stack.pm +++ b/centreon-plugins/network/alcatel/omniswitch/snmp/mode/components/stack.pm @@ -59,9 +59,9 @@ sub check { if ($result->{chasEntPhysPower} > 0) { $self->{output}->perfdata_add( - label => "power", unit => 'W', nlabel => 'hardware.stack.power.watt', - instances => $instance, + unit => 'W', + instances => [$result->{entPhysicalName}, $result->{entPhysicalDescr}, $instance], value => $result->{chasEntPhysPower}, min => 0 ); diff --git a/centreon-plugins/network/alcatel/omniswitch/snmp/mode/components/unknown.pm b/centreon-plugins/network/alcatel/omniswitch/snmp/mode/components/unknown.pm index fa949d80d..b3b20aab1 100644 --- a/centreon-plugins/network/alcatel/omniswitch/snmp/mode/components/unknown.pm +++ b/centreon-plugins/network/alcatel/omniswitch/snmp/mode/components/unknown.pm @@ -59,8 +59,8 @@ sub check { if ($result->{chasEntPhysPower} > 0) { $self->{output}->perfdata_add( - label => "power", unit => 'W', - nlabel => 'hardware.unknown.power.watt', + nlabel => [$result->{entPhysicalName}, $result->{entPhysicalDescr}, $instance], + unit => 'W', instances => $instance, value => $result->{chasEntPhysPower}, min => 0 diff --git a/centreon-plugins/network/alcatel/omniswitch/snmp/mode/hardware.pm b/centreon-plugins/network/alcatel/omniswitch/snmp/mode/hardware.pm index ae20f6c54..bc6ac0239 100644 --- a/centreon-plugins/network/alcatel/omniswitch/snmp/mode/hardware.pm +++ b/centreon-plugins/network/alcatel/omniswitch/snmp/mode/hardware.pm @@ -26,8 +26,10 @@ use network::alcatel::omniswitch::snmp::mode::components::resources qw(%oids); sub set_system { my ($self, %options) = @_; + $self->{regexp_threshold_numeric_check_section_option} = '^(temperature)$'; + $self->{cb_hook2} = 'snmp_execute'; - + $self->{thresholds} = { admin => [ ['^(reset|takeover|resetWithFabric|takeoverWithFabrc)$', 'WARNING'], @@ -58,34 +60,59 @@ sub snmp_execute { my ($self, %options) = @_; $self->{snmp} = $options{snmp}; - $self->{results} = $self->{snmp}->get_multiple_table(oids => [ - { oid => $oids{common}->{entPhysicalClass} }, - { oid => $oids{aos6}->{alaChasEntPhysFanStatus} }, - { oid => $oids{aos7}->{alaChasEntPhysFanStatus} } - ]); - $self->{results}->{entity} = $self->{snmp}->get_multiple_table(oids => [ - { oid => $oids{common}->{entPhysicalDescr} }, - { oid => $oids{common}->{entPhysicalName} }, - { oid => $oids{aos6}->{chasEntPhysAdminStatus} }, - { oid => $oids{aos6}->{chasEntPhysOperStatus} }, - { oid => $oids{aos6}->{chasEntPhysPower} }, - { oid => $oids{aos7}->{chasEntPhysAdminStatus} }, - { oid => $oids{aos7}->{chasEntPhysOperStatus} }, - { oid => $oids{aos7}->{chasEntPhysPower} } - ], return_type => 1); - $self->{type} = 'aos6'; - foreach (keys %{$self->{results}->{entity}}) { - if (/^$oids{aos7}->{entreprise_alcatel_base}\./) { - $self->{type} = 'aos7'; - last; - } + my $versions = $self->{snmp}->get_leef( + oids => [ $oids{aos6}->{version}, $oids{aos7}->{version} ] + ); + + $self->{type} = ''; + if (defined($versions->{ $oids{aos6}->{version} })) { + $self->{type} = 'aos6'; + } elsif (defined($versions->{ $oids{aos7}->{version} })) { + $self->{type} = 'aos7'; + } + + if ($self->{type} eq 'aos6') { + $self->{results} = $self->{snmp}->get_multiple_table( + oids => [ + { oid => $oids{common}->{entPhysicalClass} }, + { oid => $oids{aos6}->{alaChasEntPhysFanStatus} } + ] + ); + + $self->{results}->{entity} = $self->{snmp}->get_multiple_table( + oids => [ + { oid => $oids{common}->{entPhysicalDescr} }, + { oid => $oids{common}->{entPhysicalName} }, + { oid => $oids{aos6}->{chasPhysBase}, start => $oids{aos6}->{chasEntPhysAdminStatus}, end => $oids{aos6}->{chasEntPhysOperStatus} }, + { oid => $oids{aos6}->{chasEntPhysPower} }, + { oid => $oids{aos6}->{chasChassisEntry} } + ], + return_type => 1 + ); + } elsif ($self->{type} eq 'aos7') { + $self->{results} = $self->{snmp}->get_multiple_table( + oids => [ + { oid => $oids{common}->{entPhysicalClass} }, + { oid => $oids{aos7}->{alaChasEntPhysFanStatus} } + ] + ); + + $self->{results}->{entity} = $self->{snmp}->get_multiple_table( + oids => [ + { oid => $oids{common}->{entPhysicalDescr} }, + { oid => $oids{common}->{entPhysicalName} }, + { oid => $oids{aos7}->{chasPhysBase}, start => $oids{aos7}->{chasEntPhysAdminStatus}, end => $oids{aos7}->{chasEntPhysPower} }, + { oid => $oids{aos7}->{chasChassisEntry} } + ], + return_type => 1 + ); } } sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); bless $self, $class; $options{options}->add_options(arguments => {});