+ add new replication mode for EMX Unity
This commit is contained in:
parent
76effa7f14
commit
e447bb7a80
|
@ -40,4 +40,16 @@ $health_status = {
|
|||
30 => 'non_recoverable'
|
||||
};
|
||||
|
||||
$replication_status = {
|
||||
0 => 'manual_syncing',
|
||||
1 => 'auto_syncing',
|
||||
2 => 'idle',
|
||||
100 => 'unknown',
|
||||
101 => 'out_of_sync',
|
||||
102 => 'in_sync',
|
||||
103 => 'consistent',
|
||||
104 => 'syncing',
|
||||
105 => 'inconsistent'
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
@ -0,0 +1,111 @@
|
|||
#
|
||||
# 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::emc::unisphere::restapi::mode::listreplications;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use storage::emc::unisphere::restapi::mode::components::resources qw($health_status $replication_status);
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'filter-name:s' => { name => 'filter_name' },
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return $options{custom}->request_api(url_path => '/api/types/replicationSession/instances?fields=name,health,syncState');
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $replications = $self->manage_selection(%options);
|
||||
foreach (@{$replications->{entries}}) {
|
||||
next if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne ''
|
||||
&& $_->{content}->{name} !~ /$self->{option_results}->{filter_name}/);
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf(
|
||||
'[name = %s][health_status = %s][sync_status = %s]',
|
||||
$_->{content}->{name},
|
||||
$health_status->{ $_->{content}->{health}->{value} },
|
||||
$replication_status->{ $_->{content}->{syncState} },
|
||||
));
|
||||
}
|
||||
|
||||
$self->{output}->output_add(
|
||||
severity => 'OK',
|
||||
short_msg => 'List replications:'
|
||||
);
|
||||
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
sub disco_format {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{output}->add_disco_format(elements => ['name','health_status','sync_status']);
|
||||
}
|
||||
|
||||
sub disco_show {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $replications = $self->manage_selection(%options);
|
||||
foreach (@{$replications->{entries}}) {
|
||||
$self->{output}->add_disco_entry(
|
||||
name => $_->{content}->{name},
|
||||
health_status => $health_status->{ $_->{content}->{health}->{value} },
|
||||
repl_status => $replication_status->{ $_->{content}->{syncState} }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
List pools.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--filter-name>
|
||||
|
||||
Filter replication name (Can be a regexp).
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,182 @@
|
|||
#
|
||||
# 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::emc::unisphere::restapi::mode::replications;
|
||||
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use storage::emc::unisphere::restapi::mode::components::resources qw($replication_status $health_status);
|
||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc);
|
||||
|
||||
sub custom_health_status_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $msg = 'health status : ' . $self->{result_values}->{health_status};
|
||||
return $msg;
|
||||
}
|
||||
|
||||
sub custom_replication_status_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $msg = 'replication status : ' . $self->{result_values}->{repl_status};
|
||||
return $msg;
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'replication', type => 1, cb_prefix_output => 'prefix_replication_output', message_multiple => 'All replications are ok' },
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{replication} = [
|
||||
{ label => 'health-status', threshold => 0, set => {
|
||||
key_values => [ { name => 'health_status' }, { name => 'display' } ],
|
||||
closure_custom_calc => \&catalog_status_calc,
|
||||
closure_custom_output => $self->can('custom_health_status_output'),
|
||||
closure_custom_perfdata => sub { return 0; },
|
||||
closure_custom_threshold_check => \&catalog_status_threshold,
|
||||
}
|
||||
},
|
||||
{ label => 'replication-status', threshold => 0, set => {
|
||||
key_values => [ { name => 'repl_status' }, { name => 'display' } ],
|
||||
closure_custom_calc => \&catalog_status_calc,
|
||||
closure_custom_output => $self->can('custom_replication_status_output'),
|
||||
closure_custom_perfdata => sub { return 0; },
|
||||
closure_custom_threshold_check => \&catalog_status_threshold,
|
||||
}
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'filter-name:s' => { name => 'filter_name' },
|
||||
'unknown-health-status:s' => { name => 'unknown_health_status', default => '%{health_status} =~ /unknown/i' },
|
||||
'warning-health-status:s' => { name => 'warning_health_status', default => '%{health_status} =~ /ok_but|degraded|minor/i' },
|
||||
'critical-health-status:s' => { name => 'critical_health_status', default => '%{health_status} =~ /major|critical|non_recoverable/i' },
|
||||
'unknown-replication-status:s' => { name => 'unknown_repl_status', default => '%{repl_status} =~ /unknown/i' },
|
||||
'warning-replication-status:s' => { name => 'warning_repl_status', default => '%{repl_status} =~ /syncing/i' },
|
||||
'critical-replication-status:s' => { name => 'critical_repl_status', default => '%{repl_status} =~ /inconsistent/i' },
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
$self->change_macros(macros => [
|
||||
'warning_health_status', 'critical_health_status', 'unknown_health_status',
|
||||
'warning_repl_status', 'critical_repl_status', 'unknown_repl_status',
|
||||
]);
|
||||
}
|
||||
|
||||
sub prefix_replication_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Replication '" . $options{instance_value}->{display} . "' ";
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $results = $options{custom}->request_api(url_path => '/api/types/replicationSession/instances?fields=name,health,syncState');
|
||||
|
||||
$self->{replication} = {};
|
||||
foreach (@{$results->{entries}}) {
|
||||
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
||||
$_->{content}->{name} !~ /$self->{option_results}->{filter_name}/) {
|
||||
$self->{output}->output_add(long_msg => "skipping replication '" . $_->{content}->{name} . "': no matching filter.", debug => 1);
|
||||
next;
|
||||
}
|
||||
|
||||
$self->{replication}->{$_->{content}->{id}} = {
|
||||
display => $_->{content}->{name},
|
||||
health_status => $health_status->{ $_->{content}->{health}->{value} },
|
||||
repl_status => $replication_status->{ $_->{content}->{syncState} } },
|
||||
};
|
||||
}
|
||||
|
||||
if (scalar(keys %{$self->{replication}}) <= 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "No replications found");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check replication status.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--filter-counters>
|
||||
|
||||
Only display some counters (regexp can be used).
|
||||
Example: --filter-counters='^health'
|
||||
|
||||
=item B<--filter-name>
|
||||
|
||||
Filter replication name (can be a regexp).
|
||||
|
||||
=item B<--unknown-health-status>
|
||||
|
||||
Set warning threshold for status (Default: '%{health_status} =~ /unknown/i').
|
||||
Can used special variables like: %{health_status}, %{display}
|
||||
|
||||
=item B<--warning-health-status>
|
||||
|
||||
Set warning threshold for status (Default: '%{health_status} =~ /ok_but|degraded|minor/i').
|
||||
Can used special variables like: %{health_status}, %{display}
|
||||
|
||||
=item B<--critical-health-status>
|
||||
|
||||
Set critical threshold for status (Default: '%{health_status} =~ /major|critical|non_recoverable/i').
|
||||
Can used special variables like: %{health_status}, %{display}
|
||||
|
||||
=item B<--unknown-repl-status>
|
||||
|
||||
Set warning threshold for status (Default: '%{repl_status} =~ /unknown/i').
|
||||
Can used special variables like: %{repl_status}, %{display}
|
||||
|
||||
=item B<--warning-repl-status>
|
||||
|
||||
Set warning threshold for status (Default: '%{repl_status} =~ /syncing/i').
|
||||
Can used special variables like: %{repl_status}, %{display}
|
||||
|
||||
=item B<--critical-repl-status>
|
||||
|
||||
Set critical threshold for status (Default: '%{repl_status} =~ /inconsistent/i').
|
||||
Can used special variables like: %{repl_status}, %{display}
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -33,8 +33,10 @@ sub new {
|
|||
%{ $self->{modes} } = (
|
||||
'hardware' => 'storage::emc::unisphere::restapi::mode::hardware',
|
||||
'list-pools' => 'storage::emc::unisphere::restapi::mode::listpools',
|
||||
'list-replications' => 'storage::emc::unisphere::restapi::mode::listreplications',
|
||||
'list-storage-resources' => 'storage::emc::unisphere::restapi::mode::liststorageresources',
|
||||
'pools' => 'storage::emc::unisphere::restapi::mode::pools',
|
||||
'replications' => 'storage::emc::unisphere::restapi::mode::replications',
|
||||
'storage-resources' => 'storage::emc::unisphere::restapi::mode::storageresources',
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in New Issue