wip: netapp santricity

This commit is contained in:
garnier-quentin 2020-05-06 15:19:24 +02:00
parent 431be538b1
commit a614beb98d
13 changed files with 1201 additions and 0 deletions

View File

@ -0,0 +1,263 @@
#
# 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 storage::netapp::santricity::restapi::custom::api;
use strict;
use warnings;
use centreon::plugins::http;
use JSON::XS;
sub new {
my ($class, %options) = @_;
my $self = {};
bless $self, $class;
if (!defined($options{output})) {
print "Class Custom: Need to specify 'output' argument.\n";
exit 3;
}
if (!defined($options{options})) {
$options{output}->add_option_msg(short_msg => "Class Custom: Need to specify 'options' argument.");
$options{output}->option_exit();
}
if (!defined($options{noptions})) {
$options{options}->add_options(arguments => {
'api-username:s' => { name => 'api_username' },
'api-password:s' => { name => 'api_password' },
'hostname:s' => { name => 'hostname' },
'port:s' => { name => 'port' },
'proto:s' => { name => 'proto' },
'timeout:s' => { name => 'timeout' },
'api-path:s' => { name => 'api_path' },
'unknown-http-status:s' => { name => 'unknown_http_status' },
'warning-http-status:s' => { name => 'warning_http_status' },
'critical-http-status:s' => { name => 'critical_http_status' }
});
}
$options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1);
$self->{output} = $options{output};
$self->{mode} = $options{mode};
$self->{http} = centreon::plugins::http->new(%options);
return $self;
}
sub set_options {
my ($self, %options) = @_;
$self->{option_results} = $options{option_results};
}
sub set_defaults {
my ($self, %options) = @_;
foreach (keys %{$options{default}}) {
if ($_ eq $self->{mode}) {
for (my $i = 0; $i < scalar(@{$options{default}->{$_}}); $i++) {
foreach my $opt (keys %{$options{default}->{$_}[$i]}) {
if (!defined($self->{option_results}->{$opt}[$i])) {
$self->{option_results}->{$opt}[$i] = $options{default}->{$_}[$i]->{$opt};
}
}
}
}
}
}
sub check_options {
my ($self, %options) = @_;
$self->{hostname} = (defined($self->{option_results}->{hostname})) ? $self->{option_results}->{hostname} : '';
$self->{port} = (defined($self->{option_results}->{port})) ? $self->{option_results}->{port} : 8080;
$self->{proto} = (defined($self->{option_results}->{proto})) ? $self->{option_results}->{proto} : 'http';
$self->{timeout} = (defined($self->{option_results}->{timeout})) ? $self->{option_results}->{timeout} : 10;
$self->{api_username} = (defined($self->{option_results}->{api_username})) ? $self->{option_results}->{api_username} : '';
$self->{api_password} = (defined($self->{option_results}->{api_password})) ? $self->{option_results}->{api_password} : '';
$self->{api_path} = (defined($self->{option_results}->{api_path})) ? $self->{option_results}->{api_path} : '/devmgr/v2';
$self->{unknown_http_status} = (defined($self->{option_results}->{unknown_http_status})) ? $self->{option_results}->{unknown_http_status} : '(%{http_code} < 200 or %{http_code} >= 300) and %{http_code} != 424';
$self->{warning_http_status} = (defined($self->{option_results}->{warning_http_status})) ? $self->{option_results}->{warning_http_status} : '';
$self->{critical_http_status} = (defined($self->{option_results}->{critical_http_status})) ? $self->{option_results}->{critical_http_status} : '';
if (!defined($self->{hostname}) || $self->{hostname} eq '') {
$self->{output}->add_option_msg(short_msg => "Need to specify --hostname option.");
$self->{output}->option_exit();
}
if (!defined($self->{api_username}) || $self->{api_username} eq '') {
$self->{output}->add_option_msg(short_msg => "Need to specify --api-username option.");
$self->{output}->option_exit();
}
if (!defined($self->{api_password}) || $self->{api_password} eq '') {
$self->{output}->add_option_msg(short_msg => "Need to specify --api-password option.");
$self->{output}->option_exit();
}
return 0;
}
sub build_options_for_httplib {
my ($self, %options) = @_;
$self->{option_results}->{hostname} = $self->{hostname};
$self->{option_results}->{timeout} = $self->{timeout};
$self->{option_results}->{port} = $self->{port};
$self->{option_results}->{proto} = $self->{proto};
$self->{option_results}->{timeout} = $self->{timeout};
$self->{option_results}->{credentials} = 1;
$self->{option_results}->{basic} = 1;
$self->{option_results}->{username} = $self->{api_username};
$self->{option_results}->{password} = $self->{api_password};
}
sub settings {
my ($self, %options) = @_;
return if (defined($self->{settings_done}));
$self->build_options_for_httplib();
$self->{http}->add_header(key => 'Accept', value => 'application/json');
$self->{http}->add_header(key => 'Content-Type', value => 'application/json');
$self->{http}->set_options(%{$self->{option_results}});
$self->{settings_done} = 1;
}
sub get_hostname {
my ($self, %options) = @_;
return $self->{hostname};
}
sub request_api {
my ($self, %options) = @_;
$self->settings();
my $content = $self->{http}->request(
method => defined($options{method}) ? $options{method} : 'GET',
url_path => $self->{api_path} . '/' . $options{endpoint},
unknown_status => $self->{unknown_http_status},
warning_status => $self->{warning_http_status},
critical_status => $self->{critical_http_status},
cookies_file => '' # in memory
);
# code 424 = storageDevice offline
my $code = $self->{http}->get_code();
if (!defined($content) || $content eq '') {
$self->{output}->add_option_msg(short_msg => "API returns empty content [code: '" . $self->{http}->get_code() . "'] [message: '" . $self->{http}->get_message() . "']");
$self->{output}->option_exit();
}
return undef if ($code == 424);
my $decoded;
eval {
$decoded = JSON::XS->new->utf8->decode($content);
};
if ($@) {
$self->{output}->add_option_msg(short_msg => "Cannot decode response (add --debug option to display returned content)");
$self->{output}->option_exit();
}
return { $options{name} => $decoded };
}
sub execute_storages_request {
my ($self, %options) = @_;
my $content = do {
local $/ = undef;
if (!open my $fh, "<", '/home/qgarnier/clients/plugins/todo/santricity/test-inventory.txt') {
$self->{output}->add_option_msg(short_msg => "Could not open file $self->{option_results}->{$_} : $!");
$self->{output}->option_exit();
}
<$fh>;
};
eval {
$content = JSON::XS->new->utf8->decode($content);
};
return $content;
my $storages = $self->request_api(name => 'storages', endpoint => '/storage-systems');
for (my $i = 0; $i < scalar(@{$storages->{storages}}); $i++) {
next if (defined($options{filter_name}) && $options{filter_name} ne '' &&
$storages->{storages}->{$i}->{name} !~ /$options{filter_name}/);
my $info = $self->request_api(name => 'info', endpoint => '/' . $storages->{storages}->{$i}->{wwn} . '/' . $options{endpoint});
$storages->{storages}->{$i}->{offline} = 0;
$storages->{storages}->{$i}->{offline} = 1 if (!defined($info));
$storages->{storages}->{$i}->{ $options{endpoint} } = defined($info) ? $info->{info} : undef;
}
return $storages;
}
1;
__END__
=head1 NAME
Netapp Santricity Rest API
=head1 REST API OPTIONS
Netapp Santricity Rest API
=over 8
=item B<--hostname>
Santricity hostname.
=item B<--port>
Port used (Default: 8080)
=item B<--proto>
Specify https if needed (Default: 'http')
=item B<--api-username>
Santricity API username.
=item B<--api-password>
Santricity API password.
=item B<--api-path>
Specify api path (Default: '/devmgr/v2')
=item B<--timeout>
Set timeout in seconds (Default: 10).
=back
=head1 DESCRIPTION
B<custom>.
=cut

View File

@ -0,0 +1,67 @@
#
# 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 storage::netapp::santricity::restapi::mode::components::battery;
use strict;
use warnings;
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => 'checking batteries');
$self->{components}->{battery} = { name => 'batteries', total => 0, skip => 0 };
return if ($self->check_filter(section => 'battery'));
return if (!defined($self->{json_results}->{storages}));
foreach (@{$self->{json_results}->{storages}}) {
my $storage_name = $_->{name};
next if ($self->check_filter(section => 'storage', instance => $_->{chassisSerialNumber}));
next if (!defined($_->{'/hardware-inventory'}->{batteries}));
foreach my $entry (@{$_->{'/hardware-inventory'}->{batteries}}) {
my $instance = $entry->{batteryRef};
my $name = $storage_name . ':' . $entry->{physicalLocation}->{locationPosition} . ':' . $entry->{physicalLocation}->{slot};
next if ($self->check_filter(section => 'battery', instance => $instance));
$self->{components}->{battery}->{total}++;
$self->{output}->output_add(
long_msg => sprintf(
"battery '%s' status is '%s' [instance = %s]",
$name, $entry->{status}, $instance
)
);
my $exit = $self->get_severity(section => 'battery', instance => $instance, value => $entry->{status});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf("Battery '%s' status is '%s'", $name, $entry->{status})
);
}
}
}
}
1;

View File

@ -0,0 +1,67 @@
#
# 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 storage::netapp::santricity::restapi::mode::components::board;
use strict;
use warnings;
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => 'checking boards');
$self->{components}->{board} = { name => 'boards', total => 0, skip => 0 };
return if ($self->check_filter(section => 'board'));
return if (!defined($self->{json_results}->{storages}));
foreach (@{$self->{json_results}->{storages}}) {
my $storage_name = $_->{name};
next if ($self->check_filter(section => 'storage', instance => $_->{chassisSerialNumber}));
next if (!defined($_->{'/hardware-inventory'}->{hostBoards}));
foreach my $entry (@{$_->{'/hardware-inventory'}->{hostBoards}}) {
my $instance = $entry->{hostBoardRef};
my $name = $storage_name . ':' . $entry->{physicalLocation}->{locationPosition} . ':' . $entry->{physicalLocation}->{slot};
next if ($self->check_filter(section => 'board', instance => $instance));
$self->{components}->{board}->{total}++;
$self->{output}->output_add(
long_msg => sprintf(
"board '%s' status is '%s' [instance = %s]",
$name, $entry->{status}, $instance
)
);
my $exit = $self->get_severity(section => 'board', instance => $instance, value => $entry->{status});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf("Board '%s' status is '%s'", $name, $entry->{status})
);
}
}
}
}
1;

View File

@ -0,0 +1,67 @@
#
# 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 storage::netapp::santricity::restapi::mode::components::cbd;
use strict;
use warnings;
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => 'checking cache backup devices');
$self->{components}->{cbd} = { name => 'cbd', total => 0, skip => 0 };
return if ($self->check_filter(section => 'cbd'));
return if (!defined($self->{json_results}->{storages}));
foreach (@{$self->{json_results}->{storages}}) {
my $storage_name = $_->{name};
next if ($self->check_filter(section => 'storage', instance => $_->{chassisSerialNumber}));
next if (!defined($_->{'/hardware-inventory'}->{cacheBackupDevices}));
foreach my $entry (@{$_->{'/hardware-inventory'}->{cacheBackupDevices}}) {
my $instance = $entry->{backupDeviceRef};
my $name = $storage_name . ':' . $entry->{physicalLocation}->{locationPosition} . ':' . $entry->{physicalLocation}->{slot};
next if ($self->check_filter(section => 'cbd', instance => $instance));
$self->{components}->{cbd}->{total}++;
$self->{output}->output_add(
long_msg => sprintf(
"cache backup device '%s' status is '%s' [instance = %s]",
$name, $entry->{backupDeviceStatus}, $instance
)
);
my $exit = $self->get_severity(section => 'cbd', instance => $instance, value => $entry->{backupDeviceStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf("Cache backup device '%s' status is '%s'", $name, $entry->{backupDeviceStatus})
);
}
}
}
}
1;

View File

@ -0,0 +1,67 @@
#
# 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 storage::netapp::santricity::restapi::mode::components::cmd;
use strict;
use warnings;
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => 'checking cache memory dimms');
$self->{components}->{cmd} = { name => 'cmd', total => 0, skip => 0 };
return if ($self->check_filter(section => 'cmd'));
return if (!defined($self->{json_results}->{storages}));
foreach (@{$self->{json_results}->{storages}}) {
my $storage_name = $_->{name};
next if ($self->check_filter(section => 'storage', instance => $_->{chassisSerialNumber}));
next if (!defined($_->{'/hardware-inventory'}->{cacheMemoryDimms}));
foreach my $entry (@{$_->{'/hardware-inventory'}->{cacheMemoryDimms}}) {
my $instance = $entry->{cacheMemoryDimmRef};
my $name = $storage_name . ':' . $entry->{physicalLocation}->{locationPosition} . ':' . $entry->{physicalLocation}->{slot};
next if ($self->check_filter(section => 'cmd', instance => $instance));
$self->{components}->{cbd}->{total}++;
$self->{output}->output_add(
long_msg => sprintf(
"cache memory dimm '%s' status is '%s' [instance = %s]",
$name, $entry->{status}, $instance
)
);
my $exit = $self->get_severity(section => 'cmd', instance => $instance, value => $entry->{status});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf("Cache memory dimm '%s' status is '%s'", $name, $entry->{status})
);
}
}
}
}
1;

View File

@ -0,0 +1,67 @@
#
# 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 storage::netapp::santricity::restapi::mode::components::ctrl;
use strict;
use warnings;
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => 'checking controllers');
$self->{components}->{ctrl} = { name => 'ctrl', total => 0, skip => 0 };
return if ($self->check_filter(section => 'ctrl'));
return if (!defined($self->{json_results}->{storages}));
foreach (@{$self->{json_results}->{storages}}) {
my $storage_name = $_->{name};
next if ($self->check_filter(section => 'storage', instance => $_->{chassisSerialNumber}));
next if (!defined($_->{'/hardware-inventory'}->{controllers}));
foreach my $entry (@{$_->{'/hardware-inventory'}->{controllers}}) {
my $instance = $entry->{controllerRef};
my $name = $storage_name . ':' . $entry->{physicalLocation}->{locationPosition} . ':' . $entry->{physicalLocation}->{slot};
next if ($self->check_filter(section => 'ctrl', instance => $instance));
$self->{components}->{ctrl}->{total}++;
$self->{output}->output_add(
long_msg => sprintf(
"controller '%s' status is '%s' [instance = %s]",
$name, $entry->{status}, $instance
)
);
my $exit = $self->get_severity(section => 'ctrl', instance => $instance, value => $entry->{status});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf("Controller '%s' status is '%s'", $name, $entry->{status})
);
}
}
}
}
1;

View File

@ -0,0 +1,101 @@
#
# 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 storage::netapp::santricity::restapi::mode::components::drive;
use strict;
use warnings;
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => 'checking drives');
$self->{components}->{drive} = { name => 'drive', total => 0, skip => 0 };
return if ($self->check_filter(section => 'drive'));
return if (!defined($self->{json_results}->{storages}));
foreach (@{$self->{json_results}->{storages}}) {
my $storage_name = $_->{name};
next if ($self->check_filter(section => 'storage', instance => $_->{chassisSerialNumber}));
next if (!defined($_->{'/hardware-inventory'}->{drives}));
foreach my $entry (@{$_->{'/hardware-inventory'}->{drives}}) {
my $instance = $entry->{driveRef};
my $name = $storage_name . ':' . $entry->{physicalLocation}->{locationPosition} . ':' . $entry->{physicalLocation}->{slot};
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] [temperature: %s]",
$name, $entry->{status}, $instance, $entry->{driveTemperature}->{currentTemp}
)
);
my $exit = $self->get_severity(section => 'drive', instance => $instance, value => $entry->{status});
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'", $name, $entry->{status})
);
}
my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'drive.temperature', instance => $instance, value => $entry->{driveTemperature}->{currentTemp});
if ($checked == 0) {
my $warn_th = '';
my $crit_th = defined($entry->{driveTemperature}->{refTemp}) ? $entry->{driveTemperature}->{refTemp} : '';
$self->{perfdata}->threshold_validate(label => 'warning-drive.temperature-instance-' . $instance, value => $warn_th);
$self->{perfdata}->threshold_validate(label => 'critical-drive.temperature-instance-' . $instance, value => $crit_th);
$exit = $self->{perfdata}->threshold_check(
value => $entry->{driveTemperature}->{currentTemp},
threshold => [
{ label => 'critical-drive.temperature-instance-' . $instance, exit_litteral => 'critical' },
{ label => 'warning-drive.temperature-instance-' . $instance, exit_litteral => 'warning' }
]
);
$warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-drive.temperature-instance-' . $instance);
$crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-drive.temperature-instance-' . $instance)
}
if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(
severity => $exit2,
short_msg => sprintf("drive '%s' temperature is %s C", $name, $entry->{driveTemperature}->{currentTemp})
);
}
$self->{output}->perfdata_add(
nlabel => 'hardware.drive.temperature.celsius',
unit => 'C',
instances => $name,
value => $entry->{driveTemperature}->{currentTemp},
warning => $warn,
critical => $crit
);
}
}
}
1;

View File

@ -0,0 +1,67 @@
#
# 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 storage::netapp::santricity::restapi::mode::components::fan;
use strict;
use warnings;
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'));
return if (!defined($self->{json_results}->{storages}));
foreach (@{$self->{json_results}->{storages}}) {
my $storage_name = $_->{name};
next if ($self->check_filter(section => 'storage', instance => $_->{chassisSerialNumber}));
next if (!defined($_->{'/hardware-inventory'}->{fans}));
foreach my $entry (@{$_->{'/hardware-inventory'}->{fans}}) {
my $instance = $entry->{fanRef};
my $name = $storage_name . ':' . $entry->{physicalLocation}->{locationPosition} . ':' . $entry->{physicalLocation}->{slot};
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]",
$name, $entry->{status}, $instance
)
);
my $exit = $self->get_severity(section => 'fan', instance => $instance, value => $entry->{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'", $name, $entry->{status})
);
}
}
}
}
1;

View File

@ -0,0 +1,67 @@
#
# 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 storage::netapp::santricity::restapi::mode::components::psu;
use strict;
use warnings;
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'));
return if (!defined($self->{json_results}->{storages}));
foreach (@{$self->{json_results}->{storages}}) {
my $storage_name = $_->{name};
next if ($self->check_filter(section => 'storage', instance => $_->{chassisSerialNumber}));
next if (!defined($_->{'/hardware-inventory'}->{powerSupplies}));
foreach my $entry (@{$_->{'/hardware-inventory'}->{powerSupplies}}) {
my $instance = $entry->{powerSupplyRef};
my $name = $storage_name . ':' . $entry->{physicalLocation}->{locationPosition} . ':' . $entry->{physicalLocation}->{slot};
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]",
$name, $entry->{status}, $instance,
)
);
my $exit = $self->get_severity(section => 'psu', instance => $instance, value => $entry->{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'", $name, $entry->{status})
);
}
}
}
}
1;

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 storage::netapp::santricity::restapi::mode::components::storage;
use strict;
use warnings;
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => 'checking storages');
$self->{components}->{storage} = { name => 'storages', total => 0, skip => 0 };
return if ($self->check_filter(section => 'storage'));
return if (!defined($self->{json_results}->{storages}));
foreach (@{$self->{json_results}->{storages}}) {
my $instance = $_->{chassisSerialNumber};
next if ($self->check_filter(section => 'storage', instance => $instance));
$self->{components}->{storage}->{total}++;
$self->{output}->output_add(
long_msg => sprintf(
"storage '%s' status is '%s' [instance = %s]",
$_->{name}, $_->{status}, $instance,
)
);
my $exit = $self->get_severity(section => 'storage', instance => $instance, value => $_->{status});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf("Storage '%s' status is '%s'", $_{name}, $_->{status})
);
}
}
}
1;

View File

@ -0,0 +1,67 @@
#
# 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 storage::netapp::santricity::restapi::mode::components::thsensor;
use strict;
use warnings;
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => 'checking thermal sensors');
$self->{components}->{thsensor} = { name => 'thsensor', total => 0, skip => 0 };
return if ($self->check_filter(section => 'thsensor'));
return if (!defined($self->{json_results}->{storages}));
foreach (@{$self->{json_results}->{storages}}) {
my $storage_name = $_->{name};
next if ($self->check_filter(section => 'storage', instance => $_->{chassisSerialNumber}));
next if (!defined($_->{'/hardware-inventory'}->{thermalSensors}));
foreach my $entry (@{$_->{'/hardware-inventory'}->{thermalSensors}}) {
my $instance = $entry->{thermalSensorRef};
my $name = $storage_name . ($entry->{physicalLocation}->{label} ne '' ? ':' . $entry->{physicalLocation}->{label} : '') . ':' . $entry->{physicalLocation}->{locationPosition} . ':' . $entry->{physicalLocation}->{slot};
next if ($self->check_filter(section => 'thsensor', instance => $instance));
$self->{components}->{thsensor}->{total}++;
$self->{output}->output_add(
long_msg => sprintf(
"thermal sensor '%s' status is '%s' [instance = %s]",
$name, $entry->{status}, $instance,
)
);
my $exit = $self->get_severity(section => 'thsensor', instance => $instance, value => $entry->{status});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf("Thermal sensor '%s' status is '%s'", $name, $entry->{status})
);
}
}
}
}
1;

View File

@ -0,0 +1,194 @@
#
# 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 storage::netapp::santricity::restapi::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} =
'^(?:storage|battery|cbd|cmd|boards|psu|fan|thsensor|ctrl|drive)$';
$self->{regexp_threshold_numeric_check_section_option} = '^(?:drive.temperature)$';
$self->{cb_hook2} = 'execute_custom';
$self->{thresholds} = {
battery => [
['optimal', 'OK'],
['fullCharging', 'OK'],
['nearExpiration', 'WARNING'],
['failed', 'CRITICAL'],
['removed', 'OK'],
['unknown', 'UNKNOWN'],
['notInConfig', 'WARNING'],
['configMismatch', 'WARNING'],
['learning', 'OK'],
['overtemp', ''],
['expired', 'WARNING'],
['maintenanceCharging', 'OK'],
['replacementRequired', 'CRTICICAL']
],
board => [
['unknown', 'UNKNOWN'],
['optimal', 'OK'],
['needsAttention', 'WARNING'],
['notPresent', 'OK'],
['degraded', 'WARNING'],
['failed', 'CRITICAL'],
['diagInProgress', 'OK']
],
cbd => [
['unknown', 'UNKNOWN'],
['optimal', 'OK'],
['failed', 'CRITICAL'],
['removed', 'OK'],
['writeProtected', 'OK'],
['incompatible', 'CRITICAL']
],
cmd => [
['unknown', 'UNKNOWN'],
['optimal', 'OK'],
['failed', 'CRITICAL'],
['empty', 'OK']
],
ctrl => [
['unknown', 'UNKNOWN'],
['optimal', 'OK'],
['failed', 'CRITICAL'],
['removed', 'OK'],
['rpaParErr', 'WAARNING'],
['serviceMode', 'OK'],
['suspended', 'OK'],
['degraded', 'WARNING']
],
drive => [
['optimal', 'OK'],
['failed', 'CRITICAL'],
['replaced', 'OK'],
['bypassed', 'OK'],
['unresponsive', 'WARNING'],
['removed', 'OK'],
['incompatible', 'WARNING'],
['dataRelocation', 'OK'],
['preFailCopy', 'WARNING'],
['preFailCopyPending', 'WARNING']
],
fan => [
['optimal', 'OK'],
['removed', 'OK'],
['failed', 'CRITICAL'],
['unknown', 'UNKNOWN']
],
psu => [
['optimal', 'OK'],
['removed', 'OK'],
['failed', 'CRITICAL'],
['unknown', 'UNKNOWN'],
['noinput', 'WARNING']
],
storage => [
['neverContacted', 'UNKNOWN'],
['offline', 'OK'],
['optimal', 'OK'],
['needsAttn', 'WARNING'],
['newDevice', 'OK'],
['lockDown', 'WARNING']
],
thsensor => [
['optimal', 'OK'],
['nominalTempExceed', 'WARNING'],
['maxTempExceed', 'CRITICAL'],
['unknown', 'UNKNOWN'],
['removed', 'OK']
]
};
$self->{components_exec_load} = 0;
$self->{components_path} = 'storage::netapp::santricity::restapi::mode::components';
$self->{components_module} = [
'storage', 'ctrl', 'battery', 'board', 'cbd', 'cmd', 'drive', 'psu', 'fan',
'thsensor'
];
}
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;
}
sub execute_custom {
my ($self, %options) = @_;
$self->{json_results} = $options{custom}->execute_storages_request(endpoint => '/hardware-inventory');
}
1;
=head1 MODE
Check hardware.
=over 8
=item B<--component>
Which component to check (Default: '.*').
Can be: 'storage', 'ctrl', 'battery', 'board', 'cbd', 'cmd', 'drive', 'psu', 'fan', 'thsensor'.
=item B<--filter>
Exclude some parts (comma seperated list)
Can also exclude specific instance: --filter='drive,010000005000C500C244251B0000000000000000'
=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,preFailCopy'
=item B<--warning>
Set warning threshold for 'temperature' (syntax: type,regexp,threshold)
Example: --warning='drive.temperature,.*,40'
=item B<--critical>
Set critical threshold for 'drive.temperature' (syntax: type,regexp,threshold)
Example: --critical='drive.temperature,.*,50'
=back
=cut

View File

@ -0,0 +1,49 @@
#
# 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 storage::netapp::santricity::restapi::plugin;
use strict;
use warnings;
use base qw(centreon::plugins::script_custom);
sub new {
my ( $class, %options ) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '0.1';
%{ $self->{modes} } = (
'hardware' => 'storage::netapp::santricity::restapi::mode::hardware'
);
$self->{custom_modes}{api} = 'storage::netapp::santricity::restapi::custom::api';
return $self;
}
1;
__END__
=head1 PLUGIN DESCRIPTION
Check Netapp storages with Santricity using Rest API.
=cut