+ add netbotz plugin in snmp

This commit is contained in:
garnier-quentin 2016-11-17 11:20:32 +01:00
parent d4664329b0
commit de7d61e064
10 changed files with 761 additions and 0 deletions

View File

@ -0,0 +1,83 @@
#
# Copyright 2016 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::netbotz::snmp::mode::components::airflow;
use strict;
use warnings;
use hardware::sensors::netbotz::snmp::mode::components::resources qw(%map_status);
my $mapping = {
airFlowSensorId => { oid => '.1.3.6.1.4.1.5528.100.4.1.5.1.1' },
airFlowSensorValue => { oid => '.1.3.6.1.4.1.5528.100.4.1.5.1.2' },
airFlowSensorErrorStatus => { oid => '.1.3.6.1.4.1.5528.100.4.1.5.1.3', map => \%map_status },
airFlowSensorLabel => { oid => '.1.3.6.1.4.1.5528.100.4.1.5.1.4' },
};
my $oid_airFlowSensorEntry = '.1.3.6.1.4.1.5528.100.4.1.5.1';
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $oid_airFlowSensorEntry };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking air flows");
$self->{components}->{airflow} = {name => 'air flows', total => 0, skip => 0};
return if ($self->check_filter(section => 'airflow'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_airFlowSensorEntry}})) {
next if ($oid !~ /^$mapping->{airFlowSensorErrorStatus}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_airFlowSensorEntry}, instance => $instance);
next if ($self->check_filter(section => 'airflow', instance => $instance));
$self->{components}->{airflow}->{total}++;
$result->{airFlowSensorValue} *= 0.1;
my $label = defined($result->{airFlowSensorLabel}) && $result->{airFlowSensorLabel} ne '' ? $result->{airFlowSensorLabel} : $result->{airFlowSensorId};
$self->{output}->output_add(long_msg => sprintf("air flow '%s' status is '%s' [instance = %s] [value = %s]",
$label, $result->{airFlowSensorErrorStatus}, $instance,
$result->{airFlowSensorValue}));
my $exit = $self->get_severity(label => 'default', section => 'airflow', value => $result->{airFlowSensorErrorStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Air flow '%s' status is '%s'", $label, $result->{airFlowSensorErrorStatus}));
}
my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'airflow', instance => $instance, value => $result->{airFlowSensorValue});
if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit2,
short_msg => sprintf("Air flow '%s' is %s m/min", $label, $result->{airFlowSensorValue}));
}
$self->{output}->perfdata_add(label => 'airflow_' . $label, unit => 'm/min',
value => $result->{airFlowSensorValue},
warning => $warn,
critical => $crit, min => 0
);
}
}
1;

View File

@ -0,0 +1,70 @@
#
# Copyright 2016 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::netbotz::snmp::mode::components::camera;
use strict;
use warnings;
use hardware::sensors::netbotz::snmp::mode::components::resources qw(%map_status %map_camera_value);
my $mapping = {
cameraMotionSensorId => { oid => '.1.3.6.1.4.1.5528.100.4.2.3.1.1' },
cameraMotionSensorValue => { oid => '.1.3.6.1.4.1.5528.100.4.2.3.1.2', map => \%map_camera_value },
cameraMotionSensorErrorStatus => { oid => '.1.3.6.1.4.1.5528.100.4.2.3.1.3', map => \%map_status },
cameraMotionSensorLabel => { oid => '.1.3.6.1.4.1.5528.100.4.2.3.1.4' },
};
my $oid_cameraMotionSensorEntry = '.1.3.6.1.4.1.5528.100.4.2.3.1';
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $oid_cameraMotionSensorEntry };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking cameras");
$self->{components}->{camera} = {name => 'cameras', total => 0, skip => 0};
return if ($self->check_filter(section => 'camera'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_cameraMotionSensorEntry}})) {
next if ($oid !~ /^$mapping->{cameraMotionSensorErrorStatus}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_cameraMotionSensorEntry}, instance => $instance);
next if ($self->check_filter(section => 'camera', instance => $instance));
$self->{components}->{camera}->{total}++;
my $label = defined($result->{cameraMotionSensorLabel}) && $result->{cameraMotionSensorLabel} ne '' ? $result->{cameraMotionSensorLabel} : $result->{cameraMotionSensorId};
$self->{output}->output_add(long_msg => sprintf("camera motion '%s' status is '%s' [instance = %s] [value = %s]",
$label, $result->{cameraMotionSensorErrorStatus}, $instance,
$result->{cameraMotionSensorValue}));
my $exit = $self->get_severity(label => 'default', section => 'camera', value => $result->{cameraMotionSensorErrorStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Camera motion '%s' status is '%s'", $label, $result->{cameraMotionSensorErrorStatus}));
}
}
}
1;

View File

@ -0,0 +1,83 @@
#
# Copyright 2016 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::netbotz::snmp::mode::components::dewpoint;
use strict;
use warnings;
use hardware::sensors::netbotz::snmp::mode::components::resources qw(%map_status);
my $mapping = {
dewPointSensorId => { oid => '.1.3.6.1.4.1.5528.100.4.1.3.1.1' },
dewPointSensorValue => { oid => '.1.3.6.1.4.1.5528.100.4.1.3.1.2' },
dewPointSensorErrorStatus => { oid => '.1.3.6.1.4.1.5528.100.4.1.3.1.3', map => \%map_status },
dewPointSensorLabel => { oid => '.1.3.6.1.4.1.5528.100.4.1.3.1.4' },
};
my $oid_dewPointSensorEntry = '.1.3.6.1.4.1.5528.100.4.1.3.1';
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $oid_dewPointSensorEntry };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking dew points");
$self->{components}->{dewpoint} = {name => 'dew points', total => 0, skip => 0};
return if ($self->check_filter(section => 'dewpoint'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_dewPointSensorEntry}})) {
next if ($oid !~ /^$mapping->{dewPointSensorErrorStatus}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_dewPointSensorEntry}, instance => $instance);
next if ($self->check_filter(section => 'dewpoint', instance => $instance));
$self->{components}->{dewpoint}->{total}++;
$result->{dewPointSensorValue} *= 0.1;
my $label = defined($result->{dewPointSensorLabel}) && $result->{dewPointSensorLabel} ne '' ? $result->{dewPointSensorLabel} : $result->{dewPointSensorId};
$self->{output}->output_add(long_msg => sprintf("dew point '%s' status is '%s' [instance = %s] [value = %s]",
$label, $result->{dewPointSensorErrorStatus}, $instance,
$result->{dewPointSensorValue}));
my $exit = $self->get_severity(label => 'default', section => 'dewpoint', value => $result->{dewPointSensorErrorStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Dew point '%s' status is '%s'", $label, $result->{dewPointSensorErrorStatus}));
}
my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'dewpoint', instance => $instance, value => $result->{dewPointSensorValue});
if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit2,
short_msg => sprintf("Dew point '%s' is %s C", $label, $result->{dewPointSensorValue}));
}
$self->{output}->perfdata_add(label => 'dewpoint_' . $label, unit => 'C',
value => $result->{dewPointSensorValue},
warning => $warn,
critical => $crit,
);
}
}
1;

View File

@ -0,0 +1,70 @@
#
# Copyright 2016 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::netbotz::snmp::mode::components::doorswitch;
use strict;
use warnings;
use hardware::sensors::netbotz::snmp::mode::components::resources qw(%map_status %map_door_value);
my $mapping = {
doorSwitchSensorId => { oid => '.1.3.6.1.4.1.5528.100.4.2.2.1.1' },
doorSwitchSensorValue => { oid => '.1.3.6.1.4.1.5528.100.4.2.2.1.2', map => \%map_door_value },
doorSwitchSensorErrorStatus => { oid => '.1.3.6.1.4.1.5528.100.4.2.2.1.3', map => \%map_status },
doorSwitchSensorLabel => { oid => '.1.3.6.1.4.1.5528.100.4.2.2.1.4' },
};
my $oid_doorSwitchSensorEntry = '.1.3.6.1.4.1.5528.100.4.2.2.1';
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $oid_doorSwitchSensorEntry };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking door switches");
$self->{components}->{doorswitch} = {name => 'door switches', total => 0, skip => 0};
return if ($self->check_filter(section => 'doorswitch'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_doorSwitchSensorEntry}})) {
next if ($oid !~ /^$mapping->{doorSwitchSensorErrorStatus}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_doorSwitchSensorEntry}, instance => $instance);
next if ($self->check_filter(section => 'doorswitch', instance => $instance));
$self->{components}->{doorswitch}->{total}++;
my $label = defined($result->{doorSwitchSensorLabel}) && $result->{doorSwitchSensorLabel} ne '' ? $result->{doorSwitchSensorLabel} : $result->{doorSwitchSensorId};
$self->{output}->output_add(long_msg => sprintf("door switch '%s' status is '%s' [instance = %s] [value = %s]",
$label, $result->{doorSwitchSensorErrorStatus}, $instance,
$result->{doorSwitchSensorValue}));
my $exit = $self->get_severity(label => 'default', section => 'doorswitch', value => $result->{doorSwitchSensorErrorStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Door switch '%s' status is '%s'", $label, $result->{doorSwitchSensorErrorStatus}));
}
}
}
1;

View File

@ -0,0 +1,83 @@
#
# Copyright 2016 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::netbotz::snmp::mode::components::humidity;
use strict;
use warnings;
use hardware::sensors::netbotz::snmp::mode::components::resources qw(%map_status);
my $mapping = {
humiSensorId => { oid => '.1.3.6.1.4.1.5528.100.4.1.2.1.1' },
humiSensorValue => { oid => '.1.3.6.1.4.1.5528.100.4.1.2.1.2' },
humiSensorErrorStatus => { oid => '.1.3.6.1.4.1.5528.100.4.1.2.1.3', map => \%map_status },
humiSensorLabel => { oid => '.1.3.6.1.4.1.5528.100.4.1.2.1.4' },
};
my $oid_humiSensorEntry = '.1.3.6.1.4.1.5528.100.4.1.2.1';
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $oid_humiSensorEntry };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking humidities");
$self->{components}->{humidity} = {name => 'humidity', total => 0, skip => 0};
return if ($self->check_filter(section => 'humidity'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_humiSensorEntry}})) {
next if ($oid !~ /^$mapping->{humiSensorErrorStatus}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_humiSensorEntry}, instance => $instance);
next if ($self->check_filter(section => 'humidity', instance => $instance));
$self->{components}->{humidity}->{total}++;
$result->{humiSensorValue} *= 0.1;
my $label = defined($result->{humiSensorLabel}) && $result->{humiSensorLabel} ne '' ? $result->{humiSensorLabel} : $result->{humiSensorId};
$self->{output}->output_add(long_msg => sprintf("humidity '%s' status is '%s' [instance = %s] [value = %s]",
$label, $result->{humiSensorErrorStatus}, $instance,
$result->{humiSensorValue}));
my $exit = $self->get_severity(label => 'default', section => 'humidity', value => $result->{humiSensorErrorStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Humidity '%s' status is '%s'", $label, $result->{humiSensorErrorStatus}));
}
my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'humidity', instance => $instance, value => $result->{humiSensorValue});
if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit2,
short_msg => sprintf("Humidity '%s' is %s %%", $label, $result->{humiSensorValue}));
}
$self->{output}->perfdata_add(label => 'humidity_' . $label, unit => '%',
value => $result->{humiSensorValue},
warning => $warn,
critical => $crit, min => 0, max => 100
);
}
}
1;

View File

@ -0,0 +1,70 @@
#
# Copyright 2016 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::netbotz::snmp::mode::components::otherstate;
use strict;
use warnings;
use hardware::sensors::netbotz::snmp::mode::components::resources qw(%map_status);
my $mapping = {
otherStateSensorId => { oid => '.1.3.6.1.4.1.5528.100.4.2.10.1.1' },
otherStateSensorErrorStatus => { oid => '.1.3.6.1.4.1.5528.100.4.2.10.1.3', map => \%map_status },
otherStateSensorLabel => { oid => '.1.3.6.1.4.1.5528.100.4.2.10.1.4' },
otherStateSensorValueStr => { oid => '.1.3.6.1.4.1.5528.100.4.2.10.1.7' },
};
my $oid_otherStateSensorEntry = '.1.3.6.1.4.1.5528.100.4.2.10.1';
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $oid_otherStateSensorEntry };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking other state");
$self->{components}->{otherstate} = {name => 'other state', total => 0, skip => 0};
return if ($self->check_filter(section => 'otherstate'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_otherStateSensorEntry}})) {
next if ($oid !~ /^$mapping->{otherStateSensorErrorStatus}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_otherStateSensorEntry}, instance => $instance);
next if ($self->check_filter(section => 'otherstate', instance => $instance));
$self->{components}->{otherstate}->{total}++;
my $label = defined($result->{otherStateSensorLabel}) && $result->{otherStateSensorLabel} ne '' ? $result->{otherStateSensorLabel} : $result->{otherStateSensorId};
$self->{output}->output_add(long_msg => sprintf("other state '%s' status is '%s' [instance = %s] [value = %s]",
$label, $result->{otherStateSensorErrorStatus}, $instance,
$result->{otherStateSensorValueStr}));
my $exit = $self->get_severity(label => 'default', section => 'otherstate', value => $result->{otherStateSensorErrorStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Other state '%s' status is '%s'", $label, $result->{otherStateSensorErrorStatus}));
}
}
}
1;

View File

@ -0,0 +1,55 @@
#
# Copyright 2016 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::netbotz::snmp::mode::components::resources;
use strict;
use warnings;
use Exporter;
our %map_status;
our %map_door_value;
our %map_camera_value;
our @ISA = qw(Exporter);
our @EXPORT_OK = qw(%map_status %map_door_value %map_camera_value);
%map_status = (
0 => 'normal',
1 => 'info',
2 => 'warning',
3 => 'error',
4 => 'critical',
5 => 'failure',
);
%map_door_value = (
-1 => 'null',
0 => 'open',
1 => 'closed',
);
%map_camera_value = (
-1 => 'null',
0 => 'noMotion',
1 => 'motionDetected',
);
1;

View File

@ -0,0 +1,83 @@
#
# Copyright 2016 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::netbotz::snmp::mode::components::temperature;
use strict;
use warnings;
use hardware::sensors::netbotz::snmp::mode::components::resources qw(%map_status);
my $mapping = {
tempSensorId => { oid => '.1.3.6.1.4.1.5528.100.4.1.1.1.1' },
tempSensorValue => { oid => '.1.3.6.1.4.1.5528.100.4.1.1.1.2' },
tempSensorErrorStatus => { oid => '.1.3.6.1.4.1.5528.100.4.1.1.1.3', map => \%map_status },
tempSensorLabel => { oid => '.1.3.6.1.4.1.5528.100.4.1.1.1.4' },
};
my $oid_tempSensorEntry = '.1.3.6.1.4.1.5528.100.4.1.1.1';
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $oid_tempSensorEntry };
}
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'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_tempSensorEntry}})) {
next if ($oid !~ /^$mapping->{tempSensorErrorStatus}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_tempSensorEntry}, instance => $instance);
next if ($self->check_filter(section => 'temperature', instance => $instance));
$self->{components}->{temperature}->{total}++;
$result->{tempSensorValue} *= 0.1;
my $label = defined($result->{tempSensorLabel}) && $result->{tempSensorLabel} ne '' ? $result->{tempSensorLabel} : $result->{tempSensorId};
$self->{output}->output_add(long_msg => sprintf("temperature '%s' status is '%s' [instance = %s] [value = %s]",
$label, $result->{tempSensorErrorStatus}, $instance,
$result->{tempSensorValue}));
my $exit = $self->get_severity(label => 'default', section => 'temperature', value => $result->{tempSensorErrorStatus});
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'", $label, $result->{tempSensorErrorStatus}));
}
my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{tempSensorValue});
if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit2,
short_msg => sprintf("Temperature '%s' is %s C", $label, $result->{tempSensorValue}));
}
$self->{output}->perfdata_add(label => 'temperature_' . $label, unit => 'C',
value => $result->{tempSensorValue},
warning => $warn,
critical => $crit,
);
}
}
1;

View File

@ -0,0 +1,116 @@
#
# Copyright 2016 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::netbotz::snmp::mode::sensors;
use base qw(centreon::plugins::templates::hardware);
use strict;
use warnings;
sub set_system {
my ($self, %options) = @_;
$self->{regexp_threshold_overload_check_section_option} = '^(temperature|humidity|dewpoint|airflow|doorswitch|camera|otherstate)$';
$self->{regexp_threshold_numeric_check_section_option} = '^(temperature|humidity|dewpoint|airflow)$';
$self->{cb_hook2} = 'snmp_execute';
$self->{thresholds} = {
default => [
['normal', 'OK'],
['info', 'OK'],
['warning', 'WARNING'],
['error', 'CRITICAL'],
['critical', 'CRITICAL'],
['failure', 'CRITICAL'],
],
};
$self->{components_path} = 'hardware::sensors::netbotz::snmp::mode::components';
$self->{components_module} = ['temperature', 'humidity', 'dewpoint', 'airflow',
'doorswitch', 'camera', 'otherstate'];
}
sub snmp_execute {
my ($self, %options) = @_;
$self->{snmp} = $options{snmp};
$self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request});
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
});
return $self;
}
1;
__END__
=head1 MODE
Check sensors.
=over 8
=item B<--component>
Which component to check (Default: '.*').
Can be: 'temperature', 'humidity', 'dewpoint', 'airflow',
'doorswitch', 'camera', 'otherstate'.
=item B<--filter>
Exclude some parts (comma seperated list) (Example: --filter=temperature --filter=humidity)
Can also exclude specific instance: --filter=temperature,1
=item B<--no-component>
Return an error if no compenents are checked.
If total (with skipped) is 0. (Default: 'critical' returns).
=item B<--threshold-overload>
Set to overload default threshold values (syntax: section,[instance,]status,regexp)
It used before default thresholds (order stays).
Example: --threshold-overload='temperature,CRITICAL,^(?!(normal)$)'
=item B<--warning>
Set warning threshold for 'temperature', 'humidity' (syntax: type,regexp,threshold)
Example: --warning='temperature,.*,30'
=item B<--critical>
Set critical threshold for 'temperature', 'humidity' (syntax: type,regexp,threshold)
Example: --warning='temperature,.*,50'
=back
=cut

View File

@ -0,0 +1,48 @@
#
# Copyright 2016 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::netbotz::snmp::plugin;
use strict;
use warnings;
use base qw(centreon::plugins::script_snmp);
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
%{$self->{modes}} = (
'sensors' => 'hardware::sensors::netbotz::snmp::mode::sensors',
);
return $self;
}
1;
__END__
=head1 PLUGIN DESCRIPTION
Check NetBotz sensors in SNMP.
=cut