+ add QSan NAS plugin in snmp

This commit is contained in:
garnier-quentin 2017-05-19 13:48:50 +02:00
parent 29e05f9d58
commit ad51957fd0
7 changed files with 545 additions and 0 deletions

View File

@ -0,0 +1,80 @@
#
# 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 storage::qsan::nas::snmp::mode::components::disk;
use strict;
use warnings;
my $mapping = {
pd_location => { oid => '.1.3.6.1.4.1.22274.2.2.1.1.1' },
pd_status_health => { oid => '.1.3.6.1.4.1.22274.2.2.1.1.3' },
hdd_temperature => { oid => '.1.3.6.1.4.1.22274.2.3.4.1.4' },
};
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $mapping->{pd_location}->{oid} },
{ oid => $mapping->{pd_status_health}->{oid} }, { oid => $mapping->{hdd_temperature}->{oid} };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking disks");
$self->{components}->{disk} = {name => 'disks', total => 0, skip => 0};
return if ($self->check_filter(section => 'disk'));
my $results = { %{$self->{results}->{$mapping->{pd_location}->{oid}}}, %{$self->{results}->{$mapping->{pd_status_health}->{oid}}},
%{$self->{results}->{$mapping->{hdd_temperature}->{oid}}}};
my ($exit, $warn, $crit, $checked);
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$mapping->{pd_status_health}->{oid}}})) {
$oid =~ /^$mapping->{pd_status_health}->{oid}\.(.*)$/;
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $results, instance => $instance);
next if ($self->check_filter(section => 'disk', instance => $instance));
$self->{components}->{disk}->{total}++;
$self->{output}->output_add(long_msg => sprintf("disk '%s' status is '%s' [instance = %s, temperature = %s]",
$result->{pd_location}, $result->{pd_status_health}, $instance, $result->{hdd_temperature}));
$exit = $self->get_severity(section => 'disk', value => $result->{pd_status_health});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Disk '%s' status is '%s'", $result->{pd_location}, $result->{pd_status_health}));
}
next if (!defined($result->{hdd_temperature}) || $result->{hdd_temperature} !~ /[0-9]/);
($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'disk.temperature', instance => $instance, value => $result->{hdd_temperature});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Disk '%s' is '%s' C", $result->{pd_location}, $result->{hdd_temperature}));
}
$self->{output}->perfdata_add(label => 'disk_temperature_' . $result->{pd_location}, unit => 'C',
value => $result->{hdd_temperature},
warning => $warn,
critical => $crit
);
}
}
1;

View File

@ -0,0 +1,79 @@
#
# 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 storage::qsan::nas::snmp::mode::components::fan;
use strict;
use warnings;
my $mapping = {
ems_type => { oid => '.1.3.6.1.4.1.22274.2.3.2.1.2' },
ems_item => { oid => '.1.3.6.1.4.1.22274.2.3.2.1.3' },
ems_value => { oid => '.1.3.6.1.4.1.22274.2.3.2.1.4' },
ems_status => { oid => '.1.3.6.1.4.1.22274.2.3.2.1.5' },
};
my $oid_monitorEntry = '.1.3.6.1.4.1.22274.2.3.2.1';
sub load {}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking fans");
$self->{components}->{fan} = {name => 'fans', total => 0, skip => 0};
return if ($self->check_filter(section => 'fan'));
my ($exit, $warn, $crit, $checked);
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_monitorEntry}})) {
next if ($oid !~ /^$mapping->{ems_type}->{oid}\.(.*)$/);
my $instance = $1;
next if ($self->{results}->{$oid_monitorEntry}->{$oid} !~ /Cooling/i);
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_monitorEntry}, instance => $instance);
next if ($self->check_filter(section => 'fan', instance => $instance));
#3443 RPM
my $value = '-';
$value = $1 if (defined($result->{ems_value}) && $result->{ems_value} =~ /^(\S+)\s+RPM/);
$self->{components}->{fan}->{total}++;
$self->{output}->output_add(long_msg => sprintf("fan '%s' status is '%s' [instance = %s, value = %s]",
$result->{ems_item}, $result->{ems_status}, $instance, $value));
$exit = $self->get_severity(label => 'monitor', section => 'fan', value => $result->{ems_status});
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'", $result->{ems_item}, $result->{ems_status}));
}
next if ($value !~ /[0-9]/);
($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'fan', instance => $instance, value => $value);
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("fan '%s' is '%s' rpm", $result->{ems_item}, $value));
}
$self->{output}->perfdata_add(label => 'fan_' . $result->{ems_item} . '_' . $instance, unit => 'rpm',
value => $value,
warning => $warn,
critical => $crit, min => 0
);
}
}
1;

View File

@ -0,0 +1,64 @@
#
# 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 storage::qsan::nas::snmp::mode::components::psu;
use strict;
use warnings;
my $mapping = {
ems_type => { oid => '.1.3.6.1.4.1.22274.2.3.2.1.2' },
ems_item => { oid => '.1.3.6.1.4.1.22274.2.3.2.1.3' },
ems_value => { oid => '.1.3.6.1.4.1.22274.2.3.2.1.4' },
ems_status => { oid => '.1.3.6.1.4.1.22274.2.3.2.1.5' },
};
my $oid_monitorEntry = '.1.3.6.1.4.1.22274.2.3.2.1';
sub load {}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking power supplies");
$self->{components}->{psu} = {name => 'psu', total => 0, skip => 0};
return if ($self->check_filter(section => 'psu'));
my ($exit, $warn, $crit, $checked);
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_monitorEntry}})) {
next if ($oid !~ /^$mapping->{ems_type}->{oid}\.(.*)$/);
my $instance = $1;
next if ($self->{results}->{$oid_monitorEntry}->{$oid} !~ /Power Supply/i);
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_monitorEntry}, instance => $instance);
next if ($self->check_filter(section => 'psu', instance => $instance));
$self->{components}->{psu}->{total}++;
$self->{output}->output_add(long_msg => sprintf("power supply '%s' status is '%s' [instance = %s, value = %s]",
$result->{ems_item}, $result->{ems_status}, $instance, $result->{ems_value}));
$exit = $self->get_severity(label => 'monitor', section => 'psu', value => $result->{ems_status});
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'", $result->{ems_item}, $result->{ems_status}));
}
}
}
1;

View File

@ -0,0 +1,79 @@
#
# 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 storage::qsan::nas::snmp::mode::components::temperature;
use strict;
use warnings;
my $mapping = {
ems_type => { oid => '.1.3.6.1.4.1.22274.2.3.2.1.2' },
ems_item => { oid => '.1.3.6.1.4.1.22274.2.3.2.1.3' },
ems_value => { oid => '.1.3.6.1.4.1.22274.2.3.2.1.4' },
ems_status => { oid => '.1.3.6.1.4.1.22274.2.3.2.1.5' },
};
my $oid_monitorEntry = '.1.3.6.1.4.1.22274.2.3.2.1';
sub load {}
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'));
my ($exit, $warn, $crit, $checked);
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_monitorEntry}})) {
next if ($oid !~ /^$mapping->{ems_type}->{oid}\.(.*)$/);
my $instance = $1;
next if ($self->{results}->{$oid_monitorEntry}->{$oid} !~ /Temperature/i);
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_monitorEntry}, instance => $instance);
next if ($self->check_filter(section => 'temperature', instance => $instance));
# +72.0 (C) (hyst = +5.0 (C), high = +90.0 (C))
my $value = '-';
$value = sprintf("%.2f", $1) if (defined($result->{ems_value}) && $result->{ems_value} =~ /^(\S+)\s+\(C\)/);
$self->{components}->{temperature}->{total}++;
$self->{output}->output_add(long_msg => sprintf("temperature '%s' status is '%s' [instance = %s, value = %s]",
$result->{ems_item}, $result->{ems_status}, $instance, $value));
$exit = $self->get_severity(label => 'monitor', section => 'temperature', value => $result->{ems_status});
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->{ems_item}, $result->{ems_status}));
}
next if ($value !~ /[0-9]/);
($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $value);
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Temperature '%s' is '%s' C", $result->{ems_item}, $value));
}
$self->{output}->perfdata_add(label => 'temperature_' . $result->{ems_item} . '_' . $instance, unit => 'C',
value => $value,
warning => $warn,
critical => $crit
);
}
}
1;

View File

@ -0,0 +1,79 @@
#
# 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 storage::qsan::nas::snmp::mode::components::voltage;
use strict;
use warnings;
my $mapping = {
ems_type => { oid => '.1.3.6.1.4.1.22274.2.3.2.1.2' },
ems_item => { oid => '.1.3.6.1.4.1.22274.2.3.2.1.3' },
ems_value => { oid => '.1.3.6.1.4.1.22274.2.3.2.1.4' },
ems_status => { oid => '.1.3.6.1.4.1.22274.2.3.2.1.5' },
};
my $oid_monitorEntry = '.1.3.6.1.4.1.22274.2.3.2.1';
sub load {}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking voltages");
$self->{components}->{voltage} = {name => 'voltages', total => 0, skip => 0};
return if ($self->check_filter(section => 'voltage'));
my ($exit, $warn, $crit, $checked);
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_monitorEntry}})) {
next if ($oid !~ /^$mapping->{ems_type}->{oid}\.(.*)$/);
my $instance = $1;
next if ($self->{results}->{$oid_monitorEntry}->{$oid} !~ /Voltage/i);
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_monitorEntry}, instance => $instance);
next if ($self->check_filter(section => 'voltage', instance => $instance));
#+0.99 V (min = +0.75 V, max = +1.35 V)
my $value = '-';
$value = sprintf("%.2f", $1) if (defined($result->{ems_value}) && $result->{ems_value} =~ /^(\S+)\s+V/);
$self->{components}->{voltage}->{total}++;
$self->{output}->output_add(long_msg => sprintf("voltage '%s' status is '%s' [instance = %s, value = %s]",
$result->{ems_item}, $result->{ems_status}, $instance, $value));
$exit = $self->get_severity(label => 'monitor', section => 'voltage', value => $result->{ems_status});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("voltage '%s' status is '%s'", $result->{ems_item}, $result->{ems_status}));
}
next if ($value !~ /[0-9]/);
($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'voltage', instance => $instance, value => $value);
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("voltage '%s' is '%s' V", $result->{ems_item}, $value));
}
$self->{output}->perfdata_add(label => 'voltage_' . $result->{ems_item} . '_' . $instance, unit => 'V',
value => $value,
warning => $warn,
critical => $crit
);
}
}
1;

View File

@ -0,0 +1,116 @@
#
# 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 storage::qsan::nas::snmp::mode::hardware;
use base qw(centreon::plugins::templates::hardware);
use strict;
use warnings;
sub set_system {
my ($self, %options) = @_;
$self->{regexp_threshold_overload_check_section_option} = '^(disk|voltage|temperature|psu|fan)$';
$self->{regexp_threshold_numeric_check_section_option} = '^(temperature|disk.temperature|voltage|fan)$';
$self->{cb_hook2} = 'snmp_execute';
$self->{thresholds} = {
disk => [
['good', 'OK'],
['.*', 'CRITICAL'],
],
monitor => [
['OK', 'OK'],
['.*', 'CRITICAL'],
],
};
$self->{components_path} = 'storage::qsan::nas::snmp::mode::components';
$self->{components_module} = ['disk', 'voltage', 'temperature', 'psu', 'fan'];
}
sub snmp_execute {
my ($self, %options) = @_;
$self->{snmp} = $options{snmp};
my $oid_monitorEntry = '.1.3.6.1.4.1.22274.2.3.2.1';
push @{$self->{request}}, { oid => $oid_monitorEntry };
$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 hardware.
=over 8
=item B<--component>
Which component to check (Default: '.*').
Can be: 'disk', 'voltage', 'temperature', 'psu', 'fan'
=item B<--filter>
Exclude some parts (comma seperated list) (Example: --filter=fan --filter=psu)
Can also exclude specific instance: --filter=fan,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='psu,WARNING,^(?!(OK)$)'
=item B<--warning>
Set warning threshold for 'temperature', 'disk.temperature', 'voltage', 'fan' (syntax: type,regexp,threshold)
Example: --warning='temperature,.*,40'
=item B<--critical>
Set critical threshold for 'temperature', 'disk.temperature', 'voltage', 'fan' (syntax: type,regexp,threshold)
Example: --critical='temperature,.*,50'
=back
=cut

View File

@ -0,0 +1,48 @@
#
# 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 storage::qsan::nas::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}} = (
'hardware' => 'storage::qsan::nas::snmp::mode::hardware',
);
return $self;
}
1;
__END__
=head1 PLUGIN DESCRIPTION
Check QSan NAS in SNMP.
=cut