mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-27 15:44:21 +02:00
(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.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
package storage::hp::storeonce::restapi::custom::api;
|
package storage::hp::storeonce::3::restapi::custom::api;
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
@ -41,10 +41,10 @@ sub new {
|
|||||||
|
|
||||||
if (!defined($options{noptions})) {
|
if (!defined($options{noptions})) {
|
||||||
$options{options}->add_options(arguments => {
|
$options{options}->add_options(arguments => {
|
||||||
'hostname:s@' => { name => 'hostname' },
|
'hostname:s' => { name => 'hostname' },
|
||||||
'username:s@' => { name => 'username' },
|
'username:s' => { name => 'username' },
|
||||||
'password:s@' => { name => 'password' },
|
'password:s' => { name => 'password' },
|
||||||
'timeout:s@' => { name => 'timeout' }
|
'timeout:s' => { name => 'timeout' }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
$options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1);
|
$options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1);
|
||||||
@ -66,21 +66,17 @@ sub set_defaults {}
|
|||||||
sub check_options {
|
sub check_options {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->{hostname} = (defined($self->{option_results}->{hostname})) ? shift(@{$self->{option_results}->{hostname}}) : undef;
|
$self->{hostname} = (defined($self->{option_results}->{hostname})) ? $self->{option_results}->{hostname} : '';
|
||||||
$self->{username} = (defined($self->{option_results}->{username})) ? shift(@{$self->{option_results}->{username}}) : '';
|
$self->{username} = (defined($self->{option_results}->{username})) ? $self->{option_results}->{username} : '';
|
||||||
$self->{password} = (defined($self->{option_results}->{password})) ? shift(@{$self->{option_results}->{password}}) : '';
|
$self->{password} = (defined($self->{option_results}->{password})) ? $self->{option_results}->{password} : '';
|
||||||
$self->{timeout} = (defined($self->{option_results}->{timeout})) ? shift(@{$self->{option_results}->{timeout}}) : 10;
|
$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}->add_option_msg(short_msg => "Need to specify hostname option.");
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!defined($self->{hostname}) ||
|
return 0;
|
||||||
scalar(@{$self->{option_results}->{hostname}}) == 0) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub build_options_for_httplib {
|
sub build_options_for_httplib {
|
||||||
@ -108,8 +104,11 @@ sub get {
|
|||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->settings();
|
$self->settings();
|
||||||
my $response = $self->{http}->request(url_path => '/storeonceservices' . $options{path},
|
my $response = $self->{http}->request(
|
||||||
critical_status => '', warning_status => '');
|
url_path => '/storeonceservices' . $options{path},
|
||||||
|
critical_status => '',
|
||||||
|
warning_status => ''
|
||||||
|
);
|
||||||
|
|
||||||
my $content;
|
my $content;
|
||||||
eval {
|
eval {
|
@ -18,28 +18,27 @@
|
|||||||
# limitations under the License.
|
# 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 base qw(centreon::plugins::templates::counter);
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
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 {
|
sub custom_status_output {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my $msg = 'status : ' . $self->{result_values}->{health};
|
return 'status: ' . $self->{result_values}->{health};
|
||||||
return $msg;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub custom_usage_perfdata {
|
sub custom_usage_perfdata {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my $label = 'used';
|
my $nlabel = 'cluster.space.usage.bytes';
|
||||||
my $value_perf = $self->{result_values}->{used};
|
my $value_perf = $self->{result_values}->{used};
|
||||||
if (defined($self->{instance_mode}->{option_results}->{free})) {
|
if (defined($self->{instance_mode}->{option_results}->{free})) {
|
||||||
$label = 'free';
|
$nlabel = 'cluster.space.free.bytes';
|
||||||
$value_perf = $self->{result_values}->{free};
|
$value_perf = $self->{result_values}->{free};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,8 +49,9 @@ sub custom_usage_perfdata {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$self->{output}->perfdata_add(
|
$self->{output}->perfdata_add(
|
||||||
label => $label, unit => 'B',
|
nlabel => $nlabel,
|
||||||
instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef,
|
unit => 'B',
|
||||||
|
instances => $self->{result_values}->{display},
|
||||||
value => $value_perf,
|
value => $value_perf,
|
||||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}, %total_options),
|
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),
|
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_used};
|
||||||
$threshold_value = $self->{result_values}->{prct_free} if (defined($self->{instance_mode}->{option_results}->{free}));
|
$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;
|
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_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_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 ($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%%)",
|
return sprintf(
|
||||||
$total_size_value . " " . $total_size_unit,
|
"Usage Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)",
|
||||||
$total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used},
|
$total_size_value . " " . $total_size_unit,
|
||||||
$total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free});
|
$total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used},
|
||||||
return $msg;
|
$total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub custom_usage_calc {
|
sub custom_usage_calc {
|
||||||
@ -99,6 +106,12 @@ sub custom_usage_calc {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub prefix_cluster_output {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return "Cluster '" . $options{instance_value}->{display} . "' ";
|
||||||
|
}
|
||||||
|
|
||||||
sub set_counters {
|
sub set_counters {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
@ -107,11 +120,16 @@ sub set_counters {
|
|||||||
];
|
];
|
||||||
|
|
||||||
$self->{maps_counters}->{cluster} = [
|
$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' } ],
|
key_values => [ { name => 'health' }, { name => 'display' } ],
|
||||||
closure_custom_output => $self->can('custom_status_output'),
|
closure_custom_output => $self->can('custom_status_output'),
|
||||||
closure_custom_perfdata => sub { return 0; },
|
closure_custom_perfdata => sub { return 0; },
|
||||||
closure_custom_threshold_check => \&catalog_status_threshold
|
closure_custom_threshold_check => \&catalog_status_threshold_ng
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ label => 'usage', set => {
|
{ label => 'usage', set => {
|
||||||
@ -119,56 +137,40 @@ sub set_counters {
|
|||||||
closure_custom_calc => $self->can('custom_usage_calc'),
|
closure_custom_calc => $self->can('custom_usage_calc'),
|
||||||
closure_custom_output => $self->can('custom_usage_output'),
|
closure_custom_output => $self->can('custom_usage_output'),
|
||||||
closure_custom_perfdata => $self->can('custom_usage_perfdata'),
|
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' } ],
|
key_values => [ { name => 'dedup' }, { name => 'display' } ],
|
||||||
output_template => 'Dedup Ratio : %.2f',
|
output_template => 'Dedup Ratio: %.2f',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ label => 'dedup_ratio', value => 'dedup', template => '%.2f',
|
{ template => '%.2f', min => 0, label_extra_instance => 1, instance_use => 'display' }
|
||||||
min => 0, label_extra_instance => 1, instance_use => 'display' },
|
]
|
||||||
],
|
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
my ($class, %options) = @_;
|
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;
|
bless $self, $class;
|
||||||
|
|
||||||
$options{options}->add_options(arguments => {
|
$options{options}->add_options(arguments => {
|
||||||
"filter-name:s" => { name => 'filter_name' },
|
'filter-name:s' => { name => 'filter_name' },
|
||||||
"warning-status:s" => { name => 'warning_status', default => '%{health} =~ /warning/' },
|
'units:s' => { name => 'units', default => '%' },
|
||||||
"critical-status:s" => { name => 'critical_status', default => '%{health} =~ /critical/' },
|
'free' => { name => 'free' }
|
||||||
"units:s" => { name => 'units', default => '%' },
|
|
||||||
"free" => { name => 'free' },
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return $self;
|
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 = (
|
my %mapping_health_level = (
|
||||||
0 => 'unknown',
|
0 => 'unknown',
|
||||||
1 => 'ok',
|
1 => 'ok',
|
||||||
2 => 'information',
|
2 => 'information',
|
||||||
3 => 'warning',
|
3 => 'warning',
|
||||||
4 => 'critical',
|
4 => 'critical'
|
||||||
);
|
);
|
||||||
|
|
||||||
sub manage_selection {
|
sub manage_selection {
|
@ -18,19 +18,24 @@
|
|||||||
# limitations under the License.
|
# 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 base qw(centreon::plugins::templates::counter);
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
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 {
|
sub custom_status_output {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my $msg = 'status : ' . $self->{result_values}->{health};
|
return 'status: ' . $self->{result_values}->{health};
|
||||||
return $msg;
|
}
|
||||||
|
|
||||||
|
sub prefix_fcs_output {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return "Federated catalyst store '" . $options{instance_value}->{display} . "' ";
|
||||||
}
|
}
|
||||||
|
|
||||||
sub set_counters {
|
sub set_counters {
|
||||||
@ -41,87 +46,64 @@ sub set_counters {
|
|||||||
];
|
];
|
||||||
|
|
||||||
$self->{maps_counters}->{fcs} = [
|
$self->{maps_counters}->{fcs} = [
|
||||||
{ label => 'status', threshold => 0, set => {
|
{
|
||||||
|
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' } ],
|
key_values => [ { name => 'is_online' }, { name => 'health' }, { name => 'display' } ],
|
||||||
closure_custom_output => $self->can('custom_status_output'),
|
closure_custom_output => $self->can('custom_status_output'),
|
||||||
closure_custom_perfdata => sub { return 0; },
|
closure_custom_perfdata => sub { return 0; },
|
||||||
closure_custom_threshold_check => \&catalog_status_threshold,
|
closure_custom_threshold_check => \&catalog_status_threshold_ng
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ label => 'usage', set => {
|
{ label => 'usage', nlabel => 'fcs.space.usage.bytes', set => {
|
||||||
key_values => [ { name => 'used' }, { name => 'display' } ],
|
key_values => [ { name => 'used' }, { name => 'display' } ],
|
||||||
output_template => 'Used : %s %s',
|
output_template => 'Used: %s %s',
|
||||||
output_change_bytes => 1,
|
output_change_bytes => 1,
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ label => 'used', value => 'used', template => '%s',
|
{ template => '%s', unit => 'B', min => 0, label_extra_instance => 1, instance_use => 'display' }
|
||||||
unit => 'B', min => 0, label_extra_instance => 1, instance_use => 'display' },
|
]
|
||||||
],
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ label => 'dedup', set => {
|
{ label => 'dedup', nlabel => 'fcs.deduplication.ratio.count', set => {
|
||||||
key_values => [ { name => 'dedup' }, { name => 'display' } ],
|
key_values => [ { name => 'dedup' }, { name => 'display' } ],
|
||||||
output_template => 'Dedup Ratio : %.2f',
|
output_template => 'Dedup Ratio: %.2f',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ label => 'dedup_ratio', value => 'dedup', template => '%.2f',
|
{ template => '%.2f', min => 0, label_extra_instance => 1, instance_use => 'display' }
|
||||||
min => 0, label_extra_instance => 1, instance_use => 'display' },
|
]
|
||||||
],
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ label => 'items', set => {
|
{ label => 'items', nlabel => 'fcs.items.count', set => {
|
||||||
key_values => [ { name => 'num_items' }, { name => 'display' } ],
|
key_values => [ { name => 'num_items' }, { name => 'display' } ],
|
||||||
output_template => 'Num Items : %s',
|
output_template => 'Num Items: %s',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ label => 'items', value => 'num_items', template => '%s',
|
{ template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display' }
|
||||||
min => 0, label_extra_instance => 1, instance_use => 'display' },
|
]
|
||||||
],
|
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
my ($class, %options) = @_;
|
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;
|
bless $self, $class;
|
||||||
|
|
||||||
$options{options}->add_options(arguments => {
|
$options{options}->add_options(arguments => {
|
||||||
"filter-name:s" => { name => 'filter_name' },
|
'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;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub check_options {
|
|
||||||
my ($self, %options) = @_;
|
|
||||||
$self->SUPER::check_options(%options);
|
|
||||||
|
|
||||||
$self->change_macros(macros => ['warning_status', 'critical_status']);
|
|
||||||
}
|
|
||||||
|
|
||||||
sub prefix_fcs_output {
|
|
||||||
my ($self, %options) = @_;
|
|
||||||
|
|
||||||
return "Federated catalyst store '" . $options{instance_value}->{display} . "' ";
|
|
||||||
}
|
|
||||||
|
|
||||||
sub change_macros {
|
|
||||||
my ($self, %options) = @_;
|
|
||||||
|
|
||||||
foreach (()) {
|
|
||||||
if (defined($self->{option_results}->{$_})) {
|
|
||||||
$self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
my %mapping_health_level = (
|
my %mapping_health_level = (
|
||||||
0 => 'unknown',
|
0 => 'unknown',
|
||||||
1 => 'ok',
|
1 => 'ok',
|
||||||
2 => 'information',
|
2 => 'information',
|
||||||
3 => 'warning',
|
3 => 'warning',
|
||||||
4 => 'critical',
|
4 => 'critical'
|
||||||
);
|
);
|
||||||
|
|
||||||
sub manage_selection {
|
sub manage_selection {
|
@ -18,79 +18,28 @@
|
|||||||
# limitations under the License.
|
# 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 base qw(centreon::plugins::templates::counter);
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
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 {
|
sub custom_nas_status_output {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my $msg = sprintf('status : %s [replication health: %s]',
|
return sprintf(
|
||||||
$self->{result_values}->{health}, $self->{result_values}->{replication_health});
|
'status: %s [replication health: %s]',
|
||||||
return $msg;
|
$self->{result_values}->{health},
|
||||||
|
$self->{result_values}->{replication_health}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub custom_share_status_output {
|
sub custom_share_status_output {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my $msg = sprintf('status : %s', $self->{result_values}->{health});
|
return 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']);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub prefix_nas_output {
|
sub prefix_nas_output {
|
||||||
@ -105,6 +54,58 @@ sub prefix_share_output {
|
|||||||
return "Share '" . $options{instance_value}->{display} . "' ";
|
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 = (
|
my %mapping_health_level = (
|
||||||
0 => 'unknown',
|
0 => 'unknown',
|
||||||
1 => 'ok',
|
1 => 'ok',
|
@ -18,29 +18,30 @@
|
|||||||
# limitations under the License.
|
# 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 base qw(centreon::plugins::templates::counter);
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
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 {
|
sub custom_status_output {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my $msg = sprintf('status : %s [replication health: %s] [housekeeping health: %s]',
|
return sprintf(
|
||||||
$self->{result_values}->{health}, $self->{result_values}->{replication_health}, $self->{result_values}->{housekeeping_health});
|
'status: %s [replication health: %s] [housekeeping health: %s]',
|
||||||
return $msg;
|
$self->{result_values}->{health}, $self->{result_values}->{replication_health}, $self->{result_values}->{housekeeping_health}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub custom_usage_perfdata {
|
sub custom_usage_perfdata {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my $label = 'used';
|
my $nlabel = 'serviceset.space.usage.bytes';
|
||||||
my $value_perf = $self->{result_values}->{used};
|
my $value_perf = $self->{result_values}->{used};
|
||||||
if (defined($self->{instance_mode}->{option_results}->{free})) {
|
if (defined($self->{instance_mode}->{option_results}->{free})) {
|
||||||
$label = 'free';
|
$nlabel = 'serviceset.space.free.bytes';
|
||||||
$value_perf = $self->{result_values}->{free};
|
$value_perf = $self->{result_values}->{free};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,8 +52,9 @@ sub custom_usage_perfdata {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$self->{output}->perfdata_add(
|
$self->{output}->perfdata_add(
|
||||||
label => $label, unit => 'B',
|
nlabel => $nlabel,
|
||||||
instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef,
|
unit => 'B',
|
||||||
|
instances => $self->{result_values}->{display},
|
||||||
value => $value_perf,
|
value => $value_perf,
|
||||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}, %total_options),
|
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),
|
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_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_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 ($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%%)",
|
return sprintf(
|
||||||
$total_size_value . " " . $total_size_unit,
|
"Usage Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)",
|
||||||
$total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used},
|
$total_size_value . " " . $total_size_unit,
|
||||||
$total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free});
|
$total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used},
|
||||||
return $msg;
|
$total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub custom_usage_calc {
|
sub custom_usage_calc {
|
||||||
@ -100,6 +103,12 @@ sub custom_usage_calc {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub prefix_scs_output {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return "Service set '" . $options{instance_value}->{display} . "' ";
|
||||||
|
}
|
||||||
|
|
||||||
sub set_counters {
|
sub set_counters {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
@ -108,11 +117,16 @@ sub set_counters {
|
|||||||
];
|
];
|
||||||
|
|
||||||
$self->{maps_counters}->{scs} = [
|
$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' } ],
|
key_values => [ { name => 'health' }, { name => 'replication_health' }, { name => 'housekeeping_health' }, { name => 'display' } ],
|
||||||
closure_custom_output => $self->can('custom_status_output'),
|
closure_custom_output => $self->can('custom_status_output'),
|
||||||
closure_custom_perfdata => sub { return 0; },
|
closure_custom_perfdata => sub { return 0; },
|
||||||
closure_custom_threshold_check => \&catalog_status_threshold,
|
closure_custom_threshold_check => \&catalog_status_threshold_ng
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ label => 'usage', set => {
|
{ label => 'usage', set => {
|
||||||
@ -120,25 +134,23 @@ sub set_counters {
|
|||||||
closure_custom_calc => $self->can('custom_usage_calc'),
|
closure_custom_calc => $self->can('custom_usage_calc'),
|
||||||
closure_custom_output => $self->can('custom_usage_output'),
|
closure_custom_output => $self->can('custom_usage_output'),
|
||||||
closure_custom_perfdata => $self->can('custom_usage_perfdata'),
|
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' } ],
|
key_values => [ { name => 'dedup' }, { name => 'display' } ],
|
||||||
output_template => 'Dedup Ratio : %.2f',
|
output_template => 'Dedup Ratio: %.2f',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ label => 'dedup_ratio', value => 'dedup', template => '%.2f',
|
{ template => '%.2f', min => 0, label_extra_instance => 1, instance_use => 'display' }
|
||||||
min => 0, label_extra_instance => 1, instance_use => 'display' },
|
]
|
||||||
],
|
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
my ($class, %options) = @_;
|
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;
|
bless $self, $class;
|
||||||
|
|
||||||
$options{options}->add_options(arguments => {
|
$options{options}->add_options(arguments => {
|
||||||
@ -146,31 +158,18 @@ sub new {
|
|||||||
"warning-status:s" => { name => 'warning_status', default => '%{health} =~ /warning/' },
|
"warning-status:s" => { name => 'warning_status', default => '%{health} =~ /warning/' },
|
||||||
"critical-status:s" => { name => 'critical_status', default => '%{health} =~ /critical/' },
|
"critical-status:s" => { name => 'critical_status', default => '%{health} =~ /critical/' },
|
||||||
"units:s" => { name => 'units', default => '%' },
|
"units:s" => { name => 'units', default => '%' },
|
||||||
"free" => { name => 'free' },
|
"free" => { name => 'free' }
|
||||||
});
|
});
|
||||||
|
|
||||||
return $self;
|
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 = (
|
my %mapping_health_level = (
|
||||||
0 => 'unknown',
|
0 => 'unknown',
|
||||||
1 => 'ok',
|
1 => 'ok',
|
||||||
2 => 'information',
|
2 => 'information',
|
||||||
3 => 'warning',
|
3 => 'warning',
|
||||||
4 => 'critical',
|
4 => 'critical'
|
||||||
);
|
);
|
||||||
|
|
||||||
sub manage_selection {
|
sub manage_selection {
|
||||||
@ -186,7 +185,7 @@ sub manage_selection {
|
|||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{scs}->{$entry->{properties}->{ssid}} = {
|
$self->{scs}->{ $entry->{properties}->{ssid} } = {
|
||||||
display => $entry->{properties}->{alias},
|
display => $entry->{properties}->{alias},
|
||||||
health => $mapping_health_level{$entry->{properties}->{healthLevel}},
|
health => $mapping_health_level{$entry->{properties}->{healthLevel}},
|
||||||
housekeeping_health => $mapping_health_level{$entry->{properties}->{housekeepingHealthLevel}},
|
housekeeping_health => $mapping_health_level{$entry->{properties}->{housekeepingHealthLevel}},
|
@ -18,7 +18,7 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
package storage::hp::storeonce::restapi::plugin;
|
package storage::hp::storeonce::3::restapi::plugin;
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
@ -29,15 +29,14 @@ sub new {
|
|||||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$self->{version} = '1.0';
|
$self->{modes} = {
|
||||||
%{$self->{modes}} = (
|
'cluster-usage' => 'storage::hp::storeonce::3::restapi::mode::clusterusage',
|
||||||
'cluster-usage' => 'storage::hp::storeonce::restapi::mode::clusterusage',
|
'fcs-usage' => 'storage::hp::storeonce::3::restapi::mode::fcsusage',
|
||||||
'fcs-usage' => 'storage::hp::storeonce::restapi::mode::fcsusage',
|
'nas-usage' => 'storage::hp::storeonce::3::restapi::mode::nasusage',
|
||||||
'nas-usage' => 'storage::hp::storeonce::restapi::mode::nasusage',
|
'serviceset-usage' => 'storage::hp::storeonce::3::restapi::mode::servicesetusage'
|
||||||
'serviceset-usage' => 'storage::hp::storeonce::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;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,6 +46,6 @@ __END__
|
|||||||
|
|
||||||
=head1 PLUGIN DESCRIPTION
|
=head1 PLUGIN DESCRIPTION
|
||||||
|
|
||||||
Check Hp Storeonce through HTTP/REST API.
|
Check Hp Storeonce 3.x through HTTP/REST API.
|
||||||
|
|
||||||
=cut
|
=cut
|
Loading…
x
Reference in New Issue
Block a user