+ add plugin for IBM TS3500

This commit is contained in:
garnier-quentin 2017-01-19 10:52:06 +01:00
parent 046aabc841
commit c5d9dd4f88
7 changed files with 507 additions and 0 deletions

View File

@ -0,0 +1,65 @@
#
# 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 centreon::common::ibm::tapelibrary::snmp::mode::components::changer;
use strict;
use warnings;
use centreon::common::ibm::tapelibrary::snmp::mode::components::resources qw($map_operational);
my $mapping = {
changerDevice_OperationalStatus => { oid => '.1.3.6.1.4.1.14851.3.1.11.2.1.9', map => $map_operational },
};
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $mapping->{changerDevice_OperationalStatus}->{oid} };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking changers");
$self->{components}->{changer} = {name => 'changers', total => 0, skip => 0};
return if ($self->check_filter(section => 'changer'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$mapping->{changerDevice_OperationalStatus}->{oid}}})) {
$oid =~ /^$mapping->{changerDevice_OperationalStatus}->{oid}\.(.*)$/;
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$mapping->{changerDevice_OperationalStatus}->{oid}}, instance => $instance);
next if ($self->check_filter(section => 'changer', instance => $instance));
$self->{components}->{changer}->{total}++;
$self->{output}->output_add(long_msg => sprintf("changer '%s' status is '%s' [instance: %s].",
$instance, $result->{changerDevice_OperationalStatus},
$instance
));
my $exit = $self->get_severity(label => 'operational', section => 'changer', value => $result->{changerDevice_OperationalStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("changer '%s' status is '%s'",
$instance, $result->{changerDevice_OperationalStatus}));
}
}
}
1;

View File

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

View File

@ -0,0 +1,68 @@
#
# 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 centreon::common::ibm::tapelibrary::snmp::mode::components::drive;
use strict;
use warnings;
use centreon::common::ibm::tapelibrary::snmp::mode::components::resources qw($map_operational);
my $mapping = {
mediaAccessDevice_Name => { oid => '.1.3.6.1.4.1.14851.3.1.6.2.1.3' },
mediaAccessDevice_OperationalStatus => { oid => '.1.3.6.1.4.1.14851.3.1.6.2.1.11', map => $map_operational },
};
my $oid_mediaAccessDeviceEntry = '.1.3.6.1.4.1.14851.3.1.6.2.1';
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $oid_mediaAccessDeviceEntry };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking drives");
$self->{components}->{drive} = {name => 'drives', total => 0, skip => 0};
return if ($self->check_filter(section => 'drive'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_mediaAccessDeviceEntry}})) {
next if ($oid !~ /^$mapping->{mediaAccessDevice_OperationalStatus}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_mediaAccessDeviceEntry}, instance => $instance);
next if ($self->check_filter(section => 'drive', instance => $instance));
$self->{components}->{drive}->{total}++;
$result->{mediaAccessDevice_Name} =~ s/\s+/ /g;
$self->{output}->output_add(long_msg => sprintf("drive '%s' status is '%s' [instance: %s].",
$result->{mediaAccessDevice_Name}, $result->{mediaAccessDevice_OperationalStatus},
$instance
));
my $exit = $self->get_severity(label => 'operational', section => 'drive', value => $result->{mediaAccessDevice_OperationalStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("drive '%s' status is '%s'",
$result->{mediaAccessDevice_Name}, $result->{mediaAccessDevice_OperationalStatus}));
}
}
}
1;

View File

@ -0,0 +1,75 @@
#
# 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 centreon::common::ibm::tapelibrary::snmp::mode::components::psu;
use strict;
use warnings;
use centreon::common::ibm::tapelibrary::snmp::mode::components::resources qw($map_status);
my $mapping = {
chassis_PS1Status => { oid => '.1.3.6.1.4.1.2.6.257.1.3.2.1.3', map => $map_status },
chassis_PS2Status => { oid => '.1.3.6.1.4.1.2.6.257.1.3.2.1.4', map => $map_status },
chassis_SerialNumber => { oid => '.1.3.6.1.4.1.2.6.257.1.3.2.1.9' },
};
my $oid_frameConfigEntry = '.1.3.6.1.4.1.2.6.257.1.3.2.1';
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $oid_frameConfigEntry };
}
sub check_psu {
my ($self, %options) = @_;
return if ($self->check_filter(section => 'psu', instance => $options{instance}));
$self->{components}->{psu}->{total} += 2;
$self->{output}->output_add(long_msg => sprintf("psu '%s' status is '%s' [instance: %s, chassis: %s].",
$options{instance}, $options{status},
$options{instance}, $options{serial}
));
my $exit = $self->get_severity(label => 'status', section => 'psu', value => $options{status});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("psu '%s' status is '%s'",
$options{instance}, $options{status}));
}
}
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'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_frameConfigEntry}})) {
next if ($oid !~ /^$mapping->{chassis_SerialNumber}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_frameConfigEntry}, instance => $instance);
check_psu($self, status => $result->{chassis_PS1Status}, instance => $instance . '.1', serial => $result->{chassis_SerialNumber});
check_psu($self, status => $result->{chassis_PS2Status}, instance => $instance . '.2', serial => $result->{chassis_SerialNumber});
}
}
1;

View File

@ -0,0 +1,63 @@
#
# 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 centreon::common::ibm::tapelibrary::snmp::mode::components::resources;
use strict;
use warnings;
use Exporter;
our $map_operational;
our $map_status;
our @ISA = qw(Exporter);
our @EXPORT_OK = qw($map_operational $map_status);
$map_status = {
1 => 'notinstalled',
2 => 'ok',
3 => 'notok',
};
$map_operational = {
0 => 'unknown',
1 => 'other',
2 => 'ok',
3 => 'degraded',
4 => 'stressed',
5 => 'predictiveFailure',
6 => 'error',
7 => 'non-RecoverableError',
8 => 'starting',
9 => 'stopping',
10 => 'stopped',
11 => 'inService',
12 => 'noContact',
13 => 'lostCommunication',
14 => 'aborted',
15 => 'dormant',
16 => 'supportingEntityInError',
17 => 'completed',
18 => 'powerMode',
19 => 'dMTFReserved',
32768 => 'vendorReserved',
};
1;

View File

@ -0,0 +1,121 @@
#
# 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 centreon::common::ibm::tapelibrary::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} = '^(chassis|drive|changer|psu)$';
$self->{cb_hook2} = 'snmp_execute';
$self->{thresholds} = {
status => [
['notinstalled', 'OK'],
['notok', 'CRITICAL'],
['ok', 'OK'],
],
operational => [
['unknown', 'UNKNOWN'],
['other', 'UNKNOWN'],
['ok', 'OK'],
['degraded', 'WARNING'],
['stressed', 'WARNING'],
['predictiveFailure', 'WARNING'],
['error', 'CRITICAL'],
['non-RecoverableError', 'CRITICAL'],
['starting', 'OK'],
['stopping', 'OK'],
['stopped', 'OK'],
['inService', 'OK'],
['noContact', 'WARNING'],
['lostCommunication', 'WARNING'],
['aborted', 'OK'],
['dormant', 'OK'],
['supportingEntityInError', 'CRITICAL'],
['completed', 'OK'],
['powerMode', 'OK'],
],
};
$self->{components_path} = 'centreon::common::ibm::tapelibrary::snmp::mode::components';
$self->{components_module} = ['chassis', 'drive', 'changer', 'psu'];
}
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, no_performance => 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: 'chassis', 'drive', 'changer', 'psu'.
=item B<--filter>
Exclude some parts (comma seperated list) (Example: --filter=drive)
Can also exclude specific instance: --filter=drive,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='chassis,CRITICAL,degraded'
=back
=cut

View File

@ -0,0 +1,50 @@
#
# 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::ibm::ts3500::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' => 'centreon::common::ibm::tapelibrary::snmp::mode::hardware',
);
return $self;
}
1;
__END__
=head1 PLUGIN DESCRIPTION
Check IBM TS3500 in SNMP.
Cannot get possible values of some OIDs:
libraryState, driveState, driveClean.
=cut