+ add plugin for overland snmp
This commit is contained in:
parent
949ce9e84c
commit
48c2453be1
|
@ -761,8 +761,10 @@ sub map_instance {
|
|||
my ($self, %options) = @_;
|
||||
|
||||
my $results = {};
|
||||
my $instance = '';
|
||||
$instance = '.' . $options{instance} if (defined($options{instance}));
|
||||
foreach my $name (keys %{$options{mapping}}) {
|
||||
my $entry = $options{mapping}->{$name}->{oid} . '.' . $options{instance};
|
||||
my $entry = $options{mapping}->{$name}->{oid} . $instance;
|
||||
if (defined($options{results}->{$entry})) {
|
||||
$results->{$name} = $options{results}->{$entry};
|
||||
} elsif (defined($options{results}->{$options{mapping}->{$name}->{oid}}->{$entry})) {
|
||||
|
|
|
@ -0,0 +1,74 @@
|
|||
#
|
||||
# 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 storage::overland::neo::snmp::mode::components::drive;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my %map_state = (
|
||||
0 => 'initializedNoError',
|
||||
1 => 'initializedWithError',
|
||||
2 => 'notInitialized',
|
||||
3 => 'notInstalled',
|
||||
4 => 'notInserted',
|
||||
);
|
||||
|
||||
my $mapping = {
|
||||
dstState => { oid => '.1.3.6.1.4.1.3351.1.3.2.3.1.1.3', map => \%map_state },
|
||||
dstSerialNum => { oid => '.1.3.6.1.4.1.3351.1.3.2.3.1.1.8' },
|
||||
};
|
||||
my $oid_driveStatusEntry = '.1.3.6.1.4.1.3351.1.3.2.3.1.1';
|
||||
|
||||
sub load {
|
||||
my ($self) = @_;
|
||||
|
||||
push @{$self->{request}}, { oid => $oid_driveStatusEntry };
|
||||
}
|
||||
|
||||
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'));
|
||||
|
||||
# there is no instance for the table. Weird. Need to manage the two cases.
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_driveStatusEntry}})) {
|
||||
next if ($oid !~ /^$mapping->{dstState}->{oid}(?:\.(.*)|$)/);
|
||||
my $instance = defined($1) ? $1 : undef;
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_driveStatusEntry}, instance => $instance);
|
||||
|
||||
# we set a 1 to do some filters
|
||||
$instance = '1' if (!defined($instance));
|
||||
next if ($self->check_filter(section => 'drive', instance => $instance));
|
||||
|
||||
$self->{components}->{drive}->{total}++;
|
||||
$self->{output}->output_add(long_msg => sprintf("drive '%s' status is '%s' [instance = %s]",
|
||||
$instance, $result->{dstState}, $instance));
|
||||
my $exit = $self->get_severity(section => 'drive', instance => $instance, value => $result->{dstState});
|
||||
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'", $instance, $result->{dstState}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
|
@ -0,0 +1,71 @@
|
|||
#
|
||||
# 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 storage::overland::neo::snmp::mode::components::library;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my %map_state = (
|
||||
0 => 'initializing',
|
||||
1 => 'online',
|
||||
2 => 'offline',
|
||||
);
|
||||
|
||||
my $mapping = {
|
||||
lstLibraryState => { oid => '.1.3.6.1.4.1.3351.1.3.2.3.2.1.6', map => \%map_state },
|
||||
};
|
||||
my $oid_libraryStatusEntry = '.1.3.6.1.4.1.3351.1.3.2.3.2.1';
|
||||
|
||||
sub load {
|
||||
my ($self) = @_;
|
||||
|
||||
push @{$self->{request}}, { oid => $oid_libraryStatusEntry };
|
||||
}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking libraries");
|
||||
$self->{components}->{library} = {name => 'libraries', total => 0, skip => 0};
|
||||
return if ($self->check_filter(section => 'library'));
|
||||
|
||||
# there is no instance for the table. Weird. Need to manage the two cases.
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_libraryStatusEntry}})) {
|
||||
next if ($oid !~ /^$mapping->{lstLibraryState}->{oid}(?:\.(.*)|$)/);
|
||||
my $instance = defined($1) ? $1 : undef;
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_libraryStatusEntry}, instance => $instance);
|
||||
|
||||
# we set a 1 to do some filters
|
||||
$instance = '1' if (!defined($instance));
|
||||
next if ($self->check_filter(section => 'library', instance => $instance));
|
||||
|
||||
$self->{components}->{library}->{total}++;
|
||||
$self->{output}->output_add(long_msg => sprintf("library '%s' status is '%s' [instance = %s]",
|
||||
$instance, $result->{lstLibraryState}, $instance));
|
||||
my $exit = $self->get_severity(section => 'library', instance => $instance, value => $result->{lstLibraryState});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("library '%s' status is '%s'", $instance, $result->{lstLibraryState}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
|
@ -0,0 +1,131 @@
|
|||
#
|
||||
# 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 storage::overland::neo::snmp::mode::eventlog;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my %severity_map = (
|
||||
0 => 'informational',
|
||||
1 => 'mild',
|
||||
2 => 'hard',
|
||||
3 => 'severe',
|
||||
);
|
||||
|
||||
my $mapping = {
|
||||
errCode => { oid => '.1.3.6.1.4.1.3351.1.3.2.3.3.1.2' },
|
||||
errSeverity => { oid => '.1.3.6.1.4.1.3351.1.3.2.3.3.1.3', map => \%severity_map },
|
||||
errMsg => { oid => '.1.3.6.1.4.1.3351.1.3.2.3.3.1.4' },
|
||||
};
|
||||
my $oid_errorEntry = '.1.3.6.1.4.1.3351.1.3.2.3.3.1';
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"filter-severity:s" => { name => 'filter_severity', default => 'hard|severe' },
|
||||
"filter-message:s" => { name => 'filter_message' },
|
||||
"warning" => { name => 'warning' },
|
||||
});
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $exit = defined($self->{option_results}->{warning}) ? 'WARNING' : 'CRITICAL';
|
||||
my ($num_eventlog_checked, $num_errors) = (0, 0);
|
||||
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => "No problems detected.");
|
||||
|
||||
my $results = $options{snmp}->get_table(oid => $oid_errorEntry);
|
||||
|
||||
foreach my $oid ($options{snmp}->oid_lex_sort(keys %$results)) {
|
||||
next if ($oid !~ /^$mapping->{errSeverity}->{oid}(?:\.(.*)|$)/);
|
||||
my $instance = defined($1) ? $1 : undef;
|
||||
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $results, instance => $instance);
|
||||
|
||||
$num_eventlog_checked++;
|
||||
|
||||
next if (defined($self->{option_results}->{filter_severity}) && $self->{option_results}->{filter_severity} ne '' && $result->{errSeverity} !~ /$self->{option_results}->{filter_severity}/);
|
||||
next if (defined($self->{option_results}->{filter_message}) && $self->{option_results}->{filter_message} ne '' && $result->{errMsg} !~ /$self->{option_results}->{filter_message}/);
|
||||
|
||||
$num_errors++;
|
||||
$self->{output}->output_add(long_msg => sprintf("%s : %s [severity: %s]",
|
||||
$result->{errCode},
|
||||
$result->{errMsg}, $result->{errSeverity}
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("Number of message checked: %s", $num_eventlog_checked));
|
||||
if ($num_errors != 0) {
|
||||
# Message problem
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("%d problem detected (use verbose for more details)", $num_errors)
|
||||
);
|
||||
}
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check eventlogs.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--warning>
|
||||
|
||||
Use warning return instead 'critical'.
|
||||
|
||||
=item B<--filter-severity>
|
||||
|
||||
Filter on severity. (Default: hard|severe)
|
||||
Can be: severe, hard, mild, informational.
|
||||
|
||||
=item B<--filter-message>
|
||||
|
||||
Filter on event message. (Default: none)
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
|
@ -0,0 +1,107 @@
|
|||
#
|
||||
# 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 storage::overland::neo::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} = '^(drive|library)$';
|
||||
|
||||
$self->{cb_hook2} = 'snmp_execute';
|
||||
|
||||
$self->{thresholds} = {
|
||||
drive => [
|
||||
['initializedNoError', 'OK'],
|
||||
['initializedWithError', 'CRITICAL'],
|
||||
['notInitialized', 'WARNING'],
|
||||
['notInstalled', 'OK'],
|
||||
['notInserted', 'OK'],
|
||||
],
|
||||
library => [
|
||||
['initializing', 'OK'],
|
||||
['online', 'OK'],
|
||||
['offline', 'CRITICAL'],
|
||||
],
|
||||
};
|
||||
|
||||
$self->{components_path} = 'storage::overland::neo::snmp::mode::components';
|
||||
$self->{components_module} = ['drive', 'library'];
|
||||
}
|
||||
|
||||
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: 'drive', 'library', 'eventlog'.
|
||||
|
||||
=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='drive,OK,notInitialized'
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,50 @@
|
|||
#
|
||||
# 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 storage::overland::neo::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::overland::neo::snmp::mode::hardware',
|
||||
'eventlog' => 'storage::overland::neo::snmp::mode::eventlog',
|
||||
);
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 PLUGIN DESCRIPTION
|
||||
|
||||
Check Overland Neo Series in SNMP.
|
||||
Need to use --snmp-force-getnext options.
|
||||
|
||||
=cut
|
Loading…
Reference in New Issue