diff --git a/centreon-plugins/centreon/common/h3c/snmp/mode/components/default.pm b/centreon-plugins/centreon/common/h3c/snmp/mode/components/default.pm index 801dd2728..ff5a7ddd7 100644 --- a/centreon-plugins/centreon/common/h3c/snmp/mode/components/default.pm +++ b/centreon-plugins/centreon/common/h3c/snmp/mode/components/default.pm @@ -40,7 +40,7 @@ my %map_default_status = ( 61 => 'rpsError', 71 => 'moduleFaulty', 81 => 'sensorError', - 91 => 'hardwareFaulty', + 91 => 'hardwareFaulty' ); sub check { @@ -51,7 +51,7 @@ sub check { return if ($self->check_filter(section => $options{component})); my $mapping = { - EntityExtErrorStatus => { oid => $self->{branch} . '.19', map => \%map_default_status }, + EntityExtErrorStatus => { oid => $self->{branch} . '.19', map => \%map_default_status } }; foreach my $instance (sort $self->get_instance_class(class => { $options{component_class} => 1 })) { @@ -63,19 +63,25 @@ sub check { $self->absent_problem(section => $options{component}, instance => $instance); next; } - + my $name = ''; $name = $self->get_short_name(instance => $instance) if (defined($self->{short_name}) && $self->{short_name} == 1); $name = $self->get_long_name(instance => $instance) unless (defined($self->{short_name}) && $self->{short_name} == 1 && defined($name) && $name ne ''); $self->{components}->{$options{component}}->{total}++; - $self->{output}->output_add(long_msg => sprintf("%s '%s' status is '%s' [instance = %s]", - ucfirst($options{component}), $name, $result->{EntityExtErrorStatus}, $instance)); + $self->{output}->output_add( + long_msg => sprintf( + "%s '%s' status is '%s' [instance = %s]", + ucfirst($options{component}), $name, $result->{EntityExtErrorStatus}, $instance + ) + ); my $exit = $self->get_severity(section => $options{component}, value => $result->{EntityExtErrorStatus}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("%s '%s' status is '%s'", $options{component}, $name, $result->{EntityExtErrorStatus})); + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf("%s '%s' status is '%s'", $options{component}, $name, $result->{EntityExtErrorStatus}) + ); } } } -1; \ No newline at end of file +1; diff --git a/centreon-plugins/centreon/common/h3c/snmp/mode/components/fan.pm b/centreon-plugins/centreon/common/h3c/snmp/mode/components/fan.pm index 8fb8e0f7f..38792685b 100644 --- a/centreon-plugins/centreon/common/h3c/snmp/mode/components/fan.pm +++ b/centreon-plugins/centreon/common/h3c/snmp/mode/components/fan.pm @@ -28,7 +28,7 @@ my %map_fan_status = ( 2 => 'normal', 4 => 'entityAbsent', 41 => 'fanError', - 91 => 'hardwareFaulty', + 91 => 'hardwareFaulty' ); sub check { @@ -39,7 +39,7 @@ sub check { return if ($self->check_filter(section => 'fan')); my $mapping = { - EntityExtErrorStatus => { oid => $self->{branch} . '.19', map => \%map_fan_status }, + EntityExtErrorStatus => { oid => $self->{branch} . '.19', map => \%map_fan_status } }; foreach my $instance (sort $self->get_instance_class(class => { 7 => 1 })) { @@ -51,19 +51,25 @@ sub check { $self->absent_problem(section => 'fan', instance => $instance); next; } - + my $name = ''; $name = $self->get_short_name(instance => $instance) if (defined($self->{short_name}) && $self->{short_name} == 1); $name = $self->get_long_name(instance => $instance) unless (defined($self->{short_name}) && $self->{short_name} == 1 && defined($name) && $name ne ''); $self->{components}->{fan}->{total}++; - $self->{output}->output_add(long_msg => sprintf("Fan '%s' status is '%s' [instance = %s]", - $name, $result->{EntityExtErrorStatus}, $instance)); + $self->{output}->output_add( + long_msg => sprintf( + "Fan '%s' status is '%s' [instance: %s]", + $name, $result->{EntityExtErrorStatus}, $instance + ) + ); my $exit = $self->get_severity(section => 'fan', value => $result->{EntityExtErrorStatus}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("Fan '%s' status is '%s'", $name, $result->{EntityExtErrorStatus})); + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf("Fan '%s' status is '%s'", $name, $result->{EntityExtErrorStatus}) + ); } } } -1; \ No newline at end of file +1; diff --git a/centreon-plugins/centreon/common/h3c/snmp/mode/components/psu.pm b/centreon-plugins/centreon/common/h3c/snmp/mode/components/psu.pm index b3959a2b9..394dd34d3 100644 --- a/centreon-plugins/centreon/common/h3c/snmp/mode/components/psu.pm +++ b/centreon-plugins/centreon/common/h3c/snmp/mode/components/psu.pm @@ -28,14 +28,14 @@ my %map_psu_status = ( 2 => 'normal', 4 => 'entityAbsent', 51 => 'psuError', - 91 => 'hardwareFaulty', + 91 => 'hardwareFaulty' ); sub check { my ($self) = @_; $self->{output}->output_add(long_msg => "Checking power supplies"); - $self->{components}->{psu} = {name => 'power supplies', total => 0, skip => 0}; + $self->{components}->{psu} = { name => 'power supplies', total => 0, skip => 0 }; return if ($self->check_filter(section => 'psu')); my $mapping = { @@ -51,19 +51,25 @@ sub check { $self->absent_problem(section => 'psu', instance => $instance); next; } - + my $name = ''; $name = $self->get_short_name(instance => $instance) if (defined($self->{short_name}) && $self->{short_name} == 1); $name = $self->get_long_name(instance => $instance) unless (defined($self->{short_name}) && $self->{short_name} == 1 && defined($name) && $name ne ''); $self->{components}->{psu}->{total}++; - $self->{output}->output_add(long_msg => sprintf("Power supply '%s' status is '%s' [instance = %s]", - $name, $result->{EntityExtErrorStatus}, $instance)); + $self->{output}->output_add( + long_msg => sprintf( + "Power supply '%s' status is '%s' [instance: %s]", + $name, $result->{EntityExtErrorStatus}, $instance + ) + ); my $exit = $self->get_severity(section => 'psu', value => $result->{EntityExtErrorStatus}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("Power supply '%s' status is '%s'", $name, $result->{EntityExtErrorStatus})); + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf("Power supply '%s' status is '%s'", $name, $result->{EntityExtErrorStatus}) + ); } } } -1; \ No newline at end of file +1; diff --git a/centreon-plugins/centreon/common/h3c/snmp/mode/components/sensor.pm b/centreon-plugins/centreon/common/h3c/snmp/mode/components/sensor.pm index ac268b93c..e2eb0c35f 100644 --- a/centreon-plugins/centreon/common/h3c/snmp/mode/components/sensor.pm +++ b/centreon-plugins/centreon/common/h3c/snmp/mode/components/sensor.pm @@ -28,7 +28,7 @@ my %map_sensor_status = ( 2 => 'normal', 4 => 'entityAbsent', 81 => 'sensorError', - 91 => 'hardwareFaulty', + 91 => 'hardwareFaulty' ); sub check { @@ -49,54 +49,70 @@ sub check { my @instances = $self->get_instance_class(class => { 8 => 1 }); return if (scalar(@instances) == 0); - $self->{snmp}->load(oids => [$mapping2->{EntityExtTemperature}->{oid}, $mapping2->{EntityExtTemperatureThreshold}->{oid}], - instances => [@instances]); + $self->{snmp}->load( + oids => [$mapping2->{EntityExtTemperature}->{oid}, $mapping2->{EntityExtTemperatureThreshold}->{oid}], + instances => [@instances] + ); my $results = $self->{snmp}->get_leef(); - + my ($exit, $warn, $crit, $checked); foreach my $instance (sort @instances) { my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$self->{branch} . '.19'}, instance => $instance); my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $results, instance => $instance); - + next if (!defined($result->{EntityExtErrorStatus})); next if ($self->check_filter(section => 'sensor', instance => $instance)); if ($result->{EntityExtErrorStatus} =~ /entityAbsent/i) { $self->absent_problem(section => 'sensor', instance => $instance); next; } - + my $name = ''; $name = $self->get_short_name(instance => $instance) if (defined($self->{short_name}) && $self->{short_name} == 1); $name = $self->get_long_name(instance => $instance) unless (defined($self->{short_name}) && $self->{short_name} == 1 && defined($name) && $name ne ''); $self->{components}->{sensor}->{total}++; - - $self->{output}->output_add(long_msg => sprintf("Sensor '%s' status is '%s' [instance = %s]", - $name, $result->{EntityExtErrorStatus}, $instance)); + + $self->{output}->output_add( + long_msg => sprintf( + "Sensor '%s' status is '%s' [instance: %s]", + $name, $result->{EntityExtErrorStatus}, $instance + ) + ); $exit = $self->get_severity(section => 'sensor', value => $result->{EntityExtErrorStatus}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("Sensor '%s' status is '%s'", $name, $result->{EntityExtErrorStatus})); + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf("Sensor '%s' status is '%s'", $name, $result->{EntityExtErrorStatus}) + ); } - - next if (defined($result2->{EntityExtTemperature}) && $result2->{EntityExtTemperature} <= 0); - + + next if (defined($result2->{EntityExtTemperature}) && ($result2->{EntityExtTemperature} <= 0 || $result2->{EntityExtTemperature} == 65535)); + ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result2->{EntityExtTemperature}); if ($checked == 0 && defined($result2->{EntityExtTemperatureThreshold}) && $result2->{EntityExtTemperatureThreshold} > 0 && $result2->{EntityExtTemperatureThreshold} < 65535) { my $crit_th = '~:' . $result2->{EntityExtTemperatureThreshold}; $self->{perfdata}->threshold_validate(label => 'warning-temperature-instance-' . $instance, value => undef); $self->{perfdata}->threshold_validate(label => 'critical-temperature-instance-' . $instance, value => $crit_th); - - $exit = $self->{perfdata}->threshold_check(value => $result2->{EntityExtTemperature}, threshold => [ { label => 'critical-temperature-instance-' . $instance, exit_litteral => 'critical' }, - { label => 'warning-temperature-instance-' . $instance, exit_litteral => 'warning' } ]); + + $exit = $self->{perfdata}->threshold_check( + value => $result2->{EntityExtTemperature}, + threshold => [ + { label => 'critical-temperature-instance-' . $instance, exit_litteral => 'critical' }, + { label => 'warning-temperature-instance-' . $instance, exit_litteral => 'warning' } + ] + ); $warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-temperature-instance-' . $instance); $crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-temperature-instance-' . $instance); } - + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("Temperature sensor '%s' is %s degree centigrade", $name, $result2->{EntityExtTemperature})); + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf("Temperature sensor '%s' is %s degree centigrade", $name, $result2->{EntityExtTemperature}) + ); } + $self->{output}->perfdata_add( label => 'temp', unit => 'C', nlabel => 'hardware.sensor.temperature.celsius',