Skip to content

Commit

Permalink
+ fix temperature sensor
Browse files Browse the repository at this point in the history
  • Loading branch information
garnier-quentin committed Jun 27, 2016
1 parent a175250 commit 19bcbab
Showing 1 changed file with 28 additions and 30 deletions.
58 changes: 28 additions & 30 deletions network/h3c/snmp/mode/components/sensor.pm
Original file line number Diff line number Diff line change
Expand Up @@ -71,40 +71,38 @@ sub check {
my $name = $self->get_long_name(instance => $instance);
$self->{components}->{sensor}->{total}++;

if (defined($result2->{EntityExtTemperatureThreshold}) &&
$result2->{EntityExtTemperatureThreshold} > 0 && $result2->{EntityExtTemperatureThreshold} < 65535) {
$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(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}));
}

next if (defined($result2->{EntityExtTemperature}) && $result2->{EntityExtTemperature} <= 0);
next if (defined($result2->{EntityExtTemperature}) && $result2->{EntityExtTemperature} <= 0);

($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result2->{EntityExtTemperature});
if ($checked == 0) {
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' } ]);
$warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-temperature-instance-' . $instance);
$crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-temperature-instance-' . $instance);
}
($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);

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}->perfdata_add(label => 'temp_' . $instance, unit => 'C',
value => $result2->{EntityExtTemperature},
warning => $warn,
critical => $crit,
);
$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}->perfdata_add(label => 'temp_' . $instance, unit => 'C',
value => $result2->{EntityExtTemperature},
warning => $warn,
critical => $crit,
);
}
}

Expand Down

0 comments on commit 19bcbab

Please sign in to comment.