(plugin) storage::hp::storeonce::restapi - renamed to storage::hp::storeonce::3::restapi + metrics v2 (#3679)
This commit is contained in:
parent
0ff34da9e5
commit
113f11424c
|
@ -18,7 +18,7 @@
|
|||
# limitations under the License.
|
||||
#
|
||||
|
||||
package storage::hp::storeonce::restapi::custom::api;
|
||||
package storage::hp::storeonce::3::restapi::custom::api;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
@ -41,10 +41,10 @@ sub new {
|
|||
|
||||
if (!defined($options{noptions})) {
|
||||
$options{options}->add_options(arguments => {
|
||||
'hostname:s@' => { name => 'hostname' },
|
||||
'username:s@' => { name => 'username' },
|
||||
'password:s@' => { name => 'password' },
|
||||
'timeout:s@' => { name => 'timeout' }
|
||||
'hostname:s' => { name => 'hostname' },
|
||||
'username:s' => { name => 'username' },
|
||||
'password:s' => { name => 'password' },
|
||||
'timeout:s' => { name => 'timeout' }
|
||||
});
|
||||
}
|
||||
$options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1);
|
||||
|
@ -66,21 +66,17 @@ sub set_defaults {}
|
|||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{hostname} = (defined($self->{option_results}->{hostname})) ? shift(@{$self->{option_results}->{hostname}}) : undef;
|
||||
$self->{username} = (defined($self->{option_results}->{username})) ? shift(@{$self->{option_results}->{username}}) : '';
|
||||
$self->{password} = (defined($self->{option_results}->{password})) ? shift(@{$self->{option_results}->{password}}) : '';
|
||||
$self->{timeout} = (defined($self->{option_results}->{timeout})) ? shift(@{$self->{option_results}->{timeout}}) : 10;
|
||||
$self->{hostname} = (defined($self->{option_results}->{hostname})) ? $self->{option_results}->{hostname} : '';
|
||||
$self->{username} = (defined($self->{option_results}->{username})) ? $self->{option_results}->{username} : '';
|
||||
$self->{password} = (defined($self->{option_results}->{password})) ? $self->{option_results}->{password} : '';
|
||||
$self->{timeout} = (defined($self->{option_results}->{timeout})) ? $self->{option_results}->{timeout} : 10;
|
||||
|
||||
if (!defined($self->{hostname})) {
|
||||
if ($self->{hostname} eq '') {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify hostname option.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
if (!defined($self->{hostname}) ||
|
||||
scalar(@{$self->{option_results}->{hostname}}) == 0) {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub build_options_for_httplib {
|
||||
|
@ -108,8 +104,11 @@ sub get {
|
|||
my ($self, %options) = @_;
|
||||
|
||||
$self->settings();
|
||||
my $response = $self->{http}->request(url_path => '/storeonceservices' . $options{path},
|
||||
critical_status => '', warning_status => '');
|
||||
my $response = $self->{http}->request(
|
||||
url_path => '/storeonceservices' . $options{path},
|
||||
critical_status => '',
|
||||
warning_status => ''
|
||||
);
|
||||
|
||||
my $content;
|
||||
eval {
|
||||
|
@ -119,7 +118,7 @@ sub get {
|
|||
$self->{output}->add_option_msg(short_msg => "Cannot decode xml response: $@");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
|
@ -18,28 +18,27 @@
|
|||
# limitations under the License.
|
||||
#
|
||||
|
||||
package storage::hp::storeonce::restapi::mode::clusterusage;
|
||||
package storage::hp::storeonce::3::restapi::mode::clusterusage;
|
||||
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
|
||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
|
||||
|
||||
sub custom_status_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $msg = 'status : ' . $self->{result_values}->{health};
|
||||
return $msg;
|
||||
return 'status: ' . $self->{result_values}->{health};
|
||||
}
|
||||
|
||||
sub custom_usage_perfdata {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $label = 'used';
|
||||
my $nlabel = 'cluster.space.usage.bytes';
|
||||
my $value_perf = $self->{result_values}->{used};
|
||||
if (defined($self->{instance_mode}->{option_results}->{free})) {
|
||||
$label = 'free';
|
||||
$nlabel = 'cluster.space.free.bytes';
|
||||
$value_perf = $self->{result_values}->{free};
|
||||
}
|
||||
|
||||
|
@ -50,8 +49,9 @@ sub custom_usage_perfdata {
|
|||
}
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
label => $label, unit => 'B',
|
||||
instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef,
|
||||
nlabel => $nlabel,
|
||||
unit => 'B',
|
||||
instances => $self->{result_values}->{display},
|
||||
value => $value_perf,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}, %total_options),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}, %total_options),
|
||||
|
@ -69,7 +69,13 @@ sub custom_usage_threshold {
|
|||
$threshold_value = $self->{result_values}->{prct_used};
|
||||
$threshold_value = $self->{result_values}->{prct_free} if (defined($self->{instance_mode}->{option_results}->{free}));
|
||||
}
|
||||
$exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => [ { label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' }, { label => 'warning-'. $self->{thlabel}, exit_litteral => 'warning' } ]);
|
||||
$exit = $self->{perfdata}->threshold_check(
|
||||
value => $threshold_value,
|
||||
threshold => [
|
||||
{ label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' },
|
||||
{ label => 'warning-'. $self->{thlabel}, exit_litteral => 'warning' }
|
||||
]
|
||||
);
|
||||
return $exit;
|
||||
}
|
||||
|
||||
|
@ -79,11 +85,12 @@ sub custom_usage_output {
|
|||
my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total});
|
||||
my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used});
|
||||
my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free});
|
||||
my $msg = sprintf("Usage Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)",
|
||||
$total_size_value . " " . $total_size_unit,
|
||||
$total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used},
|
||||
$total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free});
|
||||
return $msg;
|
||||
return sprintf(
|
||||
"Usage Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)",
|
||||
$total_size_value . " " . $total_size_unit,
|
||||
$total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used},
|
||||
$total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free}
|
||||
);
|
||||
}
|
||||
|
||||
sub custom_usage_calc {
|
||||
|
@ -99,6 +106,12 @@ sub custom_usage_calc {
|
|||
return 0;
|
||||
}
|
||||
|
||||
sub prefix_cluster_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Cluster '" . $options{instance_value}->{display} . "' ";
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
@ -107,11 +120,16 @@ sub set_counters {
|
|||
];
|
||||
|
||||
$self->{maps_counters}->{cluster} = [
|
||||
{ label => 'status', threshold => 0, set => {
|
||||
{
|
||||
label => 'status',
|
||||
type => 2,
|
||||
warning_default => '%{health} =~ /warning/',
|
||||
critical_default => '%{health} =~ /critical/',
|
||||
set => {
|
||||
key_values => [ { name => 'health' }, { name => 'display' } ],
|
||||
closure_custom_output => $self->can('custom_status_output'),
|
||||
closure_custom_perfdata => sub { return 0; },
|
||||
closure_custom_threshold_check => \&catalog_status_threshold
|
||||
closure_custom_threshold_check => \&catalog_status_threshold_ng
|
||||
}
|
||||
},
|
||||
{ label => 'usage', set => {
|
||||
|
@ -119,61 +137,45 @@ sub set_counters {
|
|||
closure_custom_calc => $self->can('custom_usage_calc'),
|
||||
closure_custom_output => $self->can('custom_usage_output'),
|
||||
closure_custom_perfdata => $self->can('custom_usage_perfdata'),
|
||||
closure_custom_threshold_check => $self->can('custom_usage_threshold'),
|
||||
closure_custom_threshold_check => $self->can('custom_usage_threshold')
|
||||
}
|
||||
},
|
||||
{ label => 'dedup', set => {
|
||||
{ label => 'dedup', nlabel => 'cluster.deduplication.ratio.count', set => {
|
||||
key_values => [ { name => 'dedup' }, { name => 'display' } ],
|
||||
output_template => 'Dedup Ratio : %.2f',
|
||||
output_template => 'Dedup Ratio: %.2f',
|
||||
perfdatas => [
|
||||
{ label => 'dedup_ratio', value => 'dedup', template => '%.2f',
|
||||
min => 0, label_extra_instance => 1, instance_use => 'display' },
|
||||
],
|
||||
{ template => '%.2f', min => 0, label_extra_instance => 1, instance_use => 'display' }
|
||||
]
|
||||
}
|
||||
},
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %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' },
|
||||
"warning-status:s" => { name => 'warning_status', default => '%{health} =~ /warning/' },
|
||||
"critical-status:s" => { name => 'critical_status', default => '%{health} =~ /critical/' },
|
||||
"units:s" => { name => 'units', default => '%' },
|
||||
"free" => { name => 'free' },
|
||||
'filter-name:s' => { name => 'filter_name' },
|
||||
'units:s' => { name => 'units', default => '%' },
|
||||
'free' => { name => 'free' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
$self->change_macros(macros => ['warning_status', 'critical_status']);
|
||||
}
|
||||
|
||||
sub prefix_cluster_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Cluster '" . $options{instance_value}->{display} . "' ";
|
||||
}
|
||||
|
||||
my %mapping_health_level = (
|
||||
0 => 'unknown',
|
||||
1 => 'ok',
|
||||
2 => 'information',
|
||||
3 => 'warning',
|
||||
4 => 'critical',
|
||||
4 => 'critical'
|
||||
);
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
||||
$self->{cluster} = {};
|
||||
my $result = $options{custom}->get(path => '/cluster', ForceArray => ['cluster']);
|
||||
if (defined($result->{cluster})) {
|
||||
|
@ -196,7 +198,7 @@ sub manage_selection {
|
|||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (scalar(keys %{$self->{cluster}}) <= 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "No cluster found.");
|
||||
$self->{output}->option_exit();
|
|
@ -18,86 +18,18 @@
|
|||
# limitations under the License.
|
||||
#
|
||||
|
||||
package storage::hp::storeonce::restapi::mode::fcsusage;
|
||||
package storage::hp::storeonce::3::restapi::mode::fcsusage;
|
||||
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
|
||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
|
||||
|
||||
sub custom_status_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $msg = 'status : ' . $self->{result_values}->{health};
|
||||
return $msg;
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'fcs', type => 1, cb_prefix_output => 'prefix_fcs_output', message_multiple => 'All federated catalyst stores are ok' }
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{fcs} = [
|
||||
{ label => 'status', threshold => 0, set => {
|
||||
key_values => [ { name => 'is_online' }, { name => 'health' }, { name => 'display' } ],
|
||||
closure_custom_output => $self->can('custom_status_output'),
|
||||
closure_custom_perfdata => sub { return 0; },
|
||||
closure_custom_threshold_check => \&catalog_status_threshold,
|
||||
}
|
||||
},
|
||||
{ label => 'usage', set => {
|
||||
key_values => [ { name => 'used' }, { name => 'display' } ],
|
||||
output_template => 'Used : %s %s',
|
||||
output_change_bytes => 1,
|
||||
perfdatas => [
|
||||
{ label => 'used', value => 'used', template => '%s',
|
||||
unit => 'B', min => 0, label_extra_instance => 1, instance_use => 'display' },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'dedup', set => {
|
||||
key_values => [ { name => 'dedup' }, { name => 'display' } ],
|
||||
output_template => 'Dedup Ratio : %.2f',
|
||||
perfdatas => [
|
||||
{ label => 'dedup_ratio', value => 'dedup', template => '%.2f',
|
||||
min => 0, label_extra_instance => 1, instance_use => 'display' },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'items', set => {
|
||||
key_values => [ { name => 'num_items' }, { name => 'display' } ],
|
||||
output_template => 'Num Items : %s',
|
||||
perfdatas => [
|
||||
{ label => 'items', value => 'num_items', template => '%s',
|
||||
min => 0, label_extra_instance => 1, instance_use => 'display' },
|
||||
],
|
||||
}
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
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' },
|
||||
"warning-status:s" => { name => 'warning_status', default => '%{is_online} == 1 and %{health} =~ /warning/i' },
|
||||
"critical-status:s" => { name => 'critical_status', default => '%{is_online} == 1 and %{health} =~ /critical/i' },
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
$self->change_macros(macros => ['warning_status', 'critical_status']);
|
||||
return 'status: ' . $self->{result_values}->{health};
|
||||
}
|
||||
|
||||
sub prefix_fcs_output {
|
||||
|
@ -106,14 +38,64 @@ sub prefix_fcs_output {
|
|||
return "Federated catalyst store '" . $options{instance_value}->{display} . "' ";
|
||||
}
|
||||
|
||||
sub change_macros {
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
foreach (()) {
|
||||
if (defined($self->{option_results}->{$_})) {
|
||||
$self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g;
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'fcs', type => 1, cb_prefix_output => 'prefix_fcs_output', message_multiple => 'All federated catalyst stores are ok' }
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{fcs} = [
|
||||
{
|
||||
label => 'status',
|
||||
type => 2,
|
||||
warning_default => '%{is_online} == 1 and %{health} =~ /warning/i',
|
||||
critical_default => '%{is_online} == 1 and %{health} =~ /critical/i',
|
||||
set => {
|
||||
key_values => [ { name => 'is_online' }, { name => 'health' }, { name => 'display' } ],
|
||||
closure_custom_output => $self->can('custom_status_output'),
|
||||
closure_custom_perfdata => sub { return 0; },
|
||||
closure_custom_threshold_check => \&catalog_status_threshold_ng
|
||||
}
|
||||
},
|
||||
{ label => 'usage', nlabel => 'fcs.space.usage.bytes', set => {
|
||||
key_values => [ { name => 'used' }, { name => 'display' } ],
|
||||
output_template => 'Used: %s %s',
|
||||
output_change_bytes => 1,
|
||||
perfdatas => [
|
||||
{ template => '%s', unit => 'B', min => 0, label_extra_instance => 1, instance_use => 'display' }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'dedup', nlabel => 'fcs.deduplication.ratio.count', set => {
|
||||
key_values => [ { name => 'dedup' }, { name => 'display' } ],
|
||||
output_template => 'Dedup Ratio: %.2f',
|
||||
perfdatas => [
|
||||
{ template => '%.2f', min => 0, label_extra_instance => 1, instance_use => 'display' }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'items', nlabel => 'fcs.items.count', set => {
|
||||
key_values => [ { name => 'num_items' }, { name => 'display' } ],
|
||||
output_template => 'Num Items: %s',
|
||||
perfdatas => [
|
||||
{ template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display' }
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
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' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
my %mapping_health_level = (
|
||||
|
@ -121,7 +103,7 @@ my %mapping_health_level = (
|
|||
1 => 'ok',
|
||||
2 => 'information',
|
||||
3 => 'warning',
|
||||
4 => 'critical',
|
||||
4 => 'critical'
|
||||
);
|
||||
|
||||
sub manage_selection {
|
|
@ -18,79 +18,28 @@
|
|||
# limitations under the License.
|
||||
#
|
||||
|
||||
package storage::hp::storeonce::restapi::mode::nasusage;
|
||||
package storage::hp::storeonce::3::restapi::mode::nasusage;
|
||||
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
|
||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
|
||||
|
||||
sub custom_nas_status_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $msg = sprintf('status : %s [replication health: %s]',
|
||||
$self->{result_values}->{health}, $self->{result_values}->{replication_health});
|
||||
return $msg;
|
||||
return sprintf(
|
||||
'status: %s [replication health: %s]',
|
||||
$self->{result_values}->{health},
|
||||
$self->{result_values}->{replication_health}
|
||||
);
|
||||
}
|
||||
|
||||
sub custom_share_status_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $msg = sprintf('status : %s', $self->{result_values}->{health});
|
||||
return $msg;
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'nas', type => 1, cb_prefix_output => 'prefix_nas_output', message_multiple => 'All nas are ok' },
|
||||
{ name => 'share', type => 1, cb_prefix_output => 'prefix_share_output', message_multiple => 'All shares are ok' },
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{nas} = [
|
||||
{ label => 'nas-status', threshold => 0, set => {
|
||||
key_values => [ { name => 'replication_health' }, { name => 'health' }, { name => 'display' } ],
|
||||
closure_custom_output => $self->can('custom_nas_status_output'),
|
||||
closure_custom_perfdata => sub { return 0; },
|
||||
closure_custom_threshold_check => \&catalog_status_threshold,
|
||||
}
|
||||
},
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{share} = [
|
||||
{ label => 'share-status', threshold => 0, set => {
|
||||
key_values => [ { name => 'health' }, { name => 'display' } ],
|
||||
closure_custom_output => $self->can('custom_share_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);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
"filter-name:s" => { name => 'filter_name' },
|
||||
"warning-nas-status:s" => { name => 'warning_nas_status', default => '%{health} =~ /warning/i' },
|
||||
"critical-nas-status:s" => { name => 'critical_nas_status', default => '%{health} =~ /critical/i' },
|
||||
"warning-share-status:s" => { name => 'warning_share_status', default => '%{health} =~ /warning/i' },
|
||||
"critical-share-status:s" => { name => 'critical_share_status', default => '%{health} =~ /critical/i' },
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
$self->change_macros(macros => ['warning_nas_status', 'critical_nas_status', 'warning_share_status', 'critical_share_status']);
|
||||
return sprintf('status: %s', $self->{result_values}->{health});
|
||||
}
|
||||
|
||||
sub prefix_nas_output {
|
||||
|
@ -105,6 +54,58 @@ sub prefix_share_output {
|
|||
return "Share '" . $options{instance_value}->{display} . "' ";
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'nas', type => 1, cb_prefix_output => 'prefix_nas_output', message_multiple => 'All nas are ok' },
|
||||
{ name => 'share', type => 1, cb_prefix_output => 'prefix_share_output', message_multiple => 'All shares are ok' }
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{nas} = [
|
||||
{
|
||||
label => 'nas-status',
|
||||
type => 2,
|
||||
warning_default => '%{health} =~ /warning/i',
|
||||
critical_default => '%{health} =~ /critical/i',
|
||||
set => {
|
||||
key_values => [ { name => 'replication_health' }, { name => 'health' }, { name => 'display' } ],
|
||||
closure_custom_output => $self->can('custom_nas_status_output'),
|
||||
closure_custom_perfdata => sub { return 0; },
|
||||
closure_custom_threshold_check => \&catalog_status_threshold_ng
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{share} = [
|
||||
{
|
||||
label => 'share-status',
|
||||
type => 2,
|
||||
type => 2,
|
||||
warning_default => '%{health} =~ /warning/i',
|
||||
critical_default => '%{health} =~ /critical/i',
|
||||
set => {
|
||||
key_values => [ { name => 'health' }, { name => 'display' } ],
|
||||
closure_custom_output => $self->can('custom_share_status_output'),
|
||||
closure_custom_perfdata => sub { return 0; },
|
||||
closure_custom_threshold_check => \&catalog_status_threshold_ng
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
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' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
my %mapping_health_level = (
|
||||
0 => 'unknown',
|
||||
1 => 'ok',
|
||||
|
@ -115,7 +116,7 @@ my %mapping_health_level = (
|
|||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
||||
$self->{nas} = {};
|
||||
$self->{share} = {};
|
||||
my $result = $options{custom}->get(path => '/cluster/servicesets/*all*/services/nas', ForceArray => ['service', 'item']);
|
||||
|
@ -126,13 +127,13 @@ sub manage_selection {
|
|||
$self->{output}->output_add(long_msg => "skipping '" . $entry->{properties}->{ssid} . "': no matching filter.", debug => 1);
|
||||
next;
|
||||
}
|
||||
|
||||
|
||||
$self->{nas}->{$entry->{properties}->{ssid}} = {
|
||||
display => $entry->{properties}->{ssid},
|
||||
health => $mapping_health_level{$entry->{properties}->{nasHealthLevel}},
|
||||
replication_health => $mapping_health_level{$entry->{properties}->{repHealthLevel}},
|
||||
};
|
||||
|
||||
|
||||
foreach my $item (@{$entry->{shares}->{item}}) {
|
||||
$self->{share}->{$entry->{properties}->{ssid} . '.' . $item->{id}} = {
|
||||
display => $entry->{properties}->{ssid} . '.' . $item->{id},
|
||||
|
@ -141,7 +142,7 @@ sub manage_selection {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (scalar(keys %{$self->{nas}}) <= 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "No nas found.");
|
||||
$self->{output}->option_exit();
|
|
@ -18,29 +18,30 @@
|
|||
# limitations under the License.
|
||||
#
|
||||
|
||||
package storage::hp::storeonce::restapi::mode::servicesetusage;
|
||||
package storage::hp::storeonce::3::restapi::mode::servicesetusage;
|
||||
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
|
||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
|
||||
|
||||
sub custom_status_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $msg = sprintf('status : %s [replication health: %s] [housekeeping health: %s]',
|
||||
$self->{result_values}->{health}, $self->{result_values}->{replication_health}, $self->{result_values}->{housekeeping_health});
|
||||
return $msg;
|
||||
return sprintf(
|
||||
'status: %s [replication health: %s] [housekeeping health: %s]',
|
||||
$self->{result_values}->{health}, $self->{result_values}->{replication_health}, $self->{result_values}->{housekeeping_health}
|
||||
);
|
||||
}
|
||||
|
||||
sub custom_usage_perfdata {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $label = 'used';
|
||||
|
||||
my $nlabel = 'serviceset.space.usage.bytes';
|
||||
my $value_perf = $self->{result_values}->{used};
|
||||
if (defined($self->{instance_mode}->{option_results}->{free})) {
|
||||
$label = 'free';
|
||||
$nlabel = 'serviceset.space.free.bytes';
|
||||
$value_perf = $self->{result_values}->{free};
|
||||
}
|
||||
|
||||
|
@ -51,8 +52,9 @@ sub custom_usage_perfdata {
|
|||
}
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
label => $label, unit => 'B',
|
||||
instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef,
|
||||
nlabel => $nlabel,
|
||||
unit => 'B',
|
||||
instances => $self->{result_values}->{display},
|
||||
value => $value_perf,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}, %total_options),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}, %total_options),
|
||||
|
@ -80,11 +82,12 @@ sub custom_usage_output {
|
|||
my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total});
|
||||
my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used});
|
||||
my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free});
|
||||
my $msg = sprintf("Usage Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)",
|
||||
$total_size_value . " " . $total_size_unit,
|
||||
$total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used},
|
||||
$total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free});
|
||||
return $msg;
|
||||
return sprintf(
|
||||
"Usage Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)",
|
||||
$total_size_value . " " . $total_size_unit,
|
||||
$total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used},
|
||||
$total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free}
|
||||
);
|
||||
}
|
||||
|
||||
sub custom_usage_calc {
|
||||
|
@ -96,23 +99,34 @@ sub custom_usage_calc {
|
|||
$self->{result_values}->{free} = $self->{result_values}->{total} - $self->{result_values}->{used};
|
||||
$self->{result_values}->{prct_used} = $self->{result_values}->{used} * 100 / $self->{result_values}->{total};
|
||||
$self->{result_values}->{prct_free} = 100 - $self->{result_values}->{prct_used};
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub prefix_scs_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Service set '" . $options{instance_value}->{display} . "' ";
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'scs', type => 1, cb_prefix_output => 'prefix_scs_output', message_multiple => 'All service sets are ok' }
|
||||
];
|
||||
|
||||
|
||||
$self->{maps_counters}->{scs} = [
|
||||
{ label => 'status', threshold => 0, set => {
|
||||
{
|
||||
label => 'status',
|
||||
type => 2,
|
||||
warning_default => '%{health} =~ /warning/i',
|
||||
critical_default => '%{health} =~ /critical/i',
|
||||
set => {
|
||||
key_values => [ { name => 'health' }, { name => 'replication_health' }, { name => 'housekeeping_health' }, { name => 'display' } ],
|
||||
closure_custom_output => $self->can('custom_status_output'),
|
||||
closure_custom_perfdata => sub { return 0; },
|
||||
closure_custom_threshold_check => \&catalog_status_threshold,
|
||||
closure_custom_threshold_check => \&catalog_status_threshold_ng
|
||||
}
|
||||
},
|
||||
{ label => 'usage', set => {
|
||||
|
@ -120,25 +134,23 @@ sub set_counters {
|
|||
closure_custom_calc => $self->can('custom_usage_calc'),
|
||||
closure_custom_output => $self->can('custom_usage_output'),
|
||||
closure_custom_perfdata => $self->can('custom_usage_perfdata'),
|
||||
closure_custom_threshold_check => $self->can('custom_usage_threshold'),
|
||||
closure_custom_threshold_check => $self->can('custom_usage_threshold')
|
||||
}
|
||||
},
|
||||
{ label => 'dedup', set => {
|
||||
{ label => 'dedup', nlabel => 'serviceset.deduplication.ratio.count', set => {
|
||||
key_values => [ { name => 'dedup' }, { name => 'display' } ],
|
||||
output_template => 'Dedup Ratio : %.2f',
|
||||
output_template => 'Dedup Ratio: %.2f',
|
||||
perfdatas => [
|
||||
{ label => 'dedup_ratio', value => 'dedup', template => '%.2f',
|
||||
min => 0, label_extra_instance => 1, instance_use => 'display' },
|
||||
],
|
||||
{ template => '%.2f', min => 0, label_extra_instance => 1, instance_use => 'display' }
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
|
@ -146,36 +158,23 @@ sub new {
|
|||
"warning-status:s" => { name => 'warning_status', default => '%{health} =~ /warning/' },
|
||||
"critical-status:s" => { name => 'critical_status', default => '%{health} =~ /critical/' },
|
||||
"units:s" => { name => 'units', default => '%' },
|
||||
"free" => { name => 'free' },
|
||||
"free" => { name => 'free' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
$self->change_macros(macros => ['warning_status', 'critical_status']);
|
||||
}
|
||||
|
||||
sub prefix_scs_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Service set '" . $options{instance_value}->{display} . "' ";
|
||||
}
|
||||
|
||||
my %mapping_health_level = (
|
||||
0 => 'unknown',
|
||||
1 => 'ok',
|
||||
2 => 'information',
|
||||
3 => 'warning',
|
||||
4 => 'critical',
|
||||
4 => 'critical'
|
||||
);
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
||||
$self->{scs} = {};
|
||||
my $result = $options{custom}->get(path => '/cluster/servicesets', ForceArray => ['serviceset']);
|
||||
if (defined($result->{servicesets}->{serviceset})) {
|
||||
|
@ -185,8 +184,8 @@ sub manage_selection {
|
|||
$self->{output}->output_add(long_msg => "skipping '" . $entry->{properties}->{alias} . "': no matching filter.", debug => 1);
|
||||
next;
|
||||
}
|
||||
|
||||
$self->{scs}->{$entry->{properties}->{ssid}} = {
|
||||
|
||||
$self->{scs}->{ $entry->{properties}->{ssid} } = {
|
||||
display => $entry->{properties}->{alias},
|
||||
health => $mapping_health_level{$entry->{properties}->{healthLevel}},
|
||||
housekeeping_health => $mapping_health_level{$entry->{properties}->{housekeepingHealthLevel}},
|
|
@ -18,7 +18,7 @@
|
|||
# limitations under the License.
|
||||
#
|
||||
|
||||
package storage::hp::storeonce::restapi::plugin;
|
||||
package storage::hp::storeonce::3::restapi::plugin;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
@ -29,15 +29,14 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
%{$self->{modes}} = (
|
||||
'cluster-usage' => 'storage::hp::storeonce::restapi::mode::clusterusage',
|
||||
'fcs-usage' => 'storage::hp::storeonce::restapi::mode::fcsusage',
|
||||
'nas-usage' => 'storage::hp::storeonce::restapi::mode::nasusage',
|
||||
'serviceset-usage' => 'storage::hp::storeonce::restapi::mode::servicesetusage',
|
||||
);
|
||||
$self->{modes} = {
|
||||
'cluster-usage' => 'storage::hp::storeonce::3::restapi::mode::clusterusage',
|
||||
'fcs-usage' => 'storage::hp::storeonce::3::restapi::mode::fcsusage',
|
||||
'nas-usage' => 'storage::hp::storeonce::3::restapi::mode::nasusage',
|
||||
'serviceset-usage' => 'storage::hp::storeonce::3::restapi::mode::servicesetusage'
|
||||
};
|
||||
|
||||
$self->{custom_modes}{api} = 'storage::hp::storeonce::restapi::custom::api';
|
||||
$self->{custom_modes}->{api} = 'storage::hp::storeonce::3::restapi::custom::api';
|
||||
return $self;
|
||||
}
|
||||
|
||||
|
@ -47,6 +46,6 @@ __END__
|
|||
|
||||
=head1 PLUGIN DESCRIPTION
|
||||
|
||||
Check Hp Storeonce through HTTP/REST API.
|
||||
Check Hp Storeonce 3.x through HTTP/REST API.
|
||||
|
||||
=cut
|
Loading…
Reference in New Issue