diff --git a/centreon-plugins/network/brocade/snmp/mode/hardware.pm b/centreon-plugins/network/brocade/snmp/mode/hardware.pm index b1697b057..ca51e456d 100644 --- a/centreon-plugins/network/brocade/snmp/mode/hardware.pm +++ b/centreon-plugins/network/brocade/snmp/mode/hardware.pm @@ -29,9 +29,9 @@ sub set_system { my ($self, %options) = @_; $self->{regexp_threshold_numeric_check_section_option} = '^(temperature|fan)$'; - + $self->{cb_hook2} = 'snmp_execute'; - + $self->{thresholds} = { sensor => [ ['unknown', 'UNKNOWN'], @@ -49,7 +49,7 @@ sub set_system { ['absent', 'OK'] ] }; - + $self->{components_path} = 'network::brocade::snmp::mode::components'; $self->{components_module} = ['switch', 'sensor']; } @@ -133,7 +133,7 @@ my $mapping = { swSensorType => { oid => '.1.3.6.1.4.1.1588.2.1.1.1.1.22.1.2', map => \%map_type }, swSensorStatus => { oid => '.1.3.6.1.4.1.1588.2.1.1.1.1.22.1.3', map => \%map_status }, swSensorValue => { oid => '.1.3.6.1.4.1.1588.2.1.1.1.1.22.1.4' }, - swSensorInfo => { oid => '.1.3.6.1.4.1.1588.2.1.1.1.1.22.1.5' }, + swSensorInfo => { oid => '.1.3.6.1.4.1.1588.2.1.1.1.1.22.1.5' } }; my $oid_swSensorEntry = '.1.3.6.1.4.1.1588.2.1.1.1.1.22.1'; @@ -154,28 +154,40 @@ sub check { next if ($oid !~ /^$mapping->{swSensorStatus}->{oid}\.(.*)$/); my $instance = $1; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_swSensorEntry}, instance => $instance); - + next if ($self->check_filter(section => 'sensor', instance => $instance)); next if ($result->{swSensorStatus} =~ /absent/i && $self->absent_problem(section => 'sensor', instance => $instance)); $result->{swSensorInfo} = centreon::plugins::misc::trim($result->{swSensorInfo}); $self->{components}->{sensor}->{total}++; - $self->{output}->output_add(long_msg => sprintf("%s sensor '%s' status is '%s' [instance = %s]", - $result->{swSensorType}, $result->{swSensorInfo}, $result->{swSensorStatus}, $instance)); + $self->{output}->output_add( + long_msg => sprintf( + "%s sensor '%s' status is '%s' [instance = %s]", + $result->{swSensorType}, $result->{swSensorInfo}, $result->{swSensorStatus}, $instance + ) + ); my $exit = $self->get_severity(section => 'sensor', value => $result->{swSensorStatus}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("%s sensor '%s' status is '%s'", $result->{swSensorType}, $result->{swSensorInfo})); + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf("%s sensor '%s' status is '%s'", $result->{swSensorType}, $result->{swSensorInfo}, $result->{swSensorStatus}) + ); } - + if ($result->{swSensorValue} > 0 && $result->{swSensorType} ne 'power-supply') { my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => $result->{swSensorType}, instance => $instance, value => $result->{swSensorValue}); if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) { - $self->{output}->output_add(severity => $exit2, - short_msg => sprintf("%s sensor '%s' is %s %s", $result->{swSensorType}, $result->{swSensorInfo}, $result->{swSensorValue}, - $map_unit{$result->{swSensorType}})); + $self->{output}->output_add( + severity => $exit2, + short_msg => sprintf( + "%s sensor '%s' is %s %s", + $result->{swSensorType}, $result->{swSensorInfo}, $result->{swSensorValue}, + $map_unit{$result->{swSensorType}} + ) + ); } + $self->{output}->perfdata_add( label => 'sensor', unit => $map_unit{$result->{swSensorType}}, nlabel => 'hardware.sensor.' . $result->{swSensorType} . '.' . $map_unit{$result->{swSensorType}}, @@ -199,19 +211,19 @@ my %map_oper_status = (1 => 'online', 2 => 'offline', 3 => 'testing', 4 => 'faul my $mapping_global = { swFirmwareVersion => { oid => '.1.3.6.1.4.1.1588.2.1.1.1.1.6' }, - swOperStatus => { oid => '.1.3.6.1.4.1.1588.2.1.1.1.1.7', map => \%map_oper_status }, + swOperStatus => { oid => '.1.3.6.1.4.1.1588.2.1.1.1.1.7', map => \%map_oper_status } }; my $oid_swSystem = '.1.3.6.1.4.1.1588.2.1.1.1.1'; sub load { my ($self) = @_; - + push @{$self->{request}}, { oid => $oid_swSystem, start => $mapping_global->{swFirmwareVersion}->{oid}, end => $mapping_global->{swOperStatus}->{oid} }; } sub check { my ($self) = @_; - + $self->{output}->output_add(long_msg => "Checking switch"); $self->{components}->{switch} = {name => 'switch', total => 0, skip => 0}; return if ($self->check_filter(section => 'switch')); @@ -221,14 +233,21 @@ sub check { $self->{components}->{switch}->{total}++; - $self->{output}->output_add(long_msg => sprintf("switch operational status is '%s' [firmware: %s].", - $result->{swOperStatus}, $result->{swFirmwareVersion} - )); + $self->{output}->output_add( + long_msg => sprintf( + "switch operational status is '%s' [firmware: %s].", + $result->{swOperStatus}, $result->{swFirmwareVersion} + ) + ); my $exit = $self->get_severity(section => 'switch', value => $result->{swOperStatus}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("switch operational status is '%s'", - $result->{swOperStatus})); + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf( + "switch operational status is '%s'", + $result->{swOperStatus} + ) + ); } }