parent
8e34ef8d10
commit
512685c6c7
|
@ -107,8 +107,12 @@ sub get_items {
|
|||
$self->settings();
|
||||
|
||||
if (defined($options{parent})) {
|
||||
if (defined($options{$options{parent}}) && $options{$options{parent}} ne '') {
|
||||
$options{url} .= $options{parent} . '-' . $options{engine} . '/';
|
||||
if (defined($options{parent_filter}) && $options{parent_filter} ne '') {
|
||||
if ($options{parent_filter} =~ /^[0-9\-]+$/) {
|
||||
$options{url} .= $options{parent_filter_prefix} . $options{parent_filter} . '/';
|
||||
} else {
|
||||
$options{url} .= $options{parent_filter} . '/';
|
||||
}
|
||||
} else {
|
||||
$options{url} .= '*' . '/';
|
||||
}
|
||||
|
@ -117,7 +121,7 @@ sub get_items {
|
|||
$options{url} .= $options{obj} . '/';
|
||||
}
|
||||
$options{url} .= '*';
|
||||
|
||||
|
||||
my $response = $self->{http}->request(url_path => $options{url});
|
||||
my $decoded;
|
||||
eval {
|
||||
|
@ -127,26 +131,26 @@ sub get_items {
|
|||
$self->{output}->add_option_msg(short_msg => "Cannot decode json response");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
|
||||
my $items = {};
|
||||
foreach my $context (@{$decoded->{response}->{context}}) {
|
||||
my $engine_name;
|
||||
|
||||
if (defined($options{parent})) {
|
||||
$context->{parent} =~ /\/$options{parent}-(.*?)\//;
|
||||
$engine_name = $options{parent} . '-' . $1;
|
||||
$context->{parent} =~ /$options{parent_select}/;
|
||||
$engine_name = $1;
|
||||
$items->{$engine_name} = {} if (!defined($items->{$engine_name}));
|
||||
}
|
||||
|
||||
|
||||
my $attributes = {};
|
||||
foreach my $attribute (@{$context->{attributes}}) {
|
||||
$attributes->{$attribute->{name}} = $attribute->{value};
|
||||
$attributes->{ $attribute->{name} } = $attribute->{value};
|
||||
}
|
||||
|
||||
if (defined($engine_name)) {
|
||||
$items->{$engine_name}->{$attributes->{name}} = $attributes;
|
||||
$items->{$engine_name}->{ $attributes->{name} } = $attributes;
|
||||
} else {
|
||||
$items->{$attributes->{name}} = $attributes;
|
||||
$items->{ $attributes->{name} } = $attributes;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,8 +29,8 @@ my $thresholds = {
|
|||
component_opstatus => [
|
||||
['cluster-in-contact', 'OK'],
|
||||
['in-contact', 'OK'],
|
||||
['.*', 'CRITICAL'],
|
||||
],
|
||||
['.*', 'CRITICAL']
|
||||
]
|
||||
};
|
||||
|
||||
sub new {
|
||||
|
@ -38,11 +38,10 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"filter:s@" => { name => 'filter' },
|
||||
"threshold-overload:s@" => { name => 'threshold_overload' },
|
||||
});
|
||||
$options{options}->add_options(arguments => {
|
||||
'filter:s@' => { name => 'filter' },
|
||||
'threshold-overload:s@' => { name => 'threshold_overload' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
@ -92,9 +91,8 @@ sub run {
|
|||
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => 'All Cluster Witness components are OK');
|
||||
|
||||
my $urlbase = '/vplex/cluster-witness/components/';
|
||||
my $items = $vplex->get_items(url => $urlbase);
|
||||
|
||||
my $items = $vplex->get_items(url => '/vplex/cluster-witness/components/');
|
||||
foreach my $name (sort keys %{$items}) {
|
||||
my $instance = $name;
|
||||
|
||||
|
|
|
@ -89,12 +89,15 @@ sub check_options {
|
|||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
my $vplex = $options{custom};
|
||||
|
||||
my $urlbase = '/vplex/clusters/';
|
||||
my $items = $vplex->get_items(url => $urlbase,
|
||||
parent => 'cluster',
|
||||
engine => $self->{option_results}->{cluster},
|
||||
obj => 'devices');
|
||||
|
||||
my $items = $vplex->get_items(
|
||||
url => '/vplex/clusters/',
|
||||
parent => 1,
|
||||
parent_filter => $self->{option_results}->{cluster},
|
||||
parent_filter_prefix => 'cluster-',
|
||||
parent_select => '/clusters/(.*?)/',
|
||||
obj => 'devices'
|
||||
);
|
||||
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => 'All Cluster Devices are OK');
|
||||
|
|
|
@ -104,12 +104,15 @@ sub check_options {
|
|||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
my $vplex = $options{custom};
|
||||
|
||||
my $urlbase = '/vplex/engines/';
|
||||
my $items = $vplex->get_items(url => $urlbase,
|
||||
parent => 'engine',
|
||||
engine => $self->{option_results}->{engine},
|
||||
obj => 'directors');
|
||||
|
||||
my $items = $vplex->get_items(
|
||||
url => '/vplex/engines/',
|
||||
parent => 1,
|
||||
parent_filter => $self->{option_results}->{engine},
|
||||
parent_filter_prefix => 'engine-',
|
||||
parent_select => '/engines/(.*?)/',
|
||||
obj => 'directors'
|
||||
);
|
||||
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => 'All Directors are OK');
|
||||
|
|
|
@ -99,9 +99,8 @@ sub run {
|
|||
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => 'All Distributed devices are OK');
|
||||
|
||||
my $urlbase = '/vplex/distributed-storage/distributed-devices/';
|
||||
my $items = $vplex->get_items(url => $urlbase);
|
||||
|
||||
my $items = $vplex->get_items(url => '/vplex/distributed-storage/distributed-devices/');
|
||||
foreach my $name (sort keys %{$items}) {
|
||||
my $instance = $name;
|
||||
|
||||
|
|
|
@ -94,14 +94,17 @@ sub run {
|
|||
my ($self, %options) = @_;
|
||||
my $vplex = $options{custom};
|
||||
|
||||
my $urlbase = '/vplex/engines/';
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => 'All Fans are OK');
|
||||
|
||||
my $items = $vplex->get_items(url => $urlbase,
|
||||
parent => 'engine',
|
||||
engine => $self->{option_results}->{engine},
|
||||
obj => 'fans');
|
||||
my $items = $vplex->get_items(
|
||||
url => '/vplex/engines/',
|
||||
parent => 1,
|
||||
parent_filter => $self->{option_results}->{engine},
|
||||
parent_filter_prefix => 'engine-',
|
||||
parent_select => '/engines/(.*?)/',
|
||||
obj => 'fans'
|
||||
);
|
||||
foreach my $engine_name (sort keys %{$items}) {
|
||||
foreach my $fan_name (sort keys %{$items->{$engine_name}}) {
|
||||
my $instance = $engine_name . '_' . $fan_name;
|
||||
|
|
|
@ -94,11 +94,14 @@ sub run {
|
|||
my ($self, %options) = @_;
|
||||
my $vplex = $options{custom};
|
||||
|
||||
my $urlbase = '/vplex/engines/';
|
||||
my $items = $vplex->get_items(url => $urlbase,
|
||||
parent => 'engine',
|
||||
engine => $self->{option_results}->{engine},
|
||||
obj => 'power-supplies');
|
||||
my $items = $vplex->get_items(
|
||||
url => '/vplex/engines/',
|
||||
parent => 1,
|
||||
parent_filter => $self->{option_results}->{engine},
|
||||
parent_filter_prefix => 'engine-',
|
||||
parent_select => '/engines/(.*?)/',
|
||||
obj => 'power-supplies'
|
||||
);
|
||||
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => 'All Power supplies are OK');
|
||||
|
|
|
@ -89,11 +89,12 @@ sub run {
|
|||
my ($self, %options) = @_;
|
||||
my $vplex = $options{custom};
|
||||
|
||||
my $urlbase = '/vplex/clusters/';
|
||||
my $items = $vplex->get_items(
|
||||
url => $urlbase,
|
||||
parent => 'cluster',
|
||||
engine => $self->{option_results}->{cluster},
|
||||
url => '/vplex/clusters/',
|
||||
parent => 1,
|
||||
parent_filter => $self->{option_results}->{cluster},
|
||||
parent_filter_prefix => 'cluster-',
|
||||
parent_select => '/clusters/(.*?)/',
|
||||
obj => 'storage-elements/storage-volumes'
|
||||
);
|
||||
|
||||
|
|
|
@ -30,17 +30,17 @@ sub new {
|
|||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
%{$self->{modes}} = (
|
||||
$self->{modes} = {
|
||||
'psus' => 'storage::emc::vplex::restapi::mode::psus',
|
||||
'fans' => 'storage::emc::vplex::restapi::mode::fans',
|
||||
'distributed-devices' => 'storage::emc::vplex::restapi::mode::distributeddevices',
|
||||
'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',
|
||||
);
|
||||
'cluster-communication' => 'storage::emc::vplex::restapi::mode::clustercommunication'
|
||||
};
|
||||
|
||||
$self->{custom_modes}{vplexapi} = 'storage::emc::vplex::restapi::custom::vplexapi';
|
||||
$self->{custom_modes}->{vplexapi} = 'storage::emc::vplex::restapi::custom::vplexapi';
|
||||
return $self;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue