This commit is contained in:
qgarnier 2017-12-11 15:50:56 +01:00
parent 57a0ca4cf0
commit 7e6f296fa8
7 changed files with 202 additions and 88 deletions

View File

@ -25,64 +25,73 @@ use warnings;
use hardware::sensors::akcp::snmp::mode::components::resources qw(%map_default1_status %map_online);
my $mapping = {
hhmsSensorArrayHumidityDescription => { oid => '.1.3.6.1.4.1.3854.1.2.2.1.17.1.1' },
hhmsSensorArrayHumidityPercent => { oid => '.1.3.6.1.4.1.3854.1.2.2.1.17.1.3' },
hhmsSensorArrayHumidityStatus => { oid => '.1.3.6.1.4.1.3854.1.2.2.1.17.1.4', map => \%map_default1_status },
hhmsSensorArrayHumidityOnline => { oid => '.1.3.6.1.4.1.3854.1.2.2.1.17.1.5', map => \%map_online },
hhmsSensorArrayHumidityHighWarning => { oid => '.1.3.6.1.4.1.3854.1.2.2.1.17.1.7' },
hhmsSensorArrayHumidityHighCritical => { oid => '.1.3.6.1.4.1.3854.1.2.2.1.17.1.8' },
hhmsSensorArrayHumidityLowWarning => { oid => '.1.3.6.1.4.1.3854.1.2.2.1.17.1.9' },
hhmsSensorArrayHumidityLowCritical => { oid => '.1.3.6.1.4.1.3854.1.2.2.1.17.1.10' },
HumidityDescription => { oid => '.1.3.6.1.4.1.3854.1.2.2.1.17.1.1' }, # hhmsSensorArrayHumidityDescription
HumidityPercent => { oid => '.1.3.6.1.4.1.3854.1.2.2.1.17.1.3' }, # hhmsSensorArrayHumidityPercent
HumidityStatus => { oid => '.1.3.6.1.4.1.3854.1.2.2.1.17.1.4', map => \%map_default1_status }, # hhmsSensorArrayHumidityStatus
HumidityOnline => { oid => '.1.3.6.1.4.1.3854.1.2.2.1.17.1.5', map => \%map_online }, # hhmsSensorArrayHumidityOnline
HumidityHighWarning => { oid => '.1.3.6.1.4.1.3854.1.2.2.1.17.1.7' }, # hhmsSensorArrayHumidityHighWarning
HumidityHighCritical => { oid => '.1.3.6.1.4.1.3854.1.2.2.1.17.1.8' }, # hhmsSensorArrayHumidityHighCritical
HumidityLowWarning => { oid => '.1.3.6.1.4.1.3854.1.2.2.1.17.1.9' }, # hhmsSensorArrayHumidityLowWarning
HumidityLowCritical => { oid => '.1.3.6.1.4.1.3854.1.2.2.1.17.1.10' }, # hhmsSensorArrayHumidityLowCritical
};
my $mapping2 = {
HumidityDescription => { oid => '.1.3.6.1.4.1.3854.3.5.3.1.2' }, # humidityDescription
HumidityPercent => { oid => '.1.3.6.1.4.1.3854.3.5.3.1.4' }, # humidityPercent
HumidityStatus => { oid => '.1.3.6.1.4.1.3854.3.5.3.1.6', map => \%map_default1_status }, # humidityStatus
HumidityOnline => { oid => '.1.3.6.1.4.1.3854.3.5.3.1.8', map => \%map_online }, # humidityGoOffline
HumidityHighWarning => { oid => '.1.3.6.1.4.1.3854.3.5.3.1.11' }, # humidityHighWarning
HumidityHighCritical => { oid => '.1.3.6.1.4.1.3854.3.5.3.1.12' }, # humidityHighCritical
HumidityLowWarning => { oid => '.1.3.6.1.4.1.3854.3.5.3.1.10' }, # humidityLowWarning
HumidityLowCritical => { oid => '.1.3.6.1.4.1.3854.3.5.3.1.9' }, # humidityLowCritical
};
my $oid_hhmsSensorArrayHumidityEntry = '.1.3.6.1.4.1.3854.1.2.2.1.17.1';
my $oid_humidityEntry = '.1.3.6.1.4.1.3854.3.5.3.1';
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $oid_hhmsSensorArrayHumidityEntry };
push @{$self->{request}}, { oid => $oid_hhmsSensorArrayHumidityEntry },
{ oid => $oid_humidityEntry, end => $mapping2->{HumidityHighCritical}->{oid} };
}
sub check {
my ($self) = @_;
sub check_humidity {
my ($self, %options) = @_;
$self->{output}->output_add(long_msg => "Checking humidities");
$self->{components}->{humidity} = {name => 'humidities', total => 0, skip => 0};
return if ($self->check_filter(section => 'humidity'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_hhmsSensorArrayHumidityEntry}})) {
next if ($oid !~ /^$mapping->{hhmsSensorArrayHumidityOnline}->{oid}\.(.*)$/);
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$options{entry}}})) {
next if ($oid !~ /^$options{mapping}->{HumidityOnline}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_hhmsSensorArrayHumidityEntry}, instance => $instance);
my $result = $self->{snmp}->map_instance(mapping => $options{mapping}, results => $self->{results}->{$options{entry}}, instance => $instance);
next if ($self->check_filter(section => 'humidity', instance => $instance));
if ($result->{hhmsSensorArrayHumidityOnline} eq 'offline') {
$self->{output}->output_add(long_msg => sprintf("skipping '%s': is offline", $result->{hhmsSensorArrayHumidityDescription}));
if ($result->{HumidityOnline} eq 'offline') {
$self->{output}->output_add(long_msg => sprintf("skipping '%s': is offline", $result->{HumidityDescription}));
next;
}
$self->{components}->{humidity}->{total}++;
$self->{output}->output_add(long_msg => sprintf("humidity '%s' status is '%s' [instance = %s] [value = %s]",
$result->{hhmsSensorArrayHumidityDescription}, $result->{hhmsSensorArrayHumidityStatus}, $instance,
$result->{hhmsSensorArrayHumidityPercent}));
$result->{HumidityDescription}, $result->{HumidityStatus}, $instance,
$result->{HumidityPercent}));
my $exit = $self->get_severity(label => 'default1', section => 'humidity', value => $result->{hhmsSensorArrayHumidityStatus});
my $exit = $self->get_severity(label => 'default1', section => 'humidity', value => $result->{HumidityStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Humdity '%s' status is '%s'", $result->{hhmsSensorArrayHumidityDescription}, $result->{hhmsSensorArrayHumidityStatus}));
short_msg => sprintf("Humdity '%s' status is '%s'", $result->{HumidityDescription}, $result->{HumidityStatus}));
}
my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'humidity', instance => $instance, value => $result->{hhmsSensorArrayHumidityPercent});
my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'humidity', instance => $instance, value => $result->{HumidityPercent});
if ($checked == 0) {
$result->{hhmsSensorArrayHumidityLowWarning} = (defined($result->{hhmsSensorArrayHumidityLowWarning}) && $result->{hhmsSensorArrayHumidityLowWarning} =~ /[0-9]/) ?
$result->{hhmsSensorArrayHumidityLowWarning} : '';
$result->{hhmsSensorArrayHumidityLowCritical} = (defined($result->{hhmsSensorArrayHumidityLowCritical}) && $result->{hhmsSensorArrayHumidityLowCritical} =~ /[0-9]/) ?
$result->{hhmsSensorArrayHumidityLowCritical} : '';
$result->{hhmsSensorArrayHumidityHighWarning} = (defined($result->{hhmsSensorArrayHumidityHighWarning}) && $result->{hhmsSensorArrayHumidityHighWarning} =~ /[0-9]/) ?
$result->{hhmsSensorArrayHumidityHighWarning} : '';
$result->{hhmsSensorArrayHumidityHighCritical} = (defined($result->{hhmsSensorArrayHumidityHighCritical}) && $result->{hhmsSensorArrayHumidityHighCritical} =~ /[0-9]/) ?
$result->{hhmsSensorArrayHumidityHighCritical} : '';
my $warn_th = $result->{hhmsSensorArrayHumidityLowWarning} . ':' . $result->{hhmsSensorArrayHumidityHighWarning};
my $crit_th = $result->{hhmsSensorArrayHumidityLowCritical} . ':' . $result->{hhmsSensorArrayHumidityHighCritical};
$result->{HumidityLowWarning} = (defined($result->{HumidityLowWarning}) && $result->{HumidityLowWarning} =~ /[0-9]/) ?
$result->{HumidityLowWarning} : '';
$result->{HumidityLowCritical} = (defined($result->{HumidityLowCritical}) && $result->{HumidityLowCritical} =~ /[0-9]/) ?
$result->{HumidityLowCritical} : '';
$result->{HumidityHighWarning} = (defined($result->{HumidityHighWarning}) && $result->{HumidityHighWarning} =~ /[0-9]/) ?
$result->{HumidityHighWarning} : '';
$result->{HumidityHighCritical} = (defined($result->{HumidityHighCritical}) && $result->{HumidityHighCritical} =~ /[0-9]/) ?
$result->{HumidityHighCritical} : '';
my $warn_th = $result->{HumidityLowWarning} . ':' . $result->{HumidityHighWarning};
my $crit_th = $result->{HumidityLowCritical} . ':' . $result->{HumidityHighCritical};
$self->{perfdata}->threshold_validate(label => 'warning-humidity-instance-' . $instance, value => $warn_th);
$self->{perfdata}->threshold_validate(label => 'critical-humidity-instance-' . $instance, value => $crit_th);
@ -92,14 +101,25 @@ sub check {
if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit2,
short_msg => sprintf("Humdity '%s' is %s %%", $result->{hhmsSensorArrayHumidityDescription}, $result->{hhmsSensorArrayHumidityPercent}));
short_msg => sprintf("Humdity '%s' is %s %%", $result->{HumidityDescription}, $result->{HumidityPercent}));
}
$self->{output}->perfdata_add(label => 'humidity_' . $result->{hhmsSensorArrayHumidityDescription}, unit => '%',
value => $result->{hhmsSensorArrayHumidityPercent},
$self->{output}->perfdata_add(label => 'humidity_' . $result->{HumidityDescription}, unit => '%',
value => $result->{HumidityPercent},
warning => $warn,
critical => $crit,
min => 0, max => 100);
}
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking humidities");
$self->{components}->{humidity} = {name => 'humidities', total => 0, skip => 0};
return if ($self->check_filter(section => 'humidity'));
check_humidity($self, entry => $oid_hhmsSensorArrayHumidityEntry, mapping => $mapping);
check_humidity($self, entry => $oid_humidityEntry, mapping => $mapping2);
}
1;

View File

@ -40,6 +40,8 @@ our @EXPORT_OK = qw(%map_default1_status %map_default2_status %map_online %map_d
5 => 'lowWarning',
6 => 'lowCritical',
7 => 'sensorError',
8 => 'relayOn',
9 => 'relayOff',
);
%map_default2_status = (

View File

@ -64,7 +64,6 @@ sub check {
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Serial '%s' status is '%s'", $result->{hhmsSensorArraySerialDescription}, $result->{hhmsSensorArraySerialStatus}));
next;
}
}
}

View File

@ -64,7 +64,6 @@ sub check {
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Switch '%s' status is '%s'", $result->{hhmsSensorArraySwitchDescription}, $result->{hhmsSensorArraySwitchStatus}));
next;
}
}
}

View File

@ -25,65 +25,75 @@ use warnings;
use hardware::sensors::akcp::snmp::mode::components::resources qw(%map_default1_status %map_online %map_degree_type);
my $mapping = {
hhmsSensorArrayTempDescription => { oid => '.1.3.6.1.4.1.3854.1.2.2.1.16.1.1' },
hhmsSensorArrayTempDegree => { oid => '.1.3.6.1.4.1.3854.1.2.2.1.16.1.3' },
hhmsSensorArrayTempStatus => { oid => '.1.3.6.1.4.1.3854.1.2.2.1.16.1.4', map => \%map_default1_status },
hhmsSensorArrayTempOnline => { oid => '.1.3.6.1.4.1.3854.1.2.2.1.16.1.5', map => \%map_online },
hhmsSensorArrayTempHighWarning => { oid => '.1.3.6.1.4.1.3854.1.2.2.1.16.1.7' },
hhmsSensorArrayTempHighCritical => { oid => '.1.3.6.1.4.1.3854.1.2.2.1.16.1.8' },
hhmsSensorArrayTempLowWarning => { oid => '.1.3.6.1.4.1.3854.1.2.2.1.16.1.9' },
hhmsSensorArrayTempLowCritical => { oid => '.1.3.6.1.4.1.3854.1.2.2.1.16.1.10' },
hhmsSensorArrayTempDegreeType => { oid => '.1.3.6.1.4.1.3854.1.2.2.1.16.1.12', map => \%map_degree_type },
TempDescription => { oid => '.1.3.6.1.4.1.3854.1.2.2.1.16.1.1' }, # hhmsSensorArrayTempDescription
TempDegree => { oid => '.1.3.6.1.4.1.3854.1.2.2.1.16.1.3' }, # hhmsSensorArrayTempDegree
TempStatus => { oid => '.1.3.6.1.4.1.3854.1.2.2.1.16.1.4', map => \%map_default1_status }, # hhmsSensorArrayTempStatus
TempOnline => { oid => '.1.3.6.1.4.1.3854.1.2.2.1.16.1.5', map => \%map_online }, # hhmsSensorArrayTempOnline
TempHighWarning => { oid => '.1.3.6.1.4.1.3854.1.2.2.1.16.1.7' }, # hhmsSensorArrayTempHighWarning
TempHighCritical => { oid => '.1.3.6.1.4.1.3854.1.2.2.1.16.1.8' }, # hhmsSensorArrayTempHighCritical
TempLowWarning => { oid => '.1.3.6.1.4.1.3854.1.2.2.1.16.1.9' }, # hhmsSensorArrayTempLowWarning
TempLowCritical => { oid => '.1.3.6.1.4.1.3854.1.2.2.1.16.1.10' }, # hhmsSensorArrayTempLowCritical
TempDegreeType => { oid => '.1.3.6.1.4.1.3854.1.2.2.1.16.1.12', map => \%map_degree_type }, # hhmsSensorArrayTempDegreeType
};
my $mapping2 = {
TempDescription => { oid => '.1.3.6.1.4.1.3854.3.5.2.1.2' }, # temperatureDescription
TempDegree => { oid => '.1.3.6.1.4.1.3854.3.5.2.1.4' }, # temperatureDegree
TempStatus => { oid => '.1.3.6.1.4.1.3854.3.5.2.1.6', map => \%map_default1_status }, # temperatureStatus
TempOnline => { oid => '.1.3.6.1.4.1.3854.3.5.2.1.8', map => \%map_online }, # temperatureGoOffline
TempHighWarning => { oid => '.1.3.6.1.4.1.3854.3.5.2.1.11' }, # temperatureHighWarning
TempHighCritical => { oid => '.1.3.6.1.4.1.3854.3.5.2.1.12' }, # temperatureHighCritical
TempLowWarning => { oid => '.1.3.6.1.4.1.3854.3.5.2.1.10' }, # temperatureLowWarning
TempLowCritical => { oid => '.1.3.6.1.4.1.3854.3.5.2.1.9' }, # temperatureLowCritical
TempDegreeType => { oid => '.1.3.6.1.4.1.3854.3.5.2.1.5'}, # temperatureUnit
};
my $oid_hhmsSensorArrayTempEntry = '.1.3.6.1.4.1.3854.1.2.2.1.16.1';
my $oid_temperatureEntry = '.1.3.6.1.4.1.3854.3.5.2.1';
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $oid_hhmsSensorArrayTempEntry };
push @{$self->{request}}, { oid => $oid_hhmsSensorArrayTempEntry },
{ oid => $oid_temperatureEntry, end => $mapping2->{TempHighCritical}->{oid} };
}
sub check {
my ($self) = @_;
sub check_temperature {
my ($self, %options) = @_;
$self->{output}->output_add(long_msg => "Checking temperatures");
$self->{components}->{temperature} = {name => 'temperatures', total => 0, skip => 0};
return if ($self->check_filter(section => 'temperature'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_hhmsSensorArrayTempEntry}})) {
next if ($oid !~ /^$mapping->{hhmsSensorArrayTempOnline}->{oid}\.(.*)$/);
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$options{entry}}})) {
next if ($oid !~ /^$options{mapping}->{TempOnline}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_hhmsSensorArrayTempEntry}, instance => $instance);
my $result = $self->{snmp}->map_instance(mapping => $options{mapping}, results => $self->{results}->{$options{entry}}, instance => $instance);
next if ($self->check_filter(section => 'temperature', instance => $instance));
if ($result->{hhmsSensorArrayTempOnline} eq 'offline') {
$self->{output}->output_add(long_msg => sprintf("skipping '%s': is offline", $result->{hhmsSensorArrayTempDescription}));
if ($result->{TempOnline} eq 'offline') {
$self->{output}->output_add(long_msg => sprintf("skipping '%s': is offline", $result->{TempDescription}));
next;
}
$self->{components}->{temperature}->{total}++;
$self->{output}->output_add(long_msg => sprintf("temperature '%s' status is '%s' [instance = %s] [value = %s]",
$result->{hhmsSensorArrayTempDescription}, $result->{hhmsSensorArrayTempStatus}, $instance,
$result->{hhmsSensorArrayTempDegree}));
$result->{TempDescription}, $result->{TempStatus}, $instance,
$result->{TempDegree}));
my $exit = $self->get_severity(label => 'default1', section => 'temperature', value => $result->{hhmsSensorArrayTempStatus});
my $exit = $self->get_severity(label => 'default1', section => 'temperature', value => $result->{TempStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Temperature '%s' status is '%s'", $result->{hhmsSensorArrayTempDescription}, $result->{hhmsSensorArrayTempStatus}));
short_msg => sprintf("Temperature '%s' status is '%s'", $result->{TempDescription}, $result->{TempStatus}));
}
my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{hhmsSensorArrayTempDegree});
my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{TempDegree});
if ($checked == 0) {
$result->{hhmsSensorArrayTempLowWarning} = (defined($result->{hhmsSensorArrayTempLowWarning}) && $result->{hhmsSensorArrayTempLowWarning} =~ /[0-9]/) ?
$result->{hhmsSensorArrayTempLowWarning} : '';
$result->{hhmsSensorArrayTempLowCritical} = (defined($result->{hhmsSensorArrayTempLowCritical}) && $result->{hhmsSensorArrayTempLowCritical} =~ /[0-9]/) ?
$result->{hhmsSensorArrayTempLowCritical} : '';
$result->{hhmsSensorArrayTempHighWarning} = (defined($result->{hhmsSensorArrayTempHighWarning}) && $result->{hhmsSensorArrayTempHighWarning} =~ /[0-9]/) ?
$result->{hhmsSensorArrayTempHighWarning} : '';
$result->{hhmsSensorArrayTempHighCritical} = (defined($result->{hhmsSensorArrayTempHighCritical}) && $result->{hhmsSensorArrayTempHighCritical} =~ /[0-9]/) ?
$result->{hhmsSensorArrayTempHighCritical} : '';
my $warn_th = $result->{hhmsSensorArrayTempLowWarning} . ':' . $result->{hhmsSensorArrayTempHighWarning};
my $crit_th = $result->{hhmsSensorArrayTempLowCritical} . ':' . $result->{hhmsSensorArrayTempHighCritical};
$result->{TempLowWarning} = (defined($result->{TempLowWarning}) && $result->{TempLowWarning} =~ /[0-9]/) ?
$result->{TempLowWarning} * $options{threshold_mult} : '';
$result->{TempLowCritical} = (defined($result->{TempLowCritical}) && $result->{TempLowCritical} =~ /[0-9]/) ?
$result->{TempLowCritical} * $options{threshold_mult} : '';
$result->{TempHighWarning} = (defined($result->{TempHighWarning}) && $result->{TempHighWarning} =~ /[0-9]/) ?
$result->{TempHighWarning} * $options{threshold_mult} : '';
$result->{TempHighCritical} = (defined($result->{TempHighCritical}) && $result->{TempHighCritical} =~ /[0-9]/) ?
$result->{TempHighCritical} * $options{threshold_mult} : '';
my $warn_th = $result->{TempLowWarning} . ':' . $result->{TempHighWarning};
my $crit_th = $result->{TempLowCritical} . ':' . $result->{TempHighCritical};
$self->{perfdata}->threshold_validate(label => 'warning-temperature-instance-' . $instance, value => $warn_th);
$self->{perfdata}->threshold_validate(label => 'critical-temperature-instance-' . $instance, value => $crit_th);
@ -93,14 +103,25 @@ sub check {
if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit2,
short_msg => sprintf("Temperature '%s' is %s %s", $result->{hhmsSensorArrayTempDescription}, $result->{hhmsSensorArrayTempDegree}, $result->{hhmsSensorArrayTempDegreeType}));
short_msg => sprintf("Temperature '%s' is %s %s", $result->{TempDescription}, $result->{TempDegree}, $result->{TempDegreeType}));
}
$self->{output}->perfdata_add(label => 'temperature_' . $result->{hhmsSensorArrayTempDescription}, unit => $result->{hhmsSensorArrayTempDegreeType},
value => $result->{hhmsSensorArrayTempDegree},
$self->{output}->perfdata_add(label => 'temperature_' . $result->{TempDescription}, unit => $result->{TempDegreeType},
value => $result->{TempDegree},
warning => $warn,
critical => $crit,
);
}
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking temperatures");
$self->{components}->{temperature} = {name => 'temperatures', total => 0, skip => 0};
return if ($self->check_filter(section => 'temperature'));
check_temperature($self, entry => $oid_hhmsSensorArrayTempEntry, mapping => $mapping, threshold_mult => 1);
check_temperature($self, entry => $oid_temperatureEntry, mapping => $mapping2, threshold_mult => 0.1);
}
1;

View File

@ -0,0 +1,71 @@
#
# Copyright 2017 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package hardware::sensors::akcp::snmp::mode::components::water;
use strict;
use warnings;
use hardware::sensors::akcp::snmp::mode::components::resources qw(%map_default1_status %map_online);
my $mapping = {
waterDescription => { oid => '.1.3.6.1.4.1.3854.3.5.9.1.2' },
waterStatus => { oid => '.1.3.6.1.4.1.3854.3.5.9.1.6', map => \%map_default1_status },
waterGoOffline => { oid => '.1.3.6.1.4.1.3854.3.5.9.1.8', map => \%map_online },
};
my $oid_waterEntry = '.1.3.6.1.4.1.3854.3.5.9.1';
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $oid_waterEntry, end => $mapping->{waterGoOffline}->{oid} };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking waters");
$self->{components}->{water} = {name => 'waters', total => 0, skip => 0};
return if ($self->check_filter(section => 'water'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_waterEntry}})) {
next if ($oid !~ /^$mapping->{waterGoOffline}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_waterEntry}, instance => $instance);
next if ($self->check_filter(section => 'water', instance => $instance));
if ($result->{waterGoOffline} eq 'offline') {
$self->{output}->output_add(long_msg => sprintf("skipping '%s': is offline", $result->{waterDescription}));
next;
}
$self->{components}->{water}->{total}++;
$self->{output}->output_add(long_msg => sprintf("water '%s' status is '%s' [instance = %s]",
$result->{waterDescription}, $result->{waterStatus}, $instance,
));
my $exit = $self->get_severity(label => 'default1', section => 'water', value => $result->{waterStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Water '%s' status is '%s'", $result->{waterDescription}, $result->{waterStatus}));
}
}
}
1;

View File

@ -28,7 +28,7 @@ use warnings;
sub set_system {
my ($self, %options) = @_;
$self->{regexp_threshold_overload_check_section_option} = '^(temperature|humidity|switch|serial)$';
$self->{regexp_threshold_overload_check_section_option} = '^(temperature|humidity|switch|serial|water)$';
$self->{regexp_threshold_numeric_check_section_option} = '^(temperature|humidity)$';
$self->{cb_hook2} = 'snmp_execute';
@ -42,6 +42,8 @@ sub set_system {
['lowWarning', 'WARNING'],
['lowCritical', 'CRITICAL'],
['sensorError', 'CRITICAL'],
['relayOn', 'OK'],
['relayOff', 'OK'],
],
default2 => [
['noStatus', 'OK'],
@ -52,7 +54,7 @@ sub set_system {
};
$self->{components_path} = 'hardware::sensors::akcp::snmp::mode::components';
$self->{components_module} = ['temperature', 'humidity', 'switch', 'serial'];
$self->{components_module} = ['temperature', 'humidity', 'switch', 'serial', 'water'];
}
sub snmp_execute {
@ -88,7 +90,7 @@ Check sensors.
=item B<--component>
Which component to check (Default: '.*').
Can be: 'temperature', 'humidity', 'switch', 'serial'.
Can be: 'temperature', 'humidity', 'switch', 'serial', 'water'.
=item B<--filter>