Fix sensorgateway check

This commit is contained in:
Quentin Garnier 2015-03-13 11:42:20 +11:00
parent aa3614c285
commit 8973249c6c
2 changed files with 7 additions and 7 deletions

View File

@ -45,7 +45,7 @@ my $list_oids = {
3 => 9, 3 => 9,
4 => 13, 4 => 13,
5 => 17, 5 => 17,
} };
sub load { sub load {
my (%options) = @_; my (%options) = @_;
@ -60,7 +60,7 @@ sub check {
$self->{components}->{sensors} = {name => 'sensors', total => 0, skip => 0}; $self->{components}->{sensors} = {name => 'sensors', total => 0, skip => 0};
return if ($self->check_exclude(section => 'sensors')); return if ($self->check_exclude(section => 'sensors'));
foreach my $i (keys %{$list_oids}) { foreach my $i (sort keys %{$list_oids}) {
if (!defined($self->{results}->{$oid_control}->{'.1.3.6.1.4.1.17095.3.' . ($list_oids->{$i} + 1) . '.0'}) || if (!defined($self->{results}->{$oid_control}->{'.1.3.6.1.4.1.17095.3.' . ($list_oids->{$i} + 1) . '.0'}) ||
$self->{results}->{$oid_control}->{'.1.3.6.1.4.1.17095.3.' . ($list_oids->{$i} + 1) . '.0'} !~ /([0-9\.]+)/) { $self->{results}->{$oid_control}->{'.1.3.6.1.4.1.17095.3.' . ($list_oids->{$i} + 1) . '.0'} !~ /([0-9\.]+)/) {
$self->{output}->output_add(long_msg => sprintf("skip sensor '%s': no values", $self->{output}->output_add(long_msg => sprintf("skip sensor '%s': no values",
@ -68,15 +68,15 @@ sub check {
next; next;
} }
my $name = $self->{results}->{$oid_control}->{'.1.3.6.1.4.1.17095.3.' . ($list_oids->{$i}) . '.0'} my $name = $self->{results}->{$oid_control}->{'.1.3.6.1.4.1.17095.3.' . ($list_oids->{$i}) . '.0'};
my $value = $self->{results}->{$oid_control}->{'.1.3.6.1.4.1.17095.3.' . ($list_oids->{$i} + 1) . '.0'}; my $value = $self->{results}->{$oid_control}->{'.1.3.6.1.4.1.17095.3.' . ($list_oids->{$i} + 1) . '.0'};
next if ($self->check_exclude(section => 'sensors', instance => $temp)); next if ($self->check_exclude(section => 'sensors', instance => $name));
$self->{components}->{sensors}->{total}++; $self->{components}->{sensors}->{total}++;
$self->{output}->output_add(long_msg => sprintf("sensor '%s' value is %s.", $self->{output}->output_add(long_msg => sprintf("sensor '%s' value is %s.",
$name, $value)); $name, $value));
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'sensor', instance => $name, value => $value); my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'sensors', instance => $name, value => $value);
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit, $self->{output}->output_add(severity => $exit,
short_msg => sprintf("sensor '%s' value is %s", short_msg => sprintf("sensor '%s' value is %s",

View File

@ -273,12 +273,12 @@ Example: --threshold-overload='output,CRITICAL,^(?!(off)$)'
=item B<--warning> =item B<--warning>
Set warning threshold for temperatures and humidity (syntax: type,regexp,treshold) Set warning threshold for temperatures and humidity (syntax: type,regexp,treshold)
Example: --warning='sensors,.*,30' --warning='sensors,.*,90' Example: --warning='sensors,Int. Temp,30' --warning='sensors,Fuel Level,50:'
=item B<--critical> =item B<--critical>
Set critical threshold for temperature and humidity (syntax: type,regexp,treshold) Set critical threshold for temperature and humidity (syntax: type,regexp,treshold)
Example: --critical='sensors,.*,40' Example: --warning='sensors,Int. Temp,35' --warning='sensors,Fuel Level,40:'
=back =back