add dell os10 plugin snmp

This commit is contained in:
garnier-quentin 2020-02-05 14:08:23 +01:00
parent 8428555943
commit f89f5dd31c
8 changed files with 614 additions and 0 deletions

View File

@ -0,0 +1,86 @@
#
# Copyright 2020 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 network::dell::os10::snmp::mode::components::card;
use strict;
use warnings;
my $map_card_status = {
1 => 'ready', 2 => 'cardMisMatch', 3 => 'cardProblem',
4 => 'diagMode', 5 => 'cardAbsent', 6 => 'offline'
};
my $mapping = {
os10CardDescription => { oid => '.1.3.6.1.4.1.674.11000.5000.100.4.1.1.4.1.3' },
os10CardStatus => { oid => '.1.3.6.1.4.1.674.11000.5000.100.4.1.1.4.1.4', map => $map_card_status },
};
my $oid_os10CardEntry = '.1.3.6.1.4.1.674.11000.5000.100.4.1.1.4.1';
my $oid_os10ChassisPPID = '.1.3.6.1.4.1.674.11000.5000.100.4.1.1.3.1.5';
sub load {
my ($self) = @_;
push @{$self->{request}}, {
oid => $oid_os10CardEntry,
start => $mapping->{os10CardDescription}->{oid},
end => $mapping->{os10CardStatus}->{oid}
};
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => 'checking cards');
$self->{components}->{card} = { name => 'cards', total => 0, skip => 0 };
return if ($self->check_filter(section => 'card'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_os10CardEntry}})) {
next if ($oid !~ /^$mapping->{os10CardStatus}->{oid}\.(.*?)\.(.*)$/);
my ($chassis_index, $card_index, $instance) = ($1, $2, $1 . '.' . $2);
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_os10CardEntry}, instance => $instance);
my $name = $self->{results}->{$oid_os10ChassisPPID}->{$oid_os10ChassisPPID . '.' . $chassis_index} . ':' . $result->{os10CardDescription};
next if ($self->check_filter(section => 'card', instance => $instance));
$self->{components}->{card}->{total}++;
$self->{output}->output_add(
long_msg => sprintf(
"card '%s' status is '%s' [instance: %s].",
$name,
$result->{os10CardStatus},
$instance
)
);
my $exit = $self->get_severity(section => 'card', value => $result->{os10CardStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf(
"card '%s' status is '%s'",
$name,
$result->{os10CardStatus}
)
);
}
}
}
1;

View File

@ -0,0 +1,74 @@
#
# Copyright 2020 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 network::dell::os10::snmp::mode::components::fan;
use strict;
use warnings;
use network::dell::os10::snmp::mode::components::resources qw($map_oper_status);
my $mapping = {
os10FanOperStatus => { oid => '.1.3.6.1.4.1.674.11000.5000.100.4.1.2.3.1.7', map => $map_oper_status },
};
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $mapping->{os10FanOperStatus}->{oid} };
}
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'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{ $mapping->{os10FanOperStatus}->{oid} }})) {
$oid =~ /^$mapping->{os10FanOperStatus}->{oid}\.(.*)$/;
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{ $mapping->{os10FanOperStatus}->{oid} }, instance => $instance);
next if ($self->check_filter(section => 'fan', instance => $instance));
$self->{components}->{fan}->{total}++;
$self->{output}->output_add(
long_msg => sprintf(
"fan '%s' status is '%s' [instance: %s].",
$instance,
$result->{os10FanOperStatus},
$instance
)
);
my $exit = $self->get_severity(label => 'operational', section => 'fan', value => $result->{os10FanOperStatus});
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'",
$instance,
$result->{os10FanOperStatus}
)
);
}
}
}
1;

View File

@ -0,0 +1,74 @@
#
# Copyright 2020 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 network::dell::os10::snmp::mode::components::fantray;
use strict;
use warnings;
use network::dell::os10::snmp::mode::components::resources qw($map_oper_status);
my $mapping = {
os10FanTrayOperStatus => { oid => '.1.3.6.1.4.1.674.11000.5000.100.4.1.2.2.1.4', map => $map_oper_status },
};
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $mapping->{os10FanTrayOperStatus}->{oid} };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "checking fantray");
$self->{components}->{fantray} = { name => 'fantray', total => 0, skip => 0 };
return if ($self->check_filter(section => 'fantray'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{ $mapping->{os10FanTrayOperStatus}->{oid} }})) {
$oid =~ /^$mapping->{os10FanTrayOperStatus}->{oid}\.(.*)$/;
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{ $mapping->{os10FanTrayOperStatus}->{oid} }, instance => $instance);
next if ($self->check_filter(section => 'fantray', instance => $instance));
$self->{components}->{fantray}->{total}++;
$self->{output}->output_add(
long_msg => sprintf(
"fantray '%s' status is '%s' [instance: %s].",
$instance,
$result->{os10FanTrayOperStatus},
$instance
)
);
my $exit = $self->get_severity(label => 'operational', section => 'fantray', value => $result->{os10FanTrayOperStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf(
"fantray '%s' status is '%s'",
$instance,
$result->{os10FanTrayOperStatus}
)
);
}
}
}
1;

View File

@ -0,0 +1,74 @@
#
# Copyright 2020 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 network::dell::os10::snmp::mode::components::psu;
use strict;
use warnings;
use network::dell::os10::snmp::mode::components::resources qw($map_oper_status);
my $mapping = {
os10PowerSupplyOperStatus => { oid => '.1.3.6.1.4.1.674.11000.5000.100.4.1.2.1.1.4', map => $map_oper_status },
};
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $mapping->{os10PowerSupplyOperStatus}->{oid} };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "checking power supplies");
$self->{components}->{psu} = { name => 'psus', total => 0, skip => 0 };
return if ($self->check_filter(section => 'psu'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{ $mapping->{os10PowerSupplyOperStatus}->{oid} }})) {
$oid =~ /^$mapping->{os10PowerSupplyOperStatus}->{oid}\.(.*)$/;
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{ $mapping->{os10PowerSupplyOperStatus}->{oid} }, 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].",
$instance,
$result->{os10PowerSupplyOperStatus},
$instance
)
);
my $exit = $self->get_severity(label => 'operational', section => 'psu', value => $result->{os10PowerSupplyOperStatus});
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'",
$instance,
$result->{os10PowerSupplyOperStatus}
)
);
}
}
}
1;

View File

@ -0,0 +1,39 @@
#
# Copyright 2020 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 network::dell::os10::snmp::mode::components::resources;
use strict;
use warnings;
use Exporter;
our $map_oper_status;
our @ISA = qw(Exporter);
our @EXPORT_OK = qw($map_oper_status);
$map_oper_status = {
1 => 'up', 2 => 'down',
3 => 'testing', 4 => 'unknown',
5 => 'dormant', 6 => 'notPresent',
7 => 'lowerLayerDown', 8 => 'failed'
};
1;

View File

@ -0,0 +1,84 @@
#
# Copyright 2020 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 network::dell::os10::snmp::mode::components::temperature;
use strict;
use warnings;
my $mapping = {
os10ChassisTemp => { oid => '.1.3.6.1.4.1.674.11000.5000.100.4.1.1.3.1.11' }
};
my $oid_os10ChassisPPID = '.1.3.6.1.4.1.674.11000.5000.100.4.1.1.3.1.5';
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $mapping->{os10ChassisTemp}->{oid} };
}
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}->{ $mapping->{os10ChassisTemp}->{oid} }})) {
$oid =~ /^$mapping->{os10ChassisTemp}->{oid}\.(.*)$/;
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{ $mapping->{os10ChassisTemp}->{oid} }, instance => $instance);
my $name = $self->{results}->{$oid_os10ChassisPPID}->{$oid_os10ChassisPPID . '.' . $instance};
next if ($self->check_filter(section => 'temperature', instance => $instance));
$self->{components}->{temperature}->{total}++;
$self->{output}->output_add(
long_msg => sprintf(
"chassis temperature '%s' is %s degree centigrade [instance = %s]",
$name,
$result->{os10ChassisTemp},
$instance
)
);
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{os10ChassisTemp});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf(
"chassis temperature '%s' is %s degree centigrade",
$name,
$result->{os10ChassisTemp}
)
);
}
$self->{output}->perfdata_add(
unit => 'C',
nlabel => 'hardware.chassis.temperature.celsius',
instances => $name,
value => $result->{os10ChassisTemp},
warning => $warn,
critical => $crit
);
}
}
1;

View File

@ -0,0 +1,125 @@
#
# Copyright 2020 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 network::dell::os10::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} =
'^(?:card|temperature|fan|fantray|psu)$';
$self->{regexp_threshold_numeric_check_section_option} = '^(?:temperature)$';
$self->{cb_hook2} = 'snmp_execute';
$self->{thresholds} = {
card => [
['ready', 'OK'],
['cardMisMatch', 'CRITICAL'],
['cardProblem', 'CRITICAL'],
['diagMode', 'OK'],
['cardAbsent', 'OK'],
['offline', 'OK'],
],
operational => [
['up', 'OK'],
['down', 'CRITICAL'],
['testing', 'OK'],
['unknown', 'UNKNOWN'],
['dormant', 'OK'],
['notPresent', 'OK'],
['lowerLayerDown', 'OK'],
['failed', 'CRITICAL'],
],
};
$self->{components_path} = 'network::dell::os10::snmp::mode::components';
$self->{components_module} = ['card', 'temperature', 'fan', 'fantray', 'psu'];
}
sub snmp_execute {
my ($self, %options) = @_;
$self->{snmp} = $options{snmp};
my $oid_os10ChassisPPID = '.1.3.6.1.4.1.674.11000.5000.100.4.1.1.3.1.5';
push @{$self->{request}}, { oid => $oid_os10ChassisPPID };
$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, force_new_perfdata => 1);
bless $self, $class;
$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: 'card', 'temperature', 'fan', 'fantray', 'psu'.
=item B<--filter>
Exclude some parts (comma seperated list) (Example: --filter=fan)
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='fan,CRITICAL,lowerLayerDown'
=item B<--warning>
Set warning threshold (syntax: type,regexp,threshold)
Example: --warning='temperature,.*,30'
=item B<--critical>
Set critical threshold (syntax: type,regexp,threshold)
Example: --critical='temperature,.*,40'
=back
=cut

View File

@ -0,0 +1,58 @@
#
# Copyright 2020 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 network::dell::os10::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}} = (
'cpu' => 'snmp_standard::mode::cpu',
'disk-usage' => 'snmp_standard::mode::diskusage',
'hardware' => 'network::dell::os10::snmp::mode::hardware',
'inodes' => 'snmp_standard::mode::inodes',
'interfaces' => 'snmp_standard::mode::interfaces',
'load' => 'snmp_standard::mode::loadaverage',
'list-interfaces' => 'snmp_standard::mode::listinterfaces',
'memory' => 'snmp_standard::mode::memory',
'swap' => 'snmp_standard::mode::swap',
'uptime' => 'snmp_standard::mode::uptime'
);
return $self;
}
1;
__END__
=head1 PLUGIN DESCRIPTION
Check Dell OS10 Operating System in SNMP. It's based on Linux.
The legacy version is 0S9, FTOS or Force10 operating system.
=cut