mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-23 21:55:16 +02:00
Merge pull request #133 from Sims24/emcvplex
EMC Vplex Monitoring through rest API
This commit is contained in:
commit
fec4b50f8d
253
storage/emc/vplex/restapi/custom/vplexapi.pm
Normal file
253
storage/emc/vplex/restapi/custom/vplexapi.pm
Normal file
@ -0,0 +1,253 @@
|
||||
#
|
||||
# Copyright 2015 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::emc::vplex::restapi::custom::vplexapi;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::http;
|
||||
use JSON;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = {};
|
||||
bless $self, $class;
|
||||
# $options{options} = options object
|
||||
# $options{output} = output object
|
||||
# $options{exit_value} = integer
|
||||
# $options{noptions} = integer
|
||||
|
||||
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 =>
|
||||
{
|
||||
"hostname:s@" => { name => 'hostname', },
|
||||
"proxyurl:s@" => { name => 'proxyurl', },
|
||||
"timeout:s@" => { name => 'timeout', },
|
||||
"header:s@" => { name => 'header', },
|
||||
});
|
||||
}
|
||||
$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(output => $self->{output});
|
||||
|
||||
return $self;
|
||||
|
||||
}
|
||||
|
||||
# Method to manage multiples
|
||||
sub set_options {
|
||||
my ($self, %options) = @_;
|
||||
# options{options_result}
|
||||
|
||||
$self->{option_results} = $options{option_results};
|
||||
}
|
||||
|
||||
# Method to manage multiples
|
||||
sub set_defaults {
|
||||
my ($self, %options) = @_;
|
||||
# options{default}
|
||||
|
||||
# Manage default value
|
||||
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) = @_;
|
||||
# # return 1 = ok still hostname
|
||||
# # return 0 = no hostname left
|
||||
|
||||
$self->{hostname} = (defined($self->{option_results}->{hostname})) ? shift(@{$self->{option_results}->{hostname}}) : undef;
|
||||
$self->{timeout} = (defined($self->{option_results}->{timeout})) ? shift(@{$self->{option_results}->{timeout}}) : 10;
|
||||
$self->{port} = (defined($self->{option_results}->{port})) ? shift(@{$self->{option_results}->{port}}) : 443;
|
||||
$self->{proto} = (defined($self->{option_results}->{proto})) ? shift(@{$self->{option_results}->{proto}}) : 'https';
|
||||
$self->{proxyurl} = (defined($self->{option_results}->{proxyurl})) ? shift(@{$self->{option_results}->{proxyurl}}) : undef;
|
||||
|
||||
if (!defined($self->{hostname})) {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify hostname option.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
if (defined($self->{option_results}->{header})) {
|
||||
$self->{headers} = {};
|
||||
foreach (@{$self->{option_results}->{header}}) {
|
||||
if (/^(.*?):(.*)/) {
|
||||
$self->{headers}->{$1} = $2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!defined($self->{hostname}) ||
|
||||
scalar(@{$self->{option_results}->{hostname}}) == 0) {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
sub build_options_for_httplib {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{option_results}->{hostname} = $self->{hostname};
|
||||
$self->{option_results}->{timeout} = $self->{timeout};
|
||||
$self->{option_results}->{port} = 443;
|
||||
$self->{option_results}->{proto} = 'https';
|
||||
$self->{option_results}->{proxyurl} = $self->{proxyurl};
|
||||
$self->{option_results}->{url_path} = $self->{url_path};
|
||||
|
||||
}
|
||||
|
||||
sub connect {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->build_options_for_httplib();
|
||||
$self->{http}->set_options(%{$self->{option_results}});
|
||||
|
||||
}
|
||||
|
||||
sub get_items {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $url = $options{url};
|
||||
my $obj = $options{obj};
|
||||
my $engine = $options{engine};
|
||||
|
||||
my @items;
|
||||
if ($engine) {
|
||||
$url .= $engine.'/'.$obj.'/';
|
||||
} elsif (defined $obj) {
|
||||
$url .= '/'.$obj;
|
||||
};
|
||||
|
||||
my $response = $self->{http}->request(url_path => $url);
|
||||
my $decoded = decode_json($response);
|
||||
|
||||
foreach my $child (@{ $decoded->{response}->{context}->[0]->{children} } ) {
|
||||
push @items, $child->{name};
|
||||
}
|
||||
|
||||
return @items;
|
||||
}
|
||||
|
||||
sub get_param {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $url = $options{url};
|
||||
my $obj = $options{obj};
|
||||
my $engine = $options{engine};
|
||||
my $item = $options{item};
|
||||
my $param = $options{param};
|
||||
|
||||
if ( (defined $engine) && (defined $obj) ) {
|
||||
$url .= $engine.'/'.$obj.'/'.$item.'?'.$param;
|
||||
} elsif (defined $engine) {
|
||||
$url .= $engine.'/'.$item.'?'.$param;
|
||||
} else {
|
||||
$url .= '/'.$item.'?'.$param;
|
||||
}
|
||||
|
||||
my $response = $self->{http}->request(url_path => $url);
|
||||
my $decoded = decode_json($response);
|
||||
|
||||
return $decoded->{response};
|
||||
|
||||
}
|
||||
|
||||
sub get_infos {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $url = $options{url};
|
||||
my $obj = $options{obj};
|
||||
my $engine = $options{engine};
|
||||
my $item = $options{item};
|
||||
|
||||
if (defined $engine) {
|
||||
$url .= $engine.'/'.$obj.'/'.$item;
|
||||
} elsif (defined $obj) {
|
||||
$url .= '/'.$obj;
|
||||
} else {
|
||||
$url .= '/'.$item;
|
||||
}
|
||||
|
||||
my $response = $self->{http}->request(url_path => $url);
|
||||
my $decoded = decode_json($response);
|
||||
|
||||
return $decoded->{response};
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
VPLEX REST API
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
Vplex Rest API custom mode
|
||||
|
||||
=head1 REST API OPTIONS
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--hostname>
|
||||
|
||||
Vplex Hostname.
|
||||
|
||||
=item B<--proxyurl>
|
||||
|
||||
Proxy URL if any
|
||||
|
||||
=item B<--timeout>
|
||||
|
||||
Set HTTP timeout
|
||||
|
||||
=item B<--header>
|
||||
|
||||
Set HTTPS Headers (specify multiple time e.g )
|
||||
|
||||
=back
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
B<custom>.
|
||||
|
||||
=cut
|
121
storage/emc/vplex/restapi/mode/clustercommunication.pm
Normal file
121
storage/emc/vplex/restapi/mode/clustercommunication.pm
Normal file
@ -0,0 +1,121 @@
|
||||
#
|
||||
# Copyright 2015 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::emc::vplex::restapi::mode::clustercommunication;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.1';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"cluster-nodes:s@" => { name => 'cluster_nodes', },
|
||||
"witness-name:s" => { name => 'witness_name', },
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
if ( !defined($self->{option_results}->{cluster_nodes}) || !defined($self->{option_results}->{witness_name}) ) {
|
||||
$self->{output}->add_option_msg(short_msg => "You need to cluster-nodes AND witness-name options.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
my $vplex = $options{custom};
|
||||
|
||||
my $urlbase = '/vplex/cluster-witness/components/';
|
||||
my @nodes = split /,/, $self->{option_results}->{cluster_nodes}->[0];
|
||||
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => 'Cluster communication is OK');
|
||||
|
||||
$vplex->connect();
|
||||
|
||||
foreach my $node (@nodes) {
|
||||
my $details = $vplex->get_param(url => $urlbase,
|
||||
item => $node,
|
||||
param => 'operational-state');
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("Node '%s' is '%s'", $node,
|
||||
$details->{context}->[0]->{attributes}->[0]->{value}));
|
||||
|
||||
if ($details->{context}->[0]->{attributes}->[0]->{value} ne 'in-contact') {
|
||||
$self->{output}->output_add(severity => 'CRITICAL',
|
||||
short_msg => sprintf("Node '%s' is '%s'",
|
||||
$node, $details->{context}->[0]->{attributes}->[0]->{value}));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
my $details = $vplex->get_param(url => $urlbase,
|
||||
item => $self->{option_results}->{witness_name},
|
||||
param => 'operational-state');
|
||||
|
||||
|
||||
if ($details->{context}->[0]->{attributes}->[0]->{value} ne 'clusters-in-contact') {
|
||||
$self->{output}->output_add(severity => 'CRITICAL',
|
||||
short_msg => sprintf("Witness '%s' see nodes as '%s'",
|
||||
$self->{option_results}->{witness_name},
|
||||
$details->{context}->[0]->{attributes}->[0]->{value}));
|
||||
}
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("Witness '%s' says '%s'", $self->{option_results}->{witness_name},
|
||||
$details->{context}->[0]->{attributes}->[0]->{value}));
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check Cluster communication state for VPlex
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--cluster-nodes>
|
||||
|
||||
Mandatory. Specify the name of your cluster nodes, as comma-separated list (EMC defaults are 'cluster-1', 'cluster-2', ..
|
||||
|
||||
=item B<--cluster-nodes>
|
||||
|
||||
Mandatory. Specify the name of your witness server (EMC default is 'server')
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
113
storage/emc/vplex/restapi/mode/clusterdevices
Normal file
113
storage/emc/vplex/restapi/mode/clusterdevices
Normal file
@ -0,0 +1,113 @@
|
||||
#
|
||||
# Copyright 2015 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::emc::vplex::restapi::mode::clusterdevices;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.1';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"cluster:s" => { name => 'cluster', default => 'cluster-1' },
|
||||
"filter-name:s" => { name => 'filter_name' },
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
my $vplex = $options{custom};
|
||||
|
||||
my $urlbase = '/vplex/clusters/'.$self->{option_results}->{cluster}.'/devices/';
|
||||
|
||||
$vplex->connect();
|
||||
|
||||
my @items = $vplex->get_items(url => $urlbase);
|
||||
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => 'All Cluster Devices are OK');
|
||||
foreach my $item (@items) {
|
||||
|
||||
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
||||
$item !~ /$self->{option_results}->{filter_name}/) {
|
||||
$self->{output}->output_add(long_msg => sprintf("Skipping storage '%s'.", $item));
|
||||
next;
|
||||
}
|
||||
|
||||
my $details = $vplex->get_param(url => $urlbase,
|
||||
item => $item,
|
||||
param => 'health-state');
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("Device '%s' health state is '%s'",
|
||||
$item,
|
||||
$details->{context}->[0]->{attributes}->[0]->{value}
|
||||
));
|
||||
|
||||
if ($details->{context}->[0]->{attributes}->[0]->{value} ne 'ok') {
|
||||
$self->{output}->output_add(severity => 'CRITICAL',
|
||||
short_msg => sprintf("Storage '%s' service is '%s'",
|
||||
$item,
|
||||
$details->{context}->[0]->{attributes}->[0]->{value}
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check Cluster devices health for VPlex
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--cluster>
|
||||
|
||||
Set cluster name to check (cluster-1 and cluster-2)
|
||||
|
||||
=item B<--filter-name>
|
||||
|
||||
Filter some elements by name (can be a regexp)
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
163
storage/emc/vplex/restapi/mode/directors.pm
Normal file
163
storage/emc/vplex/restapi/mode/directors.pm
Normal file
@ -0,0 +1,163 @@
|
||||
#
|
||||
# Copyright 2015 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::emc::vplex::restapi::mode::directors;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.1';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"engine:s" => { name => 'engine', default => '1-1' },
|
||||
"filter-name:s" => { name => 'filter_name'},
|
||||
"detailed:s" => { name => 'detailed'},
|
||||
});
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
if (!defined($self->{option_results}->{engine})) {
|
||||
$self->{output}->add_option_msg(short_msg => "You need to specify engine number.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
my $vplex = $options{custom};
|
||||
|
||||
my $urlbase = '/vplex/engines/engine-';
|
||||
|
||||
$vplex->connect();
|
||||
|
||||
my @items = $vplex->get_items(url => $urlbase,
|
||||
engine => $self->{option_results}->{engine},
|
||||
obj => 'directors');
|
||||
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => 'All Directors are OK');
|
||||
|
||||
if (defined($self->{option_results}->{detailed})) {
|
||||
|
||||
foreach my $item (@items) {
|
||||
|
||||
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
||||
$item !~ /$self->{option_results}->{filter_name}/) {
|
||||
$self->{output}->output_add(long_msg => sprintf("Skipping storage '%s'.", $item));
|
||||
next;
|
||||
}
|
||||
|
||||
my $details = $vplex->get_infos(url => $urlbase,
|
||||
obj => 'directors',
|
||||
engine => $self->{option_results}->{engine},
|
||||
item => $item);
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("Director '%s': communication-status -> '%s' health-state -> '%s' temp thresold exceeded -> '%s' voltage thresold exceeded -> '%s'",
|
||||
$item,
|
||||
$details->{context}->[0]->{attributes}->[5]->{value},
|
||||
$details->{context}->[0]->{attributes}->[15]->{value},
|
||||
$details->{context}->[0]->{attributes}->[28]->{value},
|
||||
$details->{context}->[0]->{attributes}->[29]->{value}
|
||||
));
|
||||
|
||||
if (($details->{context}->[0]->{attributes}->[15]->{value} ne 'ok') || ($details->{context}->[0]->{attributes}->[5]->{value} ne 'ok')) {
|
||||
$self->{output}->output_add(severity => 'CRITICAL',
|
||||
short_msg => sprintf("Director '%s' communication-status is '%s' (health='%s')",
|
||||
$item,
|
||||
$details->{context}->[0]->{attributes}->[5]->{value},
|
||||
$details->{context}->[0]->{attributes}->[15]->{value}->[0]));
|
||||
} elsif (($details->{context}->[0]->{attributes}->[28]->{value} ne 'false') || ($details->{context}->[0]->{attributes}->[29]->{value} ne 'false')) {
|
||||
$self->{output}->output_add(severity => 'CRITICAL',
|
||||
short_msg => sprintf("Director '%s' temp threshold is '%s' and voltage threshold is '%s'",
|
||||
$details->{context}->[0]->{attributes}->[28]->{value},
|
||||
$details->{context}->[0]->{attributes}->[29]->{value}));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
foreach my $item (@items) {
|
||||
|
||||
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
||||
$item !~ /$self->{option_results}->{filter_name}/) {
|
||||
$self->{output}->output_add(long_msg => sprintf("Skipping storage '%s'.", $item));
|
||||
next;
|
||||
}
|
||||
|
||||
my $details = $vplex->get_param(url => $urlbase,
|
||||
obj => 'directors',
|
||||
engine => $self->{option_results}->{engine},
|
||||
param => 'health-state',
|
||||
item => $item);
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("Director '%s' health-state -> '%s'",
|
||||
$item, $details->{context}->[0]->{attributes}->[0]->{value}));
|
||||
|
||||
if ($details->{context}->[0]->{attributes}->[0]->{value} ne 'ok') {
|
||||
$self->{output}->output_add(severity => 'CRITICAL',
|
||||
short_msg => sprintf("Director '%s' health is '%s'",
|
||||
$item,
|
||||
$details->{context}->[0]->{attributes}->[0]->{value}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check Directors state for VPlex
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--engine>
|
||||
|
||||
Specify the engine number to be checked (1-1 or 2-1 usually)
|
||||
|
||||
=item B<--detailed>
|
||||
|
||||
Not mandatory, if used, display details about temp and voltage, otherwise only global health-state
|
||||
|
||||
=item B<--filter-name>
|
||||
|
||||
Filter some elements by name (can be a regexp)
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
123
storage/emc/vplex/restapi/mode/distribueddevices.pm
Normal file
123
storage/emc/vplex/restapi/mode/distribueddevices.pm
Normal file
@ -0,0 +1,123 @@
|
||||
#
|
||||
# Copyright 2015 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::emc::vplex::restapi::mode::distribueddevices;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.1';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"engine:s" => { name => 'engine' },
|
||||
"filter-name:s" => { name => 'filter_name' },
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
if (!defined($self->{option_results}->{engine})) {
|
||||
$self->{output}->add_option_msg(short_msg => "You need to specify engine number.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
my $vplex = $options{custom};
|
||||
|
||||
my $urlbase = '/vplex/distributed-storage/distributed-devices';
|
||||
|
||||
$vplex->connect();
|
||||
|
||||
my @items = $vplex->get_items(url => $urlbase);
|
||||
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => 'All Distribued storages are OK');
|
||||
|
||||
foreach my $item (@items) {
|
||||
|
||||
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
||||
$item !~ /$self->{option_results}->{filter_name}/) {
|
||||
$self->{output}->output_add(long_msg => sprintf("Skipping storage '%s'.", $item));
|
||||
next;
|
||||
}
|
||||
|
||||
my $details = $vplex->get_infos(url => $urlbase,
|
||||
item => $item);
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("Storage '%s' operational state is '%s', health-state is '%s', and service is '%s'",
|
||||
$item,
|
||||
$details->{context}->[0]->{attributes}->[9]->{value},
|
||||
$details->{context}->[0]->{attributes}->[12]->{value},
|
||||
$details->{context}->[0]->{attributes}->[19]->{value}));
|
||||
|
||||
if ($details->{context}->[0]->{attributes}->[19]->{value} ne 'running') {
|
||||
$self->{output}->output_add(severity => 'CRITICAL',
|
||||
short_msg => sprintf("Storage '%s' service is '%s'", $details->{context}->[0]->{attributes}->[19]->{value}));
|
||||
|
||||
} elsif ($details->{context}->[0]->{attributes}->[12]->{value} ne 'ok') {
|
||||
$self->{output}->output_add(severity => 'CRITICAL',
|
||||
short_msg => sprintf("Problem on '%s' [health-state='%s'][operationnal-state='%s']",
|
||||
$item,
|
||||
$details->{context}->[0]->{attributes}->[12]->{value},
|
||||
$details->{context}->[0]->{attributes}->[9]->{value}));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check Disks health for VPlex
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--engine>
|
||||
|
||||
Set engine number (usually 1-1 or 1-2)
|
||||
|
||||
=item B<--filter-name>
|
||||
|
||||
Filter by name - can be a regexp
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
119
storage/emc/vplex/restapi/mode/fans.pm
Normal file
119
storage/emc/vplex/restapi/mode/fans.pm
Normal file
@ -0,0 +1,119 @@
|
||||
#
|
||||
# Copyright 2015 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::emc::vplex::restapi::mode::fans;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.1';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"engine:s" => { name => 'engine' },
|
||||
"filter-name:s" => { name => 'filter_name' },
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
my $vplex = $options{custom};
|
||||
|
||||
my $urlbase = '/vplex/engines/engine-';
|
||||
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => 'All Fans are OK');
|
||||
|
||||
$vplex->connect();
|
||||
my @items = $vplex->get_items(url => $urlbase,
|
||||
engine => $self->{option_results}->{engine},
|
||||
obj => 'fans');
|
||||
|
||||
foreach my $item (@items) {
|
||||
|
||||
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
||||
$item !~ /$self->{option_results}->{filter_name}/) {
|
||||
$self->{output}->output_add(long_msg => sprintf("Skipping storage '%s'.", $item));
|
||||
next;
|
||||
}
|
||||
|
||||
my $details = $vplex->get_infos(url => $urlbase,
|
||||
obj => 'fans',
|
||||
engine => $self->{option_results}->{engine},
|
||||
item => $item);
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("FAN '%s' state is '%s' and speed-threshold-raised is '%s'",
|
||||
$details->{context}->[0]->{attributes}->[0]->{value},
|
||||
$details->{context}->[0]->{attributes}->[1]->{value},
|
||||
$details->{context}->[0]->{attributes}->[2]->{value}));
|
||||
|
||||
if ($details->{context}->[0]->{attributes}->[1]->{value} ne 'online') {
|
||||
$self->{output}->output_add(severity => 'CRITICAL',
|
||||
short_msg => sprintf("FAN '%s' state is '%s'",
|
||||
$details->{context}->[0]->{attributes}->[0]->{value},
|
||||
$details->{context}->[0]->{attributes}->[1]->{value}));
|
||||
} elsif ($details->{context}->[0]->{attributes}->[2]->{value} ne 'false') {
|
||||
$self->{output}->output_add(severity => 'CRITICAL',
|
||||
short_msg => sprintf("FAN '%s' is over speed threshold (%s)",
|
||||
$details->{context}->[0]->{attributes}->[0]->{value},
|
||||
$details->{context}->[0]->{attributes}->[2]->{value}));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check Fan state for VPlex
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--engine>
|
||||
|
||||
Specify the engine number to be checked (1-1 or 2-1 usually)
|
||||
|
||||
=item B<--filter-name>
|
||||
|
||||
Filter by name - can be a regexp
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
121
storage/emc/vplex/restapi/mode/psus.pm
Normal file
121
storage/emc/vplex/restapi/mode/psus.pm
Normal file
@ -0,0 +1,121 @@
|
||||
# Copyright 2015 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::emc::vplex::restapi::mode::psus;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.1';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"engine:s" => { name => 'engine' },
|
||||
"filter-name:s" => { name => 'filter_name' },
|
||||
});
|
||||
|
||||
return $self;
|
||||
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
my $vplex = $options{custom};
|
||||
|
||||
my $urlbase = '/vplex/engines/engine-';
|
||||
|
||||
$vplex->connect();
|
||||
|
||||
my @items = $vplex->get_items(url => $urlbase,
|
||||
engine => $self->{option_results}->{engine},
|
||||
obj => 'power-supplies');
|
||||
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => 'All PSUs are OK');
|
||||
|
||||
foreach my $item (@items) {
|
||||
|
||||
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
||||
$item !~ /$self->{option_results}->{filter_name}/) {
|
||||
$self->{output}->output_add(long_msg => sprintf("Skipping storage '%s'.", $item));
|
||||
next;
|
||||
}
|
||||
|
||||
my $details = $vplex->get_infos(url => $urlbase,
|
||||
obj => 'power-supplies',
|
||||
engine => $self->{option_results}->{engine},
|
||||
item => $item);
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("PSU '%s' state is '%s' and temperature-threshold-exceeded is '%s'",
|
||||
$details->{context}->[0]->{attributes}->[0]->{value},
|
||||
$details->{context}->[0]->{attributes}->[2]->{value},
|
||||
$details->{context}->[0]->{attributes}->[6]->{value}));
|
||||
|
||||
|
||||
if ($details->{context}->[0]->{attributes}->[2]->{value} ne 'online') {
|
||||
$self->{output}->output_add(severity => 'CRITICAL',
|
||||
short_msg => sprintf("PSU '%s' state is '%s'",
|
||||
$details->{context}->[0]->{attributes}->[0]->{value},
|
||||
$details->{context}->[0]->{attributes}->[1]->{value}));
|
||||
} elsif ($details->{context}->[0]->{attributes}->[6]->{value} ne 'false') {
|
||||
$self->{output}->output_add(severity => 'WARNING',
|
||||
short_msg => sprintf("PSU '%s' temperature exceeds threshold ('%s')",
|
||||
$details->{context}->[0]->{attributes}->[0]->{value},
|
||||
$details->{context}->[0]->{attributes}->[2]->{value}));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check Power-supplies infos for VPlex
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--engine>
|
||||
|
||||
Specify the engine number to be checked (1-1 or 2-1 usually)
|
||||
|
||||
=item B<--filter-name>
|
||||
|
||||
Filter by name - can be a regexp
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
114
storage/emc/vplex/restapi/mode/storagevolumes.pm
Normal file
114
storage/emc/vplex/restapi/mode/storagevolumes.pm
Normal file
@ -0,0 +1,114 @@
|
||||
#
|
||||
# Copyright 2015 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::emc::vplex::restapi::mode::storagevolumes;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.1';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"cluster:s" => { name => 'cluster', default => 'cluster-1' },
|
||||
"filter-name:s" => { name => 'filter_name' },
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
my $vplex = $options{custom};
|
||||
|
||||
my $urlbase = '/vplex/clusters/'.$self->{option_results}->{cluster}.'/storage-elements/storage-volumes/';
|
||||
|
||||
$vplex->connect();
|
||||
|
||||
my @items = $vplex->get_items(url => $urlbase);
|
||||
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => 'All storage volumes are OK');
|
||||
|
||||
foreach my $item (@items) {
|
||||
|
||||
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
||||
$item !~ /$self->{option_results}->{filter_name}/) {
|
||||
$self->{output}->output_add(long_msg => sprintf("Skipping storage '%s'.", $item));
|
||||
next;
|
||||
}
|
||||
|
||||
my $details = $vplex->get_param(url => $urlbase,
|
||||
item => $item,
|
||||
param => 'health-state');
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("Device '%s' health state is '%s'",
|
||||
$item,
|
||||
$details->{context}->[0]->{attributes}->[0]->{value}
|
||||
));
|
||||
|
||||
if ($details->{context}->[0]->{attributes}->[0]->{value} ne 'ok') {
|
||||
$self->{output}->output_add(severity => 'CRITICAL',
|
||||
short_msg => sprintf("Storage '%s' service is '%s'",
|
||||
$item,
|
||||
$details->{context}->[0]->{attributes}->[0]->{value}
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check Cluster devices health for VPlex
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--cluster>
|
||||
|
||||
Set cluster name to check (cluster-1 and cluster-2)
|
||||
|
||||
=item B<--filter-name>
|
||||
|
||||
Filter some elements by name (can be a regexp)
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
60
storage/emc/vplex/restapi/plugin.pm
Normal file
60
storage/emc/vplex/restapi/plugin.pm
Normal file
@ -0,0 +1,60 @@
|
||||
#
|
||||
# Copyright 2015 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::emc::vplex::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;
|
||||
# $options->{options} = options object
|
||||
|
||||
$self->{version} = '1.0';
|
||||
%{$self->{modes}} = (
|
||||
'psus' => 'storage::emc::vplex::restapi::mode::psus',
|
||||
'fans' => 'storage::emc::vplex::restapi::mode::fans',
|
||||
'distribued-devices' => 'storage::emc::vplex::restapi::mode::distribueddevices',
|
||||
'cluster-devices' => 'storage::emc::vplex::restapi::mode::clusterdevices',
|
||||
'storage-volumes' => 'storage::emc::vplex::restapi::mode::storagevolumes',
|
||||
'directors' => 'storage::emc::vplex::restapi::mode::directors',
|
||||
'cluster-communication' => 'storage::emc::vplex::restapi::mode::clustercommunication',
|
||||
);
|
||||
|
||||
$self->{custom_modes}{vplexapi} = 'storage::emc::vplex::restapi::custom::vplexapi';
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub init {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->SUPER::init(%options);
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 PLUGIN DESCRIPTION
|
||||
|
||||
Check EMC Vplex through HTTP/REST API.
|
Loading…
x
Reference in New Issue
Block a user