mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-04-07 20:35:27 +02:00
(plugin) refactoring purestorage
This commit is contained in:
parent
d702df59aa
commit
6d548492a8
@ -18,12 +18,12 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
package storage::purestorage::restapi::custom::api;
|
||||
package storage::purestorage::flasharray::legacy::restapi::custom::api;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::http;
|
||||
use JSON;
|
||||
use JSON::XS;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
@ -70,25 +70,25 @@ sub set_defaults {}
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{hostname} = (defined($self->{option_results}->{hostname})) ? $self->{option_results}->{hostname} : undef;
|
||||
$self->{username} = (defined($self->{option_results}->{username})) ? $self->{option_results}->{username} : undef;
|
||||
$self->{password} = (defined($self->{option_results}->{password})) ? $self->{option_results}->{password} : undef;
|
||||
$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;
|
||||
$self->{api_path} = (defined($self->{option_results}->{api_path})) ? $self->{option_results}->{api_path} : '/api/1.11';
|
||||
$self->{unknown_http_status} = (defined($self->{option_results}->{unknown_http_status})) ? $self->{option_results}->{unknown_http_status} : '%{http_code} < 200 or %{http_code} >= 300';
|
||||
$self->{warning_http_status} = (defined($self->{option_results}->{warning_http_status})) ? $self->{option_results}->{warning_http_status} : '';
|
||||
$self->{critical_http_status} = (defined($self->{option_results}->{critical_http_status})) ? $self->{option_results}->{critical_http_status} : '';
|
||||
|
||||
if (!defined($self->{hostname})) {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify hostname option.");
|
||||
if ($self->{hostname} eq '') {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify --hostname option.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (!defined($self->{username})) {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify username option.");
|
||||
if ($self->{username} eq '') {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify --username option.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (!defined($self->{password})) {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify password option.");
|
||||
if ($self->{password} eq '') {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify --password option.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
@ -18,7 +18,7 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
package storage::purestorage::restapi::mode::alarms;
|
||||
package storage::purestorage::flasharray::legacy::restapi::mode::alarms;
|
||||
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
@ -56,11 +56,11 @@ sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'alarms', type => 2, message_multiple => '0 problem(s) detected', display_counter_problem => { label => 'alerts', min => 0 },
|
||||
{ name => 'alarms', type => 2, message_multiple => '0 problem(s) detected', display_counter_problem => { nlabel => 'alerts.detected.count', min => 0 },
|
||||
group => [ { name => 'alarm', skipped_code => { -11 => 1 } } ]
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
$self->{maps_counters}->{alarm} = [
|
||||
{
|
||||
label => 'status',
|
||||
@ -80,7 +80,7 @@ sub set_counters {
|
||||
|
||||
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 => {
|
@ -18,7 +18,7 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
package storage::purestorage::restapi::mode::arrays;
|
||||
package storage::purestorage::flasharray::legacy::restapi::mode::arrays;
|
||||
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
@ -116,7 +116,7 @@ sub manage_selection {
|
||||
$self->{output}->output_add(long_msg => "skipping '" . $entry->{hostname} . "': no matching filter.", debug => 1);
|
||||
next;
|
||||
}
|
||||
|
||||
|
||||
$self->{arrays}->{ $entry->{hostname} } = {
|
||||
display => $entry->{hostname},
|
||||
data_reduction => $entry->{data_reduction},
|
@ -18,7 +18,7 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
package storage::purestorage::restapi::mode::hardware;
|
||||
package storage::purestorage::flasharray::legacy::restapi::mode::hardware;
|
||||
|
||||
use base qw(centreon::plugins::templates::hardware);
|
||||
|
||||
@ -40,17 +40,17 @@ sub set_system {
|
||||
['device_off', 'WARNING'],
|
||||
['identifying', 'OK'],
|
||||
['not_installed', 'OK'],
|
||||
['unknown', 'UNKNOWN'],
|
||||
],
|
||||
['unknown', 'UNKNOWN']
|
||||
]
|
||||
};
|
||||
|
||||
$self->{components_path} = 'storage::purestorage::restapi::mode::components';
|
||||
$self->{components_path} = 'storage::purestorage::flasharray::legacy::restapi::mode::components';
|
||||
$self->{components_module} = ['entity'];
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1, no_load_components => 1);
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1, no_load_components => 1, force_new_perfdata => 1);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => { });
|
||||
@ -107,7 +107,7 @@ Example: --critical='temperature,.*,50'
|
||||
|
||||
=cut
|
||||
|
||||
package storage::purestorage::restapi::mode::components::entity;
|
||||
package storage::purestorage::flasharray::legacy::restapi::mode::components::entity;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
@ -132,23 +132,32 @@ sub check {
|
||||
next if ($self->check_filter(section => 'entity', instance => $instance));
|
||||
|
||||
$self->{components}->{entity}->{total}++;
|
||||
$self->{output}->output_add(long_msg => sprintf("entity '%s' status is '%s' [instance = %s]",
|
||||
$entry->{name}, $entry->{status}, $instance));
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
"entity '%s' status is '%s' [instance = %s]",
|
||||
$entry->{name}, $entry->{status}, $instance
|
||||
)
|
||||
);
|
||||
my $exit = $self->get_severity(section => 'entity', value => $entry->{status});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("entity '%s' status is '%s'", $entry->{name}, $entry->{status}));
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf("entity '%s' status is '%s'", $entry->{name}, $entry->{status})
|
||||
);
|
||||
}
|
||||
|
||||
if (defined($entry->{temperature}) && $entry->{temperature} =~ /[0-9]/) {
|
||||
my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $entry->{temperature});
|
||||
if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit2,
|
||||
short_msg => sprintf("entity '%s' temperature is %s C", $entry->{name}, $entry->{temperature}));
|
||||
$self->{output}->output_add(
|
||||
severity => $exit2,
|
||||
short_msg => sprintf("entity '%s' temperature is %s C", $entry->{name}, $entry->{temperature})
|
||||
);
|
||||
}
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
label => 'temperature', unit => 'C',
|
||||
nlabel => 'hardware.entity.temperature.celsius',
|
||||
unit => 'C',
|
||||
instances => $entry->{name},
|
||||
value => $entry->{temperature},
|
||||
warning => $warn,
|
@ -18,7 +18,7 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
package storage::purestorage::restapi::mode::listpgroups;
|
||||
package storage::purestorage::flasharray::legacy::restapi::mode::listpgroups;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
||||
@ -30,9 +30,8 @@ sub new {
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
});
|
||||
$options{options}->add_options(arguments => {});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
@ -55,8 +54,10 @@ sub run {
|
||||
$self->{output}->output_add(long_msg => "[name = '" . $_->{name} . "']");
|
||||
}
|
||||
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => 'List protection groups:');
|
||||
$self->{output}->output_add(
|
||||
severity => 'OK',
|
||||
short_msg => 'List protection groups:'
|
||||
);
|
||||
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
|
||||
$self->{output}->exit();
|
||||
}
|
||||
@ -89,4 +90,3 @@ List protection groups.
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
@ -18,7 +18,7 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
package storage::purestorage::restapi::mode::listvolumes;
|
||||
package storage::purestorage::flasharray::legacy::restapi::mode::listvolumes;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
||||
@ -55,8 +55,10 @@ sub run {
|
||||
$self->{output}->output_add(long_msg => "[name = '" . $_->{name} . "']");
|
||||
}
|
||||
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => 'List volumes:');
|
||||
$self->{output}->output_add(
|
||||
severity => 'OK',
|
||||
short_msg => 'List volumes:'
|
||||
);
|
||||
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
|
||||
$self->{output}->exit();
|
||||
}
|
||||
@ -89,4 +91,3 @@ List volumes.
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
@ -18,7 +18,7 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
package storage::purestorage::restapi::mode::pgroupreplication;
|
||||
package storage::purestorage::flasharray::legacy::restapi::mode::pgroupreplication;
|
||||
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
@ -27,6 +27,12 @@ use warnings;
|
||||
use centreon::plugins::misc;
|
||||
use DateTime;
|
||||
|
||||
sub prefix_pgroup_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Protection group '" . $options{instance_value}->{display} . "' replication ";
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
@ -35,77 +41,68 @@ sub set_counters {
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{pgroup} = [
|
||||
{ label => 'progress', set => {
|
||||
{ label => 'progress', nlabel => 'protection_group.progress.percentage', set => {
|
||||
key_values => [ { name => 'progress' }, { name => 'display' } ],
|
||||
output_template => 'Progress : %s %%',
|
||||
output_template => 'progress: %s %%',
|
||||
perfdatas => [
|
||||
{ label => 'progress', value => 'progress', template => '%s', unit => '%',
|
||||
min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' },
|
||||
],
|
||||
{ template => '%s', unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'creation', set => {
|
||||
{ label => 'creation', nlabel => 'protection_group.creation.seconds', set => {
|
||||
key_values => [ { name => 'creation_human' }, { name => 'creation_seconds' }, { name => 'display' } ],
|
||||
threshold_use => 'creation_seconds',
|
||||
output_template => 'Creation Time : %s',
|
||||
output_template => 'creation time: %s',
|
||||
perfdatas => [
|
||||
{ label => 'creation', value => 'creation_seconds', template => '%d',
|
||||
unit => 's', min => 0, label_extra_instance => 1, instance_use => 'display' },
|
||||
],
|
||||
{ value => 'creation_seconds', template => '%d',
|
||||
unit => 's', min => 0, label_extra_instance => 1, instance_use => 'display' }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'duration', set => {
|
||||
{ label => 'duration', nlabel => 'protection_group.duration.seconds', set => {
|
||||
key_values => [ { name => 'duration_human' }, { name => 'duration_seconds' }, { name => 'display' } ],
|
||||
output_template => 'duration: %s',
|
||||
threshold_use => 'duration_seconds',
|
||||
output_template => 'Duration : %s',
|
||||
perfdatas => [
|
||||
{ label => 'duration', value => 'duration_seconds', template => '%d',
|
||||
unit => 's', min => 0, label_extra_instance => 1, instance_use => 'display' },
|
||||
],
|
||||
{ value => 'duration_seconds', template => '%d',
|
||||
unit => 's', min => 0, label_extra_instance => 1, instance_use => 'display' }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'physical-bytes-written', set => {
|
||||
{ label => 'physical-bytes-written', nlabel => 'protection_group.physical.written.bytes', set => {
|
||||
key_values => [ { name => 'physical_bytes_written' }, { name => 'display' } ],
|
||||
output_template => 'Physical Bytes Written : %s %s',
|
||||
output_template => 'physical bytes written: %s %s',
|
||||
output_change_bytes => 1,
|
||||
perfdatas => [
|
||||
{ label => 'physical_bytes_written', value => 'physical_bytes_written', template => '%s',
|
||||
unit => 'B', min => 0, label_extra_instance => 1, instance_use => 'display' },
|
||||
],
|
||||
{ template => '%s', unit => 'B', min => 0, label_extra_instance => 1, instance_use => 'display' }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'data-transferred', set => {
|
||||
{ label => 'data-transferred', nlabel => 'protection_group.transferred.data.bytes',set => {
|
||||
key_values => [ { name => 'data_transferred' }, { name => 'display' } ],
|
||||
output_template => 'Data Transferred : %s %s',
|
||||
output_template => 'data transferred: %s %s',
|
||||
output_change_bytes => 1,
|
||||
perfdatas => [
|
||||
{ label => 'data_transferred', value => 'data_transferred', template => '%s',
|
||||
unit => 'B', min => 0, label_extra_instance => 1, instance_use => 'display' },
|
||||
],
|
||||
{ template => '%s', unit => 'B', 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' },
|
||||
'timezone:s' => { name => 'timezone', default => 'GMT' },
|
||||
'timezone:s' => { name => 'timezone', default => 'GMT' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub prefix_pgroup_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Protection group '" . $options{instance_value}->{display} . "' replication ";
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
@ -18,7 +18,7 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
package storage::purestorage::restapi::mode::volumeusage;
|
||||
package storage::purestorage::flasharray::legacy::restapi::mode::volumeusage;
|
||||
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
@ -28,10 +28,10 @@ use warnings;
|
||||
sub custom_usage_perfdata {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $label = 'used';
|
||||
my $nlabel = 'volume.space.usage.bytes';
|
||||
my $value_perf = $self->{result_values}->{used};
|
||||
if (defined($self->{instance_mode}->{option_results}->{free})) {
|
||||
$label = 'free';
|
||||
$nlabel = 'volume.space.free.bytes';
|
||||
$value_perf = $self->{result_values}->{free};
|
||||
}
|
||||
|
||||
@ -42,8 +42,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),
|
||||
@ -71,11 +72,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 {
|
||||
@ -91,6 +93,12 @@ sub custom_usage_calc {
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub prefix_volume_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Volume '" . $options{instance_value}->{display} . "' ";
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
@ -107,31 +115,28 @@ sub set_counters {
|
||||
closure_custom_threshold_check => $self->can('custom_usage_threshold')
|
||||
}
|
||||
},
|
||||
{ label => 'data-reduction', set => {
|
||||
key_values => [ { name => 'data_reduction' }, { name => 'display' } ],
|
||||
output_template => 'Data Reduction : %.3f',
|
||||
{ label => 'data-reduction', nlabel => 'volume.data.reduction.count', set => {
|
||||
key_values => [ { name => 'data_reduction' } ],
|
||||
output_template => 'data reduction: %.3f',
|
||||
perfdatas => [
|
||||
{ label => 'data_reduction', template => '%.3f',
|
||||
min => 0, label_extra_instance => 1, instance_use => 'display' }
|
||||
{ template => '%.3f', min => 0, label_extra_instance => 1 }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'total-reduction', set => {
|
||||
key_values => [ { name => 'total_reduction' }, { name => 'display' } ],
|
||||
output_template => 'Total Reduction : %.3f',
|
||||
{ label => 'total-reduction', nlabel => 'volume.total.reduction.count', set => {
|
||||
key_values => [ { name => 'total_reduction' } ],
|
||||
output_template => 'total reduction: %.3f',
|
||||
perfdatas => [
|
||||
{ label => 'total_reduction', template => '%.3f',
|
||||
min => 0, label_extra_instance => 1, instance_use => 'display' }
|
||||
{ template => '%.3f', min => 0, label_extra_instance => 1 }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'snapshots', set => {
|
||||
key_values => [ { name => 'snapshots' }, { name => 'display' } ],
|
||||
output_template => 'Snapshots : %s %s',
|
||||
{ label => 'snapshots', nlabel => 'volume.snapshots.usage.bytes', set => {
|
||||
key_values => [ { name => 'snapshots' } ],
|
||||
output_template => 'snapshots: %s %s',
|
||||
output_change_bytes => 1,
|
||||
perfdatas => [
|
||||
{ label => 'snapshots', template => '%s',
|
||||
unit => 'B', min => 0, label_extra_instance => 1, instance_use => 'display' }
|
||||
{ template => '%s', unit => 'B', min => 0, label_extra_instance => 1 }
|
||||
]
|
||||
}
|
||||
}
|
||||
@ -140,24 +145,18 @@ sub set_counters {
|
||||
|
||||
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' },
|
||||
'units:s' => { name => 'units', default => '%' },
|
||||
'free' => { name => 'free' },
|
||||
'free' => { name => 'free' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub prefix_volume_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Volume '" . $options{instance_value}->{display} . "' ";
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
@ -175,9 +174,9 @@ sub manage_selection {
|
||||
next;
|
||||
}
|
||||
|
||||
$self->{volume}->{$entry->{name}} = {
|
||||
$self->{volume}->{ $entry->{name} } = {
|
||||
display => $entry->{name},
|
||||
%{$entry},
|
||||
%{$entry}
|
||||
};
|
||||
}
|
||||
|
@ -18,7 +18,7 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
package storage::purestorage::restapi::plugin;
|
||||
package storage::purestorage::flasharray::legacy::restapi::plugin;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
@ -29,18 +29,17 @@ sub new {
|
||||
my $self = $class->SUPER::new( package => __PACKAGE__, %options );
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '0.1';
|
||||
$self->{modes} = {
|
||||
'alarms' => 'storage::purestorage::restapi::mode::alarms',
|
||||
'arrays' => 'storage::purestorage::restapi::mode::arrays',
|
||||
'hardware' => 'storage::purestorage::restapi::mode::hardware',
|
||||
'list-pgroups' => 'storage::purestorage::restapi::mode::listpgroups',
|
||||
'list-volumes' => 'storage::purestorage::restapi::mode::listvolumes',
|
||||
'pgroup-replication' => 'storage::purestorage::restapi::mode::pgroupreplication',
|
||||
'volume-usage' => 'storage::purestorage::restapi::mode::volumeusage'
|
||||
'alarms' => 'storage::purestorage::flasharray::legacy::restapi::mode::alarms',
|
||||
'arrays' => 'storage::purestorage::flasharray::legacy::restapi::mode::arrays',
|
||||
'hardware' => 'storage::purestorage::flasharray::legacy::restapi::mode::hardware',
|
||||
'list-pgroups' => 'storage::purestorage::flasharray::legacy::restapi::mode::listpgroups',
|
||||
'list-volumes' => 'storage::purestorage::flasharray::legacy::restapi::mode::listvolumes',
|
||||
'pgroup-replication' => 'storage::purestorage::flasharray::legacy::restapi::mode::pgroupreplication',
|
||||
'volume-usage' => 'storage::purestorage::flasharray::legacy::restapi::mode::volumeusage'
|
||||
};
|
||||
|
||||
$self->{custom_modes}->{api} = 'storage::purestorage::restapi::custom::api';
|
||||
$self->{custom_modes}->{api} = 'storage::purestorage::flasharray::legacy::restapi::custom::api';
|
||||
return $self;
|
||||
}
|
||||
|
||||
@ -50,6 +49,6 @@ __END__
|
||||
|
||||
=head1 PLUGIN DESCRIPTION
|
||||
|
||||
Check Pure Storage through HTTP/REST API.
|
||||
Check Pure Storage FlashArray through legacy HTTP/REST API.
|
||||
|
||||
=cut
|
@ -0,0 +1,272 @@
|
||||
#
|
||||
# Copyright 2023 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::purestorage::flasharray::v2::restapi::custom::api;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::http;
|
||||
use centreon::plugins::statefile;
|
||||
use Digest::MD5 qw(md5_hex);
|
||||
use JSON::XS;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = {};
|
||||
bless $self, $class;
|
||||
|
||||
if (!defined($options{output})) {
|
||||
print "Class Custom: Need to specify 'output' argument.\n";
|
||||
exit 3;
|
||||
}
|
||||
if (!defined($options{options})) {
|
||||
$options{output}->add_option_msg(short_msg => "Class Custom: Need to specify 'options' argument.");
|
||||
$options{output}->option_exit();
|
||||
}
|
||||
|
||||
if (!defined($options{noptions})) {
|
||||
$options{options}->add_options(arguments => {
|
||||
'api-token:s' => { name => 'api_token' },
|
||||
'hostname:s' => { name => 'hostname' },
|
||||
'port:s' => { name => 'port' },
|
||||
'proto:s' => { name => 'proto' },
|
||||
'timeout:s' => { name => 'timeout' },
|
||||
'api-version:s' => { name => 'api_version' },
|
||||
'unknown-http-status:s' => { name => 'unknown_http_status' },
|
||||
'warning-http-status:s' => { name => 'warning_http_status' },
|
||||
'critical-http-status:s' => { name => 'critical_http_status' }
|
||||
});
|
||||
}
|
||||
$options{options}->add_help(package => __PACKAGE__, sections => 'API OPTIONS', once => 1);
|
||||
|
||||
$self->{output} = $options{output};
|
||||
$self->{http} = centreon::plugins::http->new(%options, default_backend => 'curl');
|
||||
$self->{cache} = centreon::plugins::statefile->new(%options);
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub set_options {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{option_results} = $options{option_results};
|
||||
}
|
||||
|
||||
sub set_defaults {}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{option_results}->{hostname} = (defined($self->{option_results}->{hostname})) ? $self->{option_results}->{hostname} : '';
|
||||
$self->{option_results}->{port} = (defined($self->{option_results}->{port})) ? $self->{option_results}->{port} : 443;
|
||||
$self->{option_results}->{proto} = (defined($self->{option_results}->{proto})) ? $self->{option_results}->{proto} : 'https';
|
||||
$self->{option_results}->{timeout} = (defined($self->{option_results}->{timeout})) ? $self->{option_results}->{timeout} : 30;
|
||||
$self->{api_token} = (defined($self->{option_results}->{api_token})) ? $self->{option_results}->{api_token} : '';
|
||||
$self->{api_version} = (defined($self->{option_results}->{api_version})) ? $self->{option_results}->{api_version} : '2.4';
|
||||
$self->{unknown_http_status} = (defined($self->{option_results}->{unknown_http_status})) ? $self->{option_results}->{unknown_http_status} : '%{http_code} < 200 or %{http_code} >= 300';
|
||||
$self->{warning_http_status} = (defined($self->{option_results}->{warning_http_status})) ? $self->{option_results}->{warning_http_status} : '';
|
||||
$self->{critical_http_status} = (defined($self->{option_results}->{critical_http_status})) ? $self->{option_results}->{critical_http_status} : '';
|
||||
|
||||
if ($self->{option_results}->{hostname} eq '') {
|
||||
$self->{output}->add_option_msg(short_msg => 'Need to specify --hostname option.');
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if ($self->{api_token} eq '') {
|
||||
$self->{output}->add_option_msg(short_msg => 'Need to specify --api-token option.');
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if ($self->{api_version} eq '') {
|
||||
$self->{output}->add_option_msg(short_msg => 'Need to specify --api-version option.');
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
$self->{cache}->check_options(option_results => $self->{option_results});
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub settings {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return if (defined($self->{settings_done}));
|
||||
$self->{http}->set_options(%{$self->{option_results}});
|
||||
$self->{http}->add_header(key => 'Content-Type', value => 'application/json');
|
||||
$self->{http}->add_header(key => 'Accept', value => 'application/json');
|
||||
$self->{settings_done} = 1;
|
||||
}
|
||||
|
||||
sub get_connection_info {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return $self->{option_results}->{hostname} . ':' . $self->{option_results}->{port};
|
||||
}
|
||||
|
||||
sub get_token {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $has_cache_file = $self->{cache}->read(statefile => 'purestorage_' . md5_hex($self->get_connection_info() . '_' . $self->{api_token}));
|
||||
my $token = $self->{cache}->get(name => 'token');
|
||||
my $md5_secret_cache = $self->{cache}->get(name => 'md5_secret');
|
||||
my $md5_secret = md5_hex($self->{api_token});
|
||||
|
||||
if ($has_cache_file == 0 ||
|
||||
!defined($token) ||
|
||||
(defined($md5_secret_cache) && $md5_secret_cache ne $md5_secret)
|
||||
) {
|
||||
my ($content) = $self->{http}->request(
|
||||
method => 'POST',
|
||||
url_path => '/api/' . $self->{api_version} . '/login',
|
||||
query_form_post => '',
|
||||
header => [
|
||||
'api-token: ' . $self->{api_token}
|
||||
],
|
||||
unknown_status => $self->{unknown_http_status},
|
||||
warning_status => $self->{warning_http_status},
|
||||
critical_status => $self->{critical_http_status}
|
||||
);
|
||||
|
||||
$token = $self->{http}->get_header(name => 'x-auth-token');
|
||||
|
||||
if (!defined($token) || $token eq '') {
|
||||
$self->{output}->add_option_msg(short_msg => 'Cannot get token');
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
my $datas = {
|
||||
updated => time(),
|
||||
token => $token,
|
||||
md5_secret => $md5_secret
|
||||
};
|
||||
$self->{cache}->write(data => $datas);
|
||||
}
|
||||
|
||||
return $token;
|
||||
}
|
||||
|
||||
sub clean_token {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $datas = { updated => time() };
|
||||
$self->{cache}->write(data => $datas);
|
||||
}
|
||||
|
||||
sub request {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->settings();
|
||||
my $token = $self->get_token();
|
||||
|
||||
my $decoded;
|
||||
my $items = [];
|
||||
my $num_items = 0;
|
||||
while (1) {
|
||||
my $get_param = ['limit=1000'];
|
||||
push @$get_param, @{$options{get_param}} if (defined($options{get_param}));
|
||||
push @$get_param, 'continuation_token=' . $decoded->{continuation_token} if (defined($decoded) && defined($decoded->{continuation_token}));
|
||||
|
||||
my ($content) = $self->{http}->request(
|
||||
url_path => '/api/' . $self->{api_version} . $options{endpoint},
|
||||
get_param => $options{get_param},
|
||||
header => ['X-Auth-Token: ' . $token],
|
||||
unknown_status => '',
|
||||
warning_status => '',
|
||||
critical_status => ''
|
||||
);
|
||||
|
||||
# Maybe token is invalid. so we retry
|
||||
if ($self->{http}->get_code() < 200 || $self->{http}->get_code() >= 300) {
|
||||
$self->clean_token();
|
||||
$token = $self->get_token();
|
||||
($content) = $self->{http}->request(
|
||||
url_path => '/api/' . $self->{api_version} . $options{endpoint},
|
||||
get_param => $options{get_param},
|
||||
header => ['X-Auth-Token: ' . $token],
|
||||
unknown_status => $self->{unknown_http_status},
|
||||
warning_status => $self->{warning_http_status},
|
||||
critical_status => $self->{critical_http_status}
|
||||
);
|
||||
}
|
||||
|
||||
eval {
|
||||
$decoded = decode_json($content);
|
||||
};
|
||||
if ($@) {
|
||||
$self->{output}->add_option_msg(short_msg => "Cannot decode json response");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
$num_items += scalar(@{$decoded->{items}});
|
||||
push @$items, @{$decoded->{items}};
|
||||
|
||||
last if (
|
||||
!defined($decoded->{total_item_count}) ||
|
||||
$num_items >= $decoded->{total_item_count} ||
|
||||
!defined($decoded->{continuation_token})
|
||||
);
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Pure Storage API
|
||||
|
||||
=head1 API OPTIONS
|
||||
|
||||
Pure Storage API
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--hostname>
|
||||
|
||||
Set hostname.
|
||||
|
||||
=item B<--port>
|
||||
|
||||
Port used (Default: 443)
|
||||
|
||||
=item B<--proto>
|
||||
|
||||
Specify https if needed (Default: 'https')
|
||||
|
||||
=item B<--api-token>
|
||||
|
||||
API token.
|
||||
|
||||
=item B<--api-version>
|
||||
|
||||
API version (Default: 2.4).
|
||||
|
||||
=item B<--timeout>
|
||||
|
||||
Set timeout in seconds (Default: 30).
|
||||
|
||||
=back
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
B<custom>.
|
||||
|
||||
=cut
|
@ -0,0 +1,182 @@
|
||||
#
|
||||
# Copyright 2023 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::purestorage::flasharray::v2::restapi::mode::alerts;
|
||||
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::misc;
|
||||
use centreon::plugins::statefile;
|
||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
|
||||
|
||||
sub custom_status_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return sprintf(
|
||||
"alert [component: %s] [severity: %s] [category: %s] [issue: %s] %s",
|
||||
$self->{result_values}->{component_name},
|
||||
$self->{result_values}->{severity}, $self->{result_values}->{category},
|
||||
$self->{result_values}->{issue}, centreon::plugins::misc::change_seconds(value => $self->{result_values}->{opened})
|
||||
);
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'alerts', type => 2, message_multiple => '0 alert(s) detected', display_counter_problem => { nlabel => 'alerts.detected.count', min => 0 },
|
||||
group => [ { name => 'alert', skipped_code => { -11 => 1 } } ]
|
||||
}
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{alert} = [
|
||||
{
|
||||
label => 'status',
|
||||
type => 2,
|
||||
warning_default => '%{state} ne "closed" and %{severity} =~ /warning/i',
|
||||
critical_default => '%{state} ne "closed" and %{severity} =~ /critical/i',
|
||||
set => {
|
||||
key_values => [
|
||||
{ name => 'category' }, { name => 'code' },
|
||||
{ name => 'severity' }, { name => 'opened' }, { name => 'state' },
|
||||
{ name => 'component_name' }, { name => 'issue' }
|
||||
],
|
||||
closure_custom_output => $self->can('custom_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-category:s' => { name => 'filter_category' },
|
||||
'memory' => { name => 'memory' }
|
||||
});
|
||||
|
||||
$self->{statefile_cache} = centreon::plugins::statefile->new(%options);
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
if (defined($self->{option_results}->{memory})) {
|
||||
$self->{statefile_cache}->check_options(%options);
|
||||
}
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $items = $options{custom}->request(endpoint => '/alerts');
|
||||
|
||||
my $last_time;
|
||||
if (defined($self->{option_results}->{memory})) {
|
||||
$self->{statefile_cache}->read(statefile => 'purestorage_' . $self->{mode} . '_' . $options{custom}->get_connection_infos());
|
||||
$last_time = $self->{statefile_cache}->get(name => 'last_time');
|
||||
}
|
||||
|
||||
#{
|
||||
# "created": 1536744300846,
|
||||
# "description": "(hardware:ct1.eth0): failure Expected: , Actual: ",
|
||||
# "state": "closed",
|
||||
# "component_type": "hardware",
|
||||
# "name": "10088780",
|
||||
# "id": "18525aa28bee4eb3a68eb901c1483fea",
|
||||
# "category": "array",
|
||||
# "severity": "warning",
|
||||
# "code": 42,
|
||||
# "flagged": false,
|
||||
# "updated": 1536763089543,
|
||||
# "closed": 1536763264862,
|
||||
# "notified": null,
|
||||
# "component_name": "ct1.eth0",
|
||||
# "expected": "",
|
||||
# "actual": "",
|
||||
# "knowledge_base_url": "https://support.purestorage.com/?cid=Alert_0042",
|
||||
# "issue": "failure",
|
||||
# "summary": "(hardware:ct1.eth0): failure"
|
||||
#}
|
||||
|
||||
$self->{alerts}->{global} = { alert => {} };
|
||||
|
||||
my ($i, $current_time) = (1, time());
|
||||
foreach my $alert (@$items) {
|
||||
$alert->{created} /= 1000;
|
||||
|
||||
next if (defined($self->{option_results}->{memory}) && defined($last_time) && $last_time > $alert->{created});
|
||||
|
||||
next if (defined($self->{option_results}->{filter_category}) && $self->{option_results}->{filter_category} ne '' &&
|
||||
$alert->{category} !~ /$self->{option_results}->{filter_category}/);
|
||||
|
||||
my $diff_time = $current_time - $alert->{created};
|
||||
|
||||
$self->{alerts}->{global}->{alert}->{$i} = {
|
||||
%$alert,
|
||||
opened => $diff_time
|
||||
};
|
||||
$i++;
|
||||
}
|
||||
|
||||
if (defined($self->{option_results}->{memory})) {
|
||||
$self->{statefile_cache}->write(data => { last_time => $current_time });
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check alerts.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--filter-category>
|
||||
|
||||
Filter by category name (can be a regexp).
|
||||
|
||||
=item B<--warning-status>
|
||||
|
||||
Set warning threshold for status (Default: '%{state} ne "closed" and %{severity} =~ /warning/i')
|
||||
Can used special variables like: %{category}, %{code}, %{severity}, %{opened}, %{state}, %{issue}, %{component_name}
|
||||
|
||||
=item B<--critical-status>
|
||||
|
||||
Set critical threshold for status (Default: '%{state} ne "closed" and %{severity} =~ /critical/i').
|
||||
Can used special variables like: %{category}, %{code}, %{severity}, %{opened}, %{state}, %{issue}, %{component_name}
|
||||
|
||||
=item B<--memory>
|
||||
|
||||
Only check new alarms.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
@ -0,0 +1,278 @@
|
||||
#
|
||||
# Copyright 2023 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::purestorage::flasharray::v2::restapi::mode::arrays;
|
||||
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub custom_usage_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
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});
|
||||
return sprintf(
|
||||
'space 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 array_long_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "checking array '" . $options{instance_value}->{name} . "'";
|
||||
}
|
||||
|
||||
sub prefix_array_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Array '" . $options{instance_value}->{name} . "' ";
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{
|
||||
name => 'arrays', type => 3, cb_prefix_output => 'prefix_array_output', cb_long_output => 'array_long_output', indent_long_output => ' ',
|
||||
message_multiple => 'All arrays are ok',
|
||||
group => [
|
||||
{ name => 'space', type => 0, skipped_code => { -10 => 1 } },
|
||||
{ name => 'reduction', type => 0, skipped_code => { -10 => 1 } },
|
||||
{ name => 'perf', type => 0, skipped_code => { -10 => 1 } }
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{space} = [
|
||||
{ label => 'space-usage', nlabel => 'array.space.usage.bytes', set => {
|
||||
key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ],
|
||||
closure_custom_output => $self->can('custom_usage_output'),
|
||||
perfdatas => [
|
||||
{ template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1, label_extra_instance => 1 }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'space-usage-free', display_ok => 0, nlabel => 'array.space.free.bytes', set => {
|
||||
key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ],
|
||||
closure_custom_output => $self->can('custom_usage_output'),
|
||||
perfdatas => [
|
||||
{ template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1, label_extra_instance => 1 }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'space-usage-prct', display_ok => 0, nlabel => 'array.space.usage.percentage', set => {
|
||||
key_values => [ { name => 'prct_used' }, { name => 'used' }, { name => 'free' }, { name => 'prct_free' }, { name => 'total' } ],
|
||||
closure_custom_output => $self->can('custom_usage_output'),
|
||||
perfdatas => [
|
||||
{ template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1 }
|
||||
]
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{reduction} = [
|
||||
{ label => 'data-reduction', nlabel => 'array.data.reduction.count', set => {
|
||||
key_values => [ { name => 'data' } ],
|
||||
output_template => 'data reduction: %.3f',
|
||||
perfdatas => [
|
||||
{ template => '%.3f', min => 0, label_extra_instance => 1 }
|
||||
]
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{perf} = [
|
||||
{ label => 'read', nlabel => 'array.io.read.usage.bytespersecond', set => {
|
||||
key_values => [ { name => 'read_bytes' }, { name => 'name' }, { name => 'resolution' } ],
|
||||
output_template => 'read: %s %s/s',
|
||||
output_change_bytes => 1,
|
||||
closure_custom_perfdata => sub {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
nlabel => $self->{nlabel},
|
||||
unit => 'B/s',
|
||||
instances => [$self->{result_values}->{name}, $self->{result_values}->{resolution}],
|
||||
value => $self->{result_values}->{read_bytes},
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}),
|
||||
min => 0
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
{ label => 'write', nlabel => 'array.io.write.usage.bytespersecond', set => {
|
||||
key_values => [ { name => 'write_bytes' }, { name => 'name' }, { name => 'resolution' } ],
|
||||
output_template => 'write: %s %s/s',
|
||||
output_change_bytes => 1,
|
||||
closure_custom_perfdata => sub {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
nlabel => $self->{nlabel},
|
||||
unit => 'B/s',
|
||||
instances => [$self->{result_values}->{name}, $self->{result_values}->{resolution}],
|
||||
value => $self->{result_values}->{write_bytes},
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}),
|
||||
min => 0
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
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-id:s' => { name => 'filter_id' },
|
||||
'filter-name:s' => { name => 'filter_name' },
|
||||
'perf-resolution:s' => { name => 'perf_resolution' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
my $map_resolution = {
|
||||
'1s' => 1000, '30s' => 30000, '5m' => 300000,
|
||||
'30m' => 1800000, '2h' => 7200000, '8h' => 28800000,
|
||||
'24h' => 86400000
|
||||
};
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
$self->{option_results}->{perf_resolution} = '5m'
|
||||
if (!defined($self->{option_results}->{perf_resolution}) || $self->{option_results}->{perf_resolution} eq '');
|
||||
|
||||
if (!defined($map_resolution->{ $self->{option_results}->{perf_resolution} })) {
|
||||
$self->{output}->add_option_msg(short_msg => 'Unsupported --perf-resolution value. Can be: 1s, 30s, 5m, 30m, 2h, 8h, 24h');
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $items = $options{custom}->request(endpoint => '/arrays/space');
|
||||
my $perfs = $options{custom}->request(endpoint => '/arrays/performance', get_param => ['resolution=' . $map_resolution->{ $self->{option_results}->{perf_resolution} }]);
|
||||
|
||||
#{
|
||||
# "capacity": 29159353378407,
|
||||
# "id": "1dcca71d-8bca-4951-9ba5-10ca0f5744d8",
|
||||
# "name": "filer-c",
|
||||
# "parity": 1.0,
|
||||
# "space": {
|
||||
# "data_reduction": 3.808265875566517,
|
||||
# "replication": 0,
|
||||
# "shared": 2182502918574,
|
||||
# "snapshots": 0,
|
||||
# "system": 0,
|
||||
# "thin_provisioning": 0.3114475926111792,
|
||||
# "total_physical": 17760870565810,
|
||||
# "total_provisioned": 98232344510464,
|
||||
# "total_reduction": 5.5308293670898685,
|
||||
# "unique": 15578367647236,
|
||||
# "virtual": 67638117296128
|
||||
# },
|
||||
# "time": 1670839151850
|
||||
#}
|
||||
$self->{arrays} = {};
|
||||
foreach my $item (@$items) {
|
||||
next if (defined($self->{option_results}->{filter_id}) && $self->{option_results}->{filter_id} ne '' &&
|
||||
$item->{id} !~ /$self->{option_results}->{filter_id}/);
|
||||
next if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
||||
$item->{name} !~ /$self->{option_results}->{filter_name}/);
|
||||
|
||||
$self->{arrays}->{ $item->{name} } = {
|
||||
name => $item->{name},
|
||||
reduction => {
|
||||
data => $item->{space}->{data_reduction}
|
||||
},
|
||||
space => {
|
||||
total => $item->{capacity},
|
||||
used => $item->{space}->{total_physical},
|
||||
free => $item->{capacity} - $item->{space}->{total_physical},
|
||||
prct_used => $item->{space}->{total_physical} * 100 / $item->{capacity},
|
||||
prct_free => (100 - ($item->{space}->{total_physical} * 100 / $item->{capacity}))
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
foreach my $perf (@$perfs) {
|
||||
next if (!defined($self->{arrays}->{ $perf->{name} }));
|
||||
|
||||
$self->{arrays}->{ $perf->{name} }->{perf} = {
|
||||
name => $perf->{name},
|
||||
resolution => $self->{option_results}->{perf_resolution},
|
||||
read_bytes => $perf->{read_bytes_per_sec},
|
||||
write_bytes => $perf->{write_bytes_per_sec}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check arrays.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--filter-counters>
|
||||
|
||||
Only display some counters (regexp can be used).
|
||||
Example: --filter-counters='data-reduction'
|
||||
|
||||
=item B<--filter-id>
|
||||
|
||||
Filter arrays by id (can be a regexp).
|
||||
|
||||
=item B<--filter-name>
|
||||
|
||||
Filter arrays by name (can be a regexp).
|
||||
|
||||
=item B<--filter-resolution>
|
||||
|
||||
Time resolution for array performance.
|
||||
Can be: 1s, 30s, 5m, 30m, 2h, 8h, 24h (default: 5m).
|
||||
|
||||
=item B<--warning-*> B<--critical-*>
|
||||
|
||||
Thresholds.
|
||||
Can be: 'space-usage' (B), 'space-usage-free' (B), 'space-usage-prct' (%),
|
||||
'data-reduction', 'read', 'write'.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
@ -0,0 +1,63 @@
|
||||
#
|
||||
# Copyright 2022 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::purestorage::flasharray::v2::restapi::mode::components::chassis;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub load {}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "checking chassis");
|
||||
$self->{components}->{chassis} = { name => 'chassis', total => 0, skip => 0 };
|
||||
return if ($self->check_filter(section => 'chassis'));
|
||||
|
||||
foreach my $item (@{$self->{results}}) {
|
||||
next if ($item->{type} ne 'chassis');
|
||||
my $instance = $item->{index};
|
||||
|
||||
next if ($self->check_filter(section => 'chassis', instance => $instance));
|
||||
$self->{components}->{chassis}->{total}++;
|
||||
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
"chassis '%s' status is %s [instance: %s]",
|
||||
$item->{name},
|
||||
$item->{status},
|
||||
$instance
|
||||
)
|
||||
);
|
||||
|
||||
my $exit = $self->get_severity(label => 'default', section => 'chassis', instance => $instance, value => $item->{status});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf(
|
||||
"Chassis '%s' status is %s", $item->{name}, $item->{status}
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
@ -0,0 +1,63 @@
|
||||
#
|
||||
# Copyright 2022 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::purestorage::flasharray::v2::restapi::mode::components::controller;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub load {}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "checking controllers");
|
||||
$self->{components}->{controller} = { name => 'controllers', total => 0, skip => 0 };
|
||||
return if ($self->check_filter(section => 'controller'));
|
||||
|
||||
foreach my $item (@{$self->{results}}) {
|
||||
next if ($item->{type} ne 'controller');
|
||||
my $instance = $item->{index};
|
||||
|
||||
next if ($self->check_filter(section => 'controller', instance => $instance));
|
||||
$self->{components}->{controller}->{total}++;
|
||||
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
"controller '%s' status is %s [instance: %s]",
|
||||
$item->{name},
|
||||
$item->{status},
|
||||
$instance
|
||||
)
|
||||
);
|
||||
|
||||
my $exit = $self->get_severity(label => 'default', section => 'controller', instance => $instance, value => $item->{status});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf(
|
||||
"Controller '%s' status is %s", $item->{name}, $item->{status}
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
@ -0,0 +1,63 @@
|
||||
#
|
||||
# Copyright 2022 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::purestorage::flasharray::v2::restapi::mode::components::cooling;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub load {}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "checking cooling");
|
||||
$self->{components}->{cooling} = { name => 'cooling', total => 0, skip => 0 };
|
||||
return if ($self->check_filter(section => 'cooling'));
|
||||
|
||||
foreach my $item (@{$self->{results}}) {
|
||||
next if ($item->{type} ne 'cooling');
|
||||
my $instance = $item->{index};
|
||||
|
||||
next if ($self->check_filter(section => 'cooling', instance => $instance));
|
||||
$self->{components}->{cooling}->{total}++;
|
||||
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
"cooling '%s' status is %s [instance: %s]",
|
||||
$item->{name},
|
||||
$item->{status},
|
||||
$instance
|
||||
)
|
||||
);
|
||||
|
||||
my $exit = $self->get_severity(label => 'default', section => 'cooling', instance => $instance, value => $item->{status});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf(
|
||||
"Cooling '%s' status is %s", $item->{name}, $item->{status}
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
@ -0,0 +1,63 @@
|
||||
#
|
||||
# Copyright 2022 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::purestorage::flasharray::v2::restapi::mode::components::drive;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub load {}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "checking drives");
|
||||
$self->{components}->{drive} = { name => 'drives', total => 0, skip => 0 };
|
||||
return if ($self->check_filter(section => 'drive'));
|
||||
|
||||
foreach my $item (@{$self->{results}}) {
|
||||
next if ($item->{type} ne 'drive_bay');
|
||||
my $instance = $item->{index};
|
||||
|
||||
next if ($self->check_filter(section => 'drive', instance => $instance));
|
||||
$self->{components}->{drive}->{total}++;
|
||||
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
"drive '%s' status is %s [instance: %s]",
|
||||
$item->{name},
|
||||
$item->{status},
|
||||
$instance
|
||||
)
|
||||
);
|
||||
|
||||
my $exit = $self->get_severity(label => 'default', section => 'drive', instance => $instance, value => $item->{status});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf(
|
||||
"Drive '%s' status is %s", $item->{name}, $item->{status}
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
@ -0,0 +1,63 @@
|
||||
#
|
||||
# Copyright 2022 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::purestorage::flasharray::v2::restapi::mode::components::ethport;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub load {}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "checking ethport");
|
||||
$self->{components}->{ethport} = { name => 'ethport', total => 0, skip => 0 };
|
||||
return if ($self->check_filter(section => 'ethport'));
|
||||
|
||||
foreach my $item (@{$self->{results}}) {
|
||||
next if ($item->{type} ne 'eth_port');
|
||||
my $instance = $item->{index};
|
||||
|
||||
next if ($self->check_filter(section => 'ethport', instance => $instance));
|
||||
$self->{components}->{ethport}->{total}++;
|
||||
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
"eth port '%s' status is %s [instance: %s]",
|
||||
$item->{name},
|
||||
$item->{status},
|
||||
$instance
|
||||
)
|
||||
);
|
||||
|
||||
my $exit = $self->get_severity(label => 'default', section => 'ethport', instance => $instance, value => $item->{status});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf(
|
||||
"Eth port '%s' status is %s", $item->{name}, $item->{status}
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
@ -0,0 +1,63 @@
|
||||
#
|
||||
# Copyright 2022 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::purestorage::flasharray::v2::restapi::mode::components::fcport;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub load {}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "checking fcport");
|
||||
$self->{components}->{fcport} = { name => 'fcport', total => 0, skip => 0 };
|
||||
return if ($self->check_filter(section => 'fcport'));
|
||||
|
||||
foreach my $item (@{$self->{results}}) {
|
||||
next if ($item->{type} ne 'fc_port');
|
||||
my $instance = $item->{index};
|
||||
|
||||
next if ($self->check_filter(section => 'fcport', instance => $instance));
|
||||
$self->{components}->{fcport}->{total}++;
|
||||
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
"fc port '%s' status is %s [instance: %s]",
|
||||
$item->{name},
|
||||
$item->{status},
|
||||
$instance
|
||||
)
|
||||
);
|
||||
|
||||
my $exit = $self->get_severity(label => 'default', section => 'fcport', instance => $instance, value => $item->{status});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf(
|
||||
"Fc port '%s' status is %s", $item->{name}, $item->{status}
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
@ -0,0 +1,63 @@
|
||||
#
|
||||
# Copyright 2022 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::purestorage::flasharray::v2::restapi::mode::components::nvram;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub load {}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "checking nvram");
|
||||
$self->{components}->{nvram} = { name => 'nvram', total => 0, skip => 0 };
|
||||
return if ($self->check_filter(section => 'nvram'));
|
||||
|
||||
foreach my $item (@{$self->{results}}) {
|
||||
next if ($item->{type} ne 'nvram_bay');
|
||||
my $instance = $item->{index};
|
||||
|
||||
next if ($self->check_filter(section => 'nvram', instance => $instance));
|
||||
$self->{components}->{nvram}->{total}++;
|
||||
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
"nvram '%s' status is %s [instance: %s]",
|
||||
$item->{name},
|
||||
$item->{status},
|
||||
$instance
|
||||
)
|
||||
);
|
||||
|
||||
my $exit = $self->get_severity(label => 'default', section => 'nvram', instance => $instance, value => $item->{status});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf(
|
||||
"Nvram '%s' status is %s", $item->{name}, $item->{status}
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
@ -0,0 +1,63 @@
|
||||
#
|
||||
# Copyright 2022 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::purestorage::flasharray::v2::restapi::mode::components::psu;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub load {}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "checking power supplies");
|
||||
$self->{components}->{psu} = { name => 'psus', total => 0, skip => 0 };
|
||||
return if ($self->check_filter(section => 'psu'));
|
||||
|
||||
foreach my $item (@{$self->{results}}) {
|
||||
next if ($item->{type} ne 'power_supply');
|
||||
my $instance = $item->{index};
|
||||
|
||||
next if ($self->check_filter(section => 'psus', instance => $instance));
|
||||
$self->{components}->{psu}->{total}++;
|
||||
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
"power supply '%s' status is %s [instance: %s]",
|
||||
$item->{name},
|
||||
$item->{status},
|
||||
$instance
|
||||
)
|
||||
);
|
||||
|
||||
my $exit = $self->get_severity(label => 'default', section => 'psu', instance => $instance, value => $item->{status});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf(
|
||||
"Power supply '%s' status is %s", $item->{name}, $item->{status}
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
@ -0,0 +1,63 @@
|
||||
#
|
||||
# Copyright 2022 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::purestorage::flasharray::v2::restapi::mode::components::sasport;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub load {}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "checking sasport");
|
||||
$self->{components}->{sasport} = { name => 'sasport', total => 0, skip => 0 };
|
||||
return if ($self->check_filter(section => 'sasport'));
|
||||
|
||||
foreach my $item (@{$self->{results}}) {
|
||||
next if ($item->{type} ne 'sas_port');
|
||||
my $instance = $item->{index};
|
||||
|
||||
next if ($self->check_filter(section => 'sasport', instance => $instance));
|
||||
$self->{components}->{sasport}->{total}++;
|
||||
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
"sas port '%s' status is %s [instance: %s]",
|
||||
$item->{name},
|
||||
$item->{status},
|
||||
$instance
|
||||
)
|
||||
);
|
||||
|
||||
my $exit = $self->get_severity(label => 'default', section => 'sasport', instance => $instance, value => $item->{status});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf(
|
||||
"Sas port '%s' status is %s", $item->{name}, $item->{status}
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
@ -0,0 +1,84 @@
|
||||
#
|
||||
# Copyright 2022 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::purestorage::flasharray::v2::restapi::mode::components::temperature;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub load {}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "checking temperatures");
|
||||
$self->{components}->{temperature} = { name => 'temperatures', total => 0, skip => 0 };
|
||||
return if ($self->check_filter(section => 'temperature'));
|
||||
|
||||
my ($exit, $warn, $crit, $checked);
|
||||
foreach my $item (@{$self->{results}}) {
|
||||
next if ($item->{type} ne 'temp_sensor');
|
||||
my $instance = $item->{index};
|
||||
|
||||
next if ($self->check_filter(section => 'temperature', instance => $instance));
|
||||
$self->{components}->{temperature}->{total}++;
|
||||
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
"temperature '%s' status is %s [instance: %s] [value: %s]",
|
||||
$item->{name},
|
||||
$item->{status},
|
||||
$instance,
|
||||
$item->{temperature}
|
||||
)
|
||||
);
|
||||
|
||||
$exit = $self->get_severity(label => 'default', section => 'temperature', instance => $instance, value => $item->{status});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf(
|
||||
"Temperature '%s' status is %s", $item->{name}, $item->{status}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
next if (!defined($item->{temperature}) || $item->{temperature} !~ /[0-9]/);
|
||||
|
||||
($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $item->{temperature});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf("Temperature '%s' is %s degree centigrade", $item->{name}, $item->{temperature})
|
||||
);
|
||||
}
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
nlabel => 'hardware.sensor.temperature.celsius',
|
||||
unit => 'C',
|
||||
instances => $item->{name},
|
||||
value => $item->{temperature},
|
||||
warning => $warn,
|
||||
critical => $crit
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
@ -0,0 +1,109 @@
|
||||
#
|
||||
# Copyright 2022 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::purestorage::flasharray::v2::restapi::mode::hardware;
|
||||
|
||||
use base qw(centreon::plugins::templates::hardware);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub set_system {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{regexp_threshold_numeric_check_section_option} = '^(?:temperature)$';
|
||||
|
||||
$self->{cb_hook2} = 'api_execute';
|
||||
|
||||
$self->{thresholds} = {
|
||||
default => [
|
||||
['ok', 'OK'],
|
||||
['unused', 'OK'],
|
||||
['unknown', 'UNKNOWN'],
|
||||
['critical', 'CRITICAL'],
|
||||
['identifying', 'OK'],
|
||||
['not_installed', 'OK']
|
||||
]
|
||||
};
|
||||
|
||||
$self->{components_path} = 'storage::purestorage::flasharray::v2::restapi::mode::components';
|
||||
$self->{components_module} = ['chassis', 'controller', 'cooling', 'drive', 'ethport', 'fcport', 'nvram', 'psu', 'sasport', 'temperature'];
|
||||
}
|
||||
|
||||
sub api_execute {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{results} = $options{custom}->request(endpoint => '/hardware');
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1, force_new_perfdata => 1);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check hardware.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--component>
|
||||
|
||||
Which component to check (Default: '.*').
|
||||
Can be: 'chassis', 'controller', 'cooling', 'drive', 'ethport', 'fcport', 'nvram', 'psu', 'sasport', 'temperature'.
|
||||
|
||||
=item B<--filter>
|
||||
|
||||
Exclude some parts (comma seperated list) (Example: --filter=controller)
|
||||
Can also exclude specific instance: --filter=drive,1
|
||||
|
||||
=item B<--no-component>
|
||||
|
||||
Return an error if no compenents are checked.
|
||||
If total (with skipped) is 0. (Default: 'critical' returns).
|
||||
|
||||
=item B<--threshold-overload>
|
||||
|
||||
Set to overload default threshold values (syntax: section,[instance,]status,regexp)
|
||||
It used before default thresholds (order stays).
|
||||
Example: --threshold-overload='temperature,OK,identifying'
|
||||
|
||||
=item B<--warning>
|
||||
|
||||
Set warning threshold (syntax: type,regexp,threshold)
|
||||
Example: --warning='temperature,.*,30'
|
||||
|
||||
=item B<--critical>
|
||||
|
||||
Set critical threshold (syntax: type,regexp,threshold)
|
||||
Example: --critical='temperature,.*,40'
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
@ -0,0 +1,108 @@
|
||||
#
|
||||
# Copyright 2022 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::purestorage::flasharray::v2::restapi::mode::listarrays;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
}
|
||||
|
||||
my @labels = ('id', 'name', 'capacity');
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $items = $options{custom}->request(endpoint => '/arrays/space');
|
||||
|
||||
my $results = {};
|
||||
foreach my $item (@$items) {
|
||||
$results->{ $item->{id} } = {
|
||||
id => $item->{id},
|
||||
name => $item->{name},
|
||||
capacity => $item->{capacity}
|
||||
};
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $results = $self->manage_selection(custom => $options{custom});
|
||||
foreach my $instance (sort keys %$results) {
|
||||
$self->{output}->output_add(long_msg =>
|
||||
join('', map("[$_: " . $results->{$instance}->{$_} . ']', @labels))
|
||||
);
|
||||
}
|
||||
|
||||
$self->{output}->output_add(
|
||||
severity => 'OK',
|
||||
short_msg => 'List arrays:'
|
||||
);
|
||||
$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 => [@labels]);
|
||||
}
|
||||
|
||||
sub disco_show {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $results = $self->manage_selection(custom => $options{custom});
|
||||
foreach (sort keys %$results) {
|
||||
$self->{output}->add_disco_entry(
|
||||
%{$results->{$_}}
|
||||
);
|
||||
}
|
||||
}
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
List arrays.
|
||||
|
||||
=over 8
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
@ -0,0 +1,108 @@
|
||||
#
|
||||
# Copyright 2022 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::purestorage::flasharray::v2::restapi::mode::listvolumes;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
}
|
||||
|
||||
my @labels = ('id', 'name', 'provisioned');
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $items = $options{custom}->request(endpoint => '/volumes');
|
||||
|
||||
my $results = {};
|
||||
foreach my $item (@$items) {
|
||||
$results->{ $item->{id} } = {
|
||||
id => $item->{id},
|
||||
name => $item->{name},
|
||||
provisioned => $item->{provisioned}
|
||||
};
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $results = $self->manage_selection(custom => $options{custom});
|
||||
foreach my $instance (sort keys %$results) {
|
||||
$self->{output}->output_add(long_msg =>
|
||||
join('', map("[$_: " . $results->{$instance}->{$_} . ']', @labels))
|
||||
);
|
||||
}
|
||||
|
||||
$self->{output}->output_add(
|
||||
severity => 'OK',
|
||||
short_msg => 'List volumes:'
|
||||
);
|
||||
$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 => [@labels]);
|
||||
}
|
||||
|
||||
sub disco_show {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $results = $self->manage_selection(custom => $options{custom});
|
||||
foreach (sort keys %$results) {
|
||||
$self->{output}->add_disco_entry(
|
||||
%{$results->{$_}}
|
||||
);
|
||||
}
|
||||
}
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
List volumes.
|
||||
|
||||
=over 8
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
@ -0,0 +1,258 @@
|
||||
#
|
||||
# Copyright 2023 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::purestorage::flasharray::v2::restapi::mode::volumes;
|
||||
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub custom_usage_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
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});
|
||||
return sprintf(
|
||||
'space 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 volume_long_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "checking volume '" . $options{instance_value}->{name} . "'";
|
||||
}
|
||||
|
||||
sub prefix_volume_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Volume '" . $options{instance_value}->{name} . "' ";
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{
|
||||
name => 'volumes', type => 3, cb_prefix_output => 'prefix_volume_output', cb_long_output => 'volume_long_output', indent_long_output => ' ',
|
||||
message_multiple => 'All volumes are ok',
|
||||
group => [
|
||||
{ name => 'space', type => 0, skipped_code => { -10 => 1 } },
|
||||
{ name => 'reduction', type => 0, skipped_code => { -10 => 1 } },
|
||||
{ name => 'perf', type => 0, skipped_code => { -10 => 1 } }
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{space} = [
|
||||
{ label => 'space-usage', nlabel => 'volume.space.usage.bytes', set => {
|
||||
key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ],
|
||||
closure_custom_output => $self->can('custom_usage_output'),
|
||||
perfdatas => [
|
||||
{ template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1, label_extra_instance => 1 }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'space-usage-free', display_ok => 0, nlabel => 'volume.space.free.bytes', set => {
|
||||
key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ],
|
||||
closure_custom_output => $self->can('custom_usage_output'),
|
||||
perfdatas => [
|
||||
{ template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1, label_extra_instance => 1 }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'space-usage-prct', display_ok => 0, nlabel => 'volume.space.usage.percentage', set => {
|
||||
key_values => [ { name => 'prct_used' }, { name => 'used' }, { name => 'free' }, { name => 'prct_free' }, { name => 'total' } ],
|
||||
closure_custom_output => $self->can('custom_usage_output'),
|
||||
perfdatas => [
|
||||
{ template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1 }
|
||||
]
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{reduction} = [
|
||||
{ label => 'data-reduction', nlabel => 'volume.data.reduction.count', set => {
|
||||
key_values => [ { name => 'data' } ],
|
||||
output_template => 'data reduction: %.3f',
|
||||
perfdatas => [
|
||||
{ template => '%.3f', min => 0, label_extra_instance => 1 }
|
||||
]
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{perf} = [
|
||||
{ label => 'read', nlabel => 'volume.io.read.usage.bytespersecond', set => {
|
||||
key_values => [ { name => 'read_bytes' }, { name => 'name' }, { name => 'resolution' } ],
|
||||
output_template => 'read: %s %s/s',
|
||||
output_change_bytes => 1,
|
||||
closure_custom_perfdata => sub {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
nlabel => $self->{nlabel},
|
||||
unit => 'B/s',
|
||||
instances => [$self->{result_values}->{name}, $self->{result_values}->{resolution}],
|
||||
value => $self->{result_values}->{read_bytes},
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}),
|
||||
min => 0
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
{ label => 'write', nlabel => 'volume.io.write.usage.bytespersecond', set => {
|
||||
key_values => [ { name => 'write_bytes' }, { name => 'name' }, { name => 'resolution' } ],
|
||||
output_template => 'write: %s %s/s',
|
||||
output_change_bytes => 1,
|
||||
closure_custom_perfdata => sub {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
nlabel => $self->{nlabel},
|
||||
unit => 'B/s',
|
||||
instances => [$self->{result_values}->{name}, $self->{result_values}->{resolution}],
|
||||
value => $self->{result_values}->{write_bytes},
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}),
|
||||
min => 0
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
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-id:s' => { name => 'filter_id' },
|
||||
'filter-name:s' => { name => 'filter_name' },
|
||||
'perf-resolution:s' => { name => 'perf_resolution' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
my $map_resolution = {
|
||||
'1s' => 1000, '30s' => 30000, '5m' => 300000,
|
||||
'30m' => 1800000, '2h' => 7200000, '8h' => 28800000,
|
||||
'24h' => 86400000
|
||||
};
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
$self->{option_results}->{perf_resolution} = '5m'
|
||||
if (!defined($self->{option_results}->{perf_resolution}) || $self->{option_results}->{perf_resolution} eq '');
|
||||
|
||||
if (!defined($map_resolution->{ $self->{option_results}->{perf_resolution} })) {
|
||||
$self->{output}->add_option_msg(short_msg => 'Unsupported --perf-resolution value. Can be: 1s, 30s, 5m, 30m, 2h, 8h, 24h');
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $items = $options{custom}->request(endpoint => '/volumes');
|
||||
my $perfs = $options{custom}->request(endpoint => '/volumes/performance', get_param => ['resolution=' . $map_resolution->{ $self->{option_results}->{perf_resolution} }]);
|
||||
|
||||
$self->{volumes} = {};
|
||||
foreach my $item (@$items) {
|
||||
next if (defined($self->{option_results}->{filter_id}) && $self->{option_results}->{filter_id} ne '' &&
|
||||
$item->{id} !~ /$self->{option_results}->{filter_id}/);
|
||||
next if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
||||
$item->{name} !~ /$self->{option_results}->{filter_name}/);
|
||||
|
||||
$self->{volumes}->{ $item->{name} } = {
|
||||
name => $item->{name},
|
||||
reduction => {
|
||||
data => $item->{space}->{data_reduction}
|
||||
},
|
||||
space => {
|
||||
total => $item->{provisioned},
|
||||
used => $item->{space}->{total_physical},
|
||||
free => $item->{provisioned} - $item->{space}->{total_physical},
|
||||
prct_used => $item->{space}->{total_physical} * 100 / $item->{provisioned},
|
||||
prct_free => (100 - ($item->{space}->{total_physical} * 100 / $item->{provisioned}))
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
foreach my $perf (@$perfs) {
|
||||
next if (!defined($self->{volumes}->{ $perf->{name} }));
|
||||
|
||||
$self->{volumes}->{ $perf->{name} }->{perf} = {
|
||||
name => $perf->{name},
|
||||
resolution => $self->{option_results}->{perf_resolution},
|
||||
read_bytes => $perf->{read_bytes_per_sec},
|
||||
write_bytes => $perf->{write_bytes_per_sec}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check volumes.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--filter-counters>
|
||||
|
||||
Only display some counters (regexp can be used).
|
||||
Example: --filter-counters='data-reduction'
|
||||
|
||||
=item B<--filter-id>
|
||||
|
||||
Filter volumes by id (can be a regexp).
|
||||
|
||||
=item B<--filter-name>
|
||||
|
||||
Filter volumes by name (can be a regexp).
|
||||
|
||||
=item B<--filter-resolution>
|
||||
|
||||
Time resolution for array performance.
|
||||
Can be: 1s, 30s, 5m, 30m, 2h, 8h, 24h (default: 5m).
|
||||
|
||||
=item B<--warning-*> B<--critical-*>
|
||||
|
||||
Thresholds.
|
||||
Can be: 'space-usage' (B), 'space-usage-free' (B), 'space-usage-prct' (%),
|
||||
'data-reduction', 'read', 'write'.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
@ -0,0 +1,53 @@
|
||||
#
|
||||
# Copyright 2023 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::purestorage::flasharray::v2::restapi::plugin;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use base qw(centreon::plugins::script_custom);
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{modes} = {
|
||||
'alerts' => 'storage::purestorage::flasharray::v2::restapi::mode::alerts',
|
||||
'arrays' => 'storage::purestorage::flasharray::v2::restapi::mode::arrays',
|
||||
'hardware' => 'storage::purestorage::flasharray::v2::restapi::mode::hardware',
|
||||
'list-arrays' => 'storage::purestorage::flasharray::v2::restapi::mode::listarrays',
|
||||
'list-volumes' => 'storage::purestorage::flasharray::v2::restapi::mode::listvolumes',
|
||||
'volumes' => 'storage::purestorage::flasharray::v2::restapi::mode::volumes'
|
||||
};
|
||||
|
||||
$self->{custom_modes}->{api} = 'storage::purestorage::flasharray::v2::restapi::custom::api';
|
||||
return $self;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 PLUGIN DESCRIPTION
|
||||
|
||||
Check Pure Storage FlashArray through HTTP/REST API v2.
|
||||
|
||||
=cut
|
@ -0,0 +1,272 @@
|
||||
#
|
||||
# Copyright 2023 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::purestorage::flashblade::v2::restapi::custom::api;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::http;
|
||||
use centreon::plugins::statefile;
|
||||
use Digest::MD5 qw(md5_hex);
|
||||
use JSON::XS;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = {};
|
||||
bless $self, $class;
|
||||
|
||||
if (!defined($options{output})) {
|
||||
print "Class Custom: Need to specify 'output' argument.\n";
|
||||
exit 3;
|
||||
}
|
||||
if (!defined($options{options})) {
|
||||
$options{output}->add_option_msg(short_msg => "Class Custom: Need to specify 'options' argument.");
|
||||
$options{output}->option_exit();
|
||||
}
|
||||
|
||||
if (!defined($options{noptions})) {
|
||||
$options{options}->add_options(arguments => {
|
||||
'api-token:s' => { name => 'api_token' },
|
||||
'hostname:s' => { name => 'hostname' },
|
||||
'port:s' => { name => 'port' },
|
||||
'proto:s' => { name => 'proto' },
|
||||
'timeout:s' => { name => 'timeout' },
|
||||
'api-version:s' => { name => 'api_version' },
|
||||
'unknown-http-status:s' => { name => 'unknown_http_status' },
|
||||
'warning-http-status:s' => { name => 'warning_http_status' },
|
||||
'critical-http-status:s' => { name => 'critical_http_status' }
|
||||
});
|
||||
}
|
||||
$options{options}->add_help(package => __PACKAGE__, sections => 'API OPTIONS', once => 1);
|
||||
|
||||
$self->{output} = $options{output};
|
||||
$self->{http} = centreon::plugins::http->new(%options, default_backend => 'curl');
|
||||
$self->{cache} = centreon::plugins::statefile->new(%options);
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub set_options {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{option_results} = $options{option_results};
|
||||
}
|
||||
|
||||
sub set_defaults {}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{option_results}->{hostname} = (defined($self->{option_results}->{hostname})) ? $self->{option_results}->{hostname} : '';
|
||||
$self->{option_results}->{port} = (defined($self->{option_results}->{port})) ? $self->{option_results}->{port} : 443;
|
||||
$self->{option_results}->{proto} = (defined($self->{option_results}->{proto})) ? $self->{option_results}->{proto} : 'https';
|
||||
$self->{option_results}->{timeout} = (defined($self->{option_results}->{timeout})) ? $self->{option_results}->{timeout} : 30;
|
||||
$self->{api_token} = (defined($self->{option_results}->{api_token})) ? $self->{option_results}->{api_token} : '';
|
||||
$self->{api_version} = (defined($self->{option_results}->{api_version})) ? $self->{option_results}->{api_version} : '2.4';
|
||||
$self->{unknown_http_status} = (defined($self->{option_results}->{unknown_http_status})) ? $self->{option_results}->{unknown_http_status} : '%{http_code} < 200 or %{http_code} >= 300';
|
||||
$self->{warning_http_status} = (defined($self->{option_results}->{warning_http_status})) ? $self->{option_results}->{warning_http_status} : '';
|
||||
$self->{critical_http_status} = (defined($self->{option_results}->{critical_http_status})) ? $self->{option_results}->{critical_http_status} : '';
|
||||
|
||||
if ($self->{option_results}->{hostname} eq '') {
|
||||
$self->{output}->add_option_msg(short_msg => 'Need to specify --hostname option.');
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if ($self->{api_token} eq '') {
|
||||
$self->{output}->add_option_msg(short_msg => 'Need to specify --api-token option.');
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if ($self->{api_version} eq '') {
|
||||
$self->{output}->add_option_msg(short_msg => 'Need to specify --api-version option.');
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
$self->{cache}->check_options(option_results => $self->{option_results});
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub settings {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return if (defined($self->{settings_done}));
|
||||
$self->{http}->set_options(%{$self->{option_results}});
|
||||
$self->{http}->add_header(key => 'Content-Type', value => 'application/json');
|
||||
$self->{http}->add_header(key => 'Accept', value => 'application/json');
|
||||
$self->{settings_done} = 1;
|
||||
}
|
||||
|
||||
sub get_connection_info {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return $self->{option_results}->{hostname} . ':' . $self->{option_results}->{port};
|
||||
}
|
||||
|
||||
sub get_token {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $has_cache_file = $self->{cache}->read(statefile => 'purestorage_' . md5_hex($self->get_connection_info() . '_' . $self->{api_token}));
|
||||
my $token = $self->{cache}->get(name => 'token');
|
||||
my $md5_secret_cache = $self->{cache}->get(name => 'md5_secret');
|
||||
my $md5_secret = md5_hex($self->{api_token});
|
||||
|
||||
if ($has_cache_file == 0 ||
|
||||
!defined($token) ||
|
||||
(defined($md5_secret_cache) && $md5_secret_cache ne $md5_secret)
|
||||
) {
|
||||
my ($content) = $self->{http}->request(
|
||||
method => 'POST',
|
||||
url_path => '/api/login',
|
||||
query_form_post => '',
|
||||
header => [
|
||||
'api-token: ' . $self->{api_token}
|
||||
],
|
||||
unknown_status => $self->{unknown_http_status},
|
||||
warning_status => $self->{warning_http_status},
|
||||
critical_status => $self->{critical_http_status}
|
||||
);
|
||||
|
||||
$token = $self->{http}->get_header(name => 'x-auth-token');
|
||||
|
||||
if (!defined($token) || $token eq '') {
|
||||
$self->{output}->add_option_msg(short_msg => 'Cannot get token');
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
my $datas = {
|
||||
updated => time(),
|
||||
token => $token,
|
||||
md5_secret => $md5_secret
|
||||
};
|
||||
$self->{cache}->write(data => $datas);
|
||||
}
|
||||
|
||||
return $token;
|
||||
}
|
||||
|
||||
sub clean_token {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $datas = { updated => time() };
|
||||
$self->{cache}->write(data => $datas);
|
||||
}
|
||||
|
||||
sub request {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->settings();
|
||||
my $token = $self->get_token();
|
||||
|
||||
my $decoded;
|
||||
my $items = [];
|
||||
my $num_items = 0;
|
||||
while (1) {
|
||||
my $get_param = ['limit=1000'];
|
||||
push @$get_param, @{$options{get_param}} if (defined($options{get_param}));
|
||||
push @$get_param, 'continuation_token=' . $decoded->{continuation_token} if (defined($decoded) && defined($decoded->{continuation_token}));
|
||||
|
||||
my ($content) = $self->{http}->request(
|
||||
url_path => '/api/' . $self->{api_version} . $options{endpoint},
|
||||
get_param => $options{get_param},
|
||||
header => ['X-Auth-Token: ' . $token],
|
||||
unknown_status => '',
|
||||
warning_status => '',
|
||||
critical_status => ''
|
||||
);
|
||||
|
||||
# Maybe token is invalid. so we retry
|
||||
if ($self->{http}->get_code() < 200 || $self->{http}->get_code() >= 300) {
|
||||
$self->clean_token();
|
||||
$token = $self->get_token();
|
||||
($content) = $self->{http}->request(
|
||||
url_path => '/api/' . $self->{api_version} . $options{endpoint},
|
||||
get_param => $options{get_param},
|
||||
header => ['X-Auth-Token: ' . $token],
|
||||
unknown_status => $self->{unknown_http_status},
|
||||
warning_status => $self->{warning_http_status},
|
||||
critical_status => $self->{critical_http_status}
|
||||
);
|
||||
}
|
||||
|
||||
eval {
|
||||
$decoded = decode_json($content);
|
||||
};
|
||||
if ($@) {
|
||||
$self->{output}->add_option_msg(short_msg => "Cannot decode json response");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
$num_items += scalar(@{$decoded->{items}});
|
||||
push @$items, @{$decoded->{items}};
|
||||
|
||||
last if (
|
||||
!defined($decoded->{total_item_count}) ||
|
||||
$num_items >= $decoded->{total_item_count} ||
|
||||
!defined($decoded->{continuation_token})
|
||||
);
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Pure Storage API
|
||||
|
||||
=head1 API OPTIONS
|
||||
|
||||
Pure Storage API
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--hostname>
|
||||
|
||||
Set hostname.
|
||||
|
||||
=item B<--port>
|
||||
|
||||
Port used (Default: 443)
|
||||
|
||||
=item B<--proto>
|
||||
|
||||
Specify https if needed (Default: 'https')
|
||||
|
||||
=item B<--api-token>
|
||||
|
||||
API token.
|
||||
|
||||
=item B<--api-version>
|
||||
|
||||
API version (Default: 2.4).
|
||||
|
||||
=item B<--timeout>
|
||||
|
||||
Set timeout in seconds (Default: 30).
|
||||
|
||||
=back
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
B<custom>.
|
||||
|
||||
=cut
|
@ -0,0 +1,177 @@
|
||||
#
|
||||
# Copyright 2023 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::purestorage::flashblade::v2::restapi::mode::alerts;
|
||||
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::misc;
|
||||
use centreon::plugins::statefile;
|
||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
|
||||
|
||||
sub custom_status_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return sprintf(
|
||||
"alert [component: %s] [severity: %s] %s",
|
||||
$self->{result_values}->{component_name},
|
||||
$self->{result_values}->{severity},
|
||||
centreon::plugins::misc::change_seconds(value => $self->{result_values}->{opened})
|
||||
);
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'alerts', type => 2, message_multiple => '0 alert(s) detected', display_counter_problem => { nlabel => 'alerts.detected.count', min => 0 },
|
||||
group => [ { name => 'alert', skipped_code => { -11 => 1 } } ]
|
||||
}
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{alert} = [
|
||||
{
|
||||
label => 'status',
|
||||
type => 2,
|
||||
warning_default => '%{state} ne "closed" and %{severity} =~ /warning/i',
|
||||
critical_default => '%{state} ne "closed" and %{severity} =~ /critical/i',
|
||||
set => {
|
||||
key_values => [
|
||||
{ name => 'code' },
|
||||
{ name => 'severity' }, { name => 'opened' }, { name => 'state' },
|
||||
{ name => 'component_name' }
|
||||
],
|
||||
closure_custom_output => $self->can('custom_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 => {
|
||||
'memory' => { name => 'memory' }
|
||||
});
|
||||
|
||||
$self->{statefile_cache} = centreon::plugins::statefile->new(%options);
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
if (defined($self->{option_results}->{memory})) {
|
||||
$self->{statefile_cache}->check_options(%options);
|
||||
}
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $items = $options{custom}->request(endpoint => '/alerts');
|
||||
|
||||
my $last_time;
|
||||
if (defined($self->{option_results}->{memory})) {
|
||||
$self->{statefile_cache}->read(statefile => 'purestorage_' . $self->{mode} . '_' . $options{custom}->get_connection_infos());
|
||||
$last_time = $self->{statefile_cache}->get(name => 'last_time');
|
||||
}
|
||||
|
||||
#{
|
||||
# "action": "This alert should automatically generate a support case. Please review your support case status by logging into Pure1 at https://pure1.purestorage.com/.",
|
||||
# "code": 1004,
|
||||
# "component_name": "CH1.FM1.ETH2",
|
||||
# "component_type": "hardware",
|
||||
# "created": 1643897934063,
|
||||
# "description": "An Ethernet connector's status is unhealthy. Performance or availability may be impacted. There will be daily notifications for 7 days.",
|
||||
# "flagged": true,
|
||||
# "id": "2305e017-2f4b-b67e-7d7d-6fa1d462a51d",
|
||||
# "index": 1,
|
||||
# "knowledge_base_url": "https://support.purestorage.com/?cid=Alert_1004",
|
||||
# "name": "1",
|
||||
# "notified": 1644416419364,
|
||||
# "severity": "warning",
|
||||
# "state": "closed",
|
||||
# "summary": "Ethernet connector CH1.FM1.ETH2 is unhealthy",
|
||||
# "updated": 1646819725244,
|
||||
# "variables": {
|
||||
# "EthernetConnector": "CH1.FM1.ETH2"
|
||||
# }
|
||||
#}
|
||||
|
||||
$self->{alerts}->{global} = { alert => {} };
|
||||
|
||||
my ($i, $current_time) = (1, time());
|
||||
foreach my $alert (@$items) {
|
||||
$alert->{created} /= 1000;
|
||||
|
||||
next if (defined($self->{option_results}->{memory}) && defined($last_time) && $last_time > $alert->{created});
|
||||
|
||||
next if (defined($self->{option_results}->{filter_category}) && $self->{option_results}->{filter_category} ne '' &&
|
||||
$alert->{category} !~ /$self->{option_results}->{filter_category}/);
|
||||
|
||||
my $diff_time = $current_time - $alert->{created};
|
||||
|
||||
$self->{alerts}->{global}->{alert}->{$i} = {
|
||||
%$alert,
|
||||
opened => $diff_time
|
||||
};
|
||||
$i++;
|
||||
}
|
||||
|
||||
if (defined($self->{option_results}->{memory})) {
|
||||
$self->{statefile_cache}->write(data => { last_time => $current_time });
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check alerts.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--warning-status>
|
||||
|
||||
Set warning threshold for status (Default: '%{state} ne "closed" and %{severity} =~ /warning/i')
|
||||
Can used special variables like: %{code}, %{severity}, %{opened}, %{state}, %{component_name}
|
||||
|
||||
=item B<--critical-status>
|
||||
|
||||
Set critical threshold for status (Default: '%{state} ne "closed" and %{severity} =~ /critical/i').
|
||||
Can used special variables like: %{code}, %{severity}, %{opened}, %{state}, %{component_name}
|
||||
|
||||
=item B<--memory>
|
||||
|
||||
Only check new alarms.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
@ -0,0 +1,278 @@
|
||||
#
|
||||
# Copyright 2023 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::purestorage::flashblade::v2::restapi::mode::arrays;
|
||||
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub custom_usage_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
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});
|
||||
return sprintf(
|
||||
'space 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 array_long_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "checking array '" . $options{instance_value}->{name} . "'";
|
||||
}
|
||||
|
||||
sub prefix_array_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Array '" . $options{instance_value}->{name} . "' ";
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{
|
||||
name => 'arrays', type => 3, cb_prefix_output => 'prefix_array_output', cb_long_output => 'array_long_output', indent_long_output => ' ',
|
||||
message_multiple => 'All arrays are ok',
|
||||
group => [
|
||||
{ name => 'space', type => 0, skipped_code => { -10 => 1 } },
|
||||
{ name => 'reduction', type => 0, skipped_code => { -10 => 1 } },
|
||||
{ name => 'perf', type => 0, skipped_code => { -10 => 1 } }
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{space} = [
|
||||
{ label => 'space-usage', nlabel => 'array.space.usage.bytes', set => {
|
||||
key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ],
|
||||
closure_custom_output => $self->can('custom_usage_output'),
|
||||
perfdatas => [
|
||||
{ template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1, label_extra_instance => 1 }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'space-usage-free', display_ok => 0, nlabel => 'array.space.free.bytes', set => {
|
||||
key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ],
|
||||
closure_custom_output => $self->can('custom_usage_output'),
|
||||
perfdatas => [
|
||||
{ template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1, label_extra_instance => 1 }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'space-usage-prct', display_ok => 0, nlabel => 'array.space.usage.percentage', set => {
|
||||
key_values => [ { name => 'prct_used' }, { name => 'used' }, { name => 'free' }, { name => 'prct_free' }, { name => 'total' } ],
|
||||
closure_custom_output => $self->can('custom_usage_output'),
|
||||
perfdatas => [
|
||||
{ template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1 }
|
||||
]
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{reduction} = [
|
||||
{ label => 'data-reduction', nlabel => 'array.data.reduction.count', set => {
|
||||
key_values => [ { name => 'data' } ],
|
||||
output_template => 'data reduction: %.3f',
|
||||
perfdatas => [
|
||||
{ template => '%.3f', min => 0, label_extra_instance => 1 }
|
||||
]
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{perf} = [
|
||||
{ label => 'read', nlabel => 'array.io.read.usage.bytespersecond', set => {
|
||||
key_values => [ { name => 'read_bytes' }, { name => 'name' }, { name => 'resolution' } ],
|
||||
output_template => 'read: %s %s/s',
|
||||
output_change_bytes => 1,
|
||||
closure_custom_perfdata => sub {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
nlabel => $self->{nlabel},
|
||||
unit => 'B/s',
|
||||
instances => [$self->{result_values}->{name}, $self->{result_values}->{resolution}],
|
||||
value => $self->{result_values}->{read_bytes},
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}),
|
||||
min => 0
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
{ label => 'write', nlabel => 'array.io.write.usage.bytespersecond', set => {
|
||||
key_values => [ { name => 'write_bytes' }, { name => 'name' }, { name => 'resolution' } ],
|
||||
output_template => 'write: %s %s/s',
|
||||
output_change_bytes => 1,
|
||||
closure_custom_perfdata => sub {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
nlabel => $self->{nlabel},
|
||||
unit => 'B/s',
|
||||
instances => [$self->{result_values}->{name}, $self->{result_values}->{resolution}],
|
||||
value => $self->{result_values}->{write_bytes},
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}),
|
||||
min => 0
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
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-id:s' => { name => 'filter_id' },
|
||||
'filter-name:s' => { name => 'filter_name' },
|
||||
'perf-resolution:s' => { name => 'perf_resolution' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
my $map_resolution = {
|
||||
'1s' => 1000, '30s' => 30000, '5m' => 300000,
|
||||
'30m' => 1800000, '2h' => 7200000, '8h' => 28800000,
|
||||
'24h' => 86400000
|
||||
};
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
$self->{option_results}->{perf_resolution} = '5m'
|
||||
if (!defined($self->{option_results}->{perf_resolution}) || $self->{option_results}->{perf_resolution} eq '');
|
||||
|
||||
if (!defined($map_resolution->{ $self->{option_results}->{perf_resolution} })) {
|
||||
$self->{output}->add_option_msg(short_msg => 'Unsupported --perf-resolution value. Can be: 1s, 30s, 5m, 30m, 2h, 8h, 24h');
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $items = $options{custom}->request(endpoint => '/arrays/space');
|
||||
my $perfs = $options{custom}->request(endpoint => '/arrays/performance', get_param => ['resolution=' . $map_resolution->{ $self->{option_results}->{perf_resolution} }]);
|
||||
|
||||
#{
|
||||
# "capacity": 29159353378407,
|
||||
# "id": "1dcca71d-8bca-4951-9ba5-10ca0f5744d8",
|
||||
# "name": "filer-c",
|
||||
# "parity": 1.0,
|
||||
# "space": {
|
||||
# "data_reduction": 3.808265875566517,
|
||||
# "replication": 0,
|
||||
# "shared": 2182502918574,
|
||||
# "snapshots": 0,
|
||||
# "system": 0,
|
||||
# "thin_provisioning": 0.3114475926111792,
|
||||
# "total_physical": 17760870565810,
|
||||
# "total_provisioned": 98232344510464,
|
||||
# "total_reduction": 5.5308293670898685,
|
||||
# "unique": 15578367647236,
|
||||
# "virtual": 67638117296128
|
||||
# },
|
||||
# "time": 1670839151850
|
||||
#}
|
||||
$self->{arrays} = {};
|
||||
foreach my $item (@$items) {
|
||||
next if (defined($self->{option_results}->{filter_id}) && $self->{option_results}->{filter_id} ne '' &&
|
||||
$item->{id} !~ /$self->{option_results}->{filter_id}/);
|
||||
next if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
||||
$item->{name} !~ /$self->{option_results}->{filter_name}/);
|
||||
|
||||
$self->{arrays}->{ $item->{name} } = {
|
||||
name => $item->{name},
|
||||
reduction => {
|
||||
data => $item->{space}->{data_reduction}
|
||||
},
|
||||
space => {
|
||||
total => $item->{capacity},
|
||||
used => $item->{space}->{total_physical},
|
||||
free => $item->{capacity} - $item->{space}->{total_physical},
|
||||
prct_used => $item->{space}->{total_physical} * 100 / $item->{capacity},
|
||||
prct_free => (100 - ($item->{space}->{total_physical} * 100 / $item->{capacity}))
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
foreach my $perf (@$perfs) {
|
||||
next if (!defined($self->{arrays}->{ $perf->{name} }));
|
||||
|
||||
$self->{arrays}->{ $perf->{name} }->{perf} = {
|
||||
name => $perf->{name},
|
||||
resolution => $self->{option_results}->{perf_resolution},
|
||||
read_bytes => $perf->{read_bytes_per_sec},
|
||||
write_bytes => $perf->{write_bytes_per_sec}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check arrays.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--filter-counters>
|
||||
|
||||
Only display some counters (regexp can be used).
|
||||
Example: --filter-counters='data-reduction'
|
||||
|
||||
=item B<--filter-id>
|
||||
|
||||
Filter arrays by id (can be a regexp).
|
||||
|
||||
=item B<--filter-name>
|
||||
|
||||
Filter arrays by name (can be a regexp).
|
||||
|
||||
=item B<--filter-resolution>
|
||||
|
||||
Time resolution for array performance.
|
||||
Can be: 1s, 30s, 5m, 30m, 2h, 8h, 24h (default: 5m).
|
||||
|
||||
=item B<--warning-*> B<--critical-*>
|
||||
|
||||
Thresholds.
|
||||
Can be: 'space-usage' (B), 'space-usage-free' (B), 'space-usage-prct' (%),
|
||||
'data-reduction', 'read', 'write'.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
@ -0,0 +1,63 @@
|
||||
#
|
||||
# Copyright 2022 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::purestorage::flashblade::v2::restapi::mode::components::chassis;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub load {}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "checking chassis");
|
||||
$self->{components}->{chassis} = { name => 'chassis', total => 0, skip => 0 };
|
||||
return if ($self->check_filter(section => 'chassis'));
|
||||
|
||||
foreach my $item (@{$self->{results}}) {
|
||||
next if ($item->{type} ne 'ch');
|
||||
my $instance = $item->{index};
|
||||
|
||||
next if ($self->check_filter(section => 'chassis', instance => $instance));
|
||||
$self->{components}->{chassis}->{total}++;
|
||||
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
"chassis '%s' status is %s [instance: %s]",
|
||||
$item->{name},
|
||||
$item->{status},
|
||||
$instance
|
||||
)
|
||||
);
|
||||
|
||||
my $exit = $self->get_severity(label => 'default', section => 'chassis', instance => $instance, value => $item->{status});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf(
|
||||
"Chassis '%s' status is %s", $item->{name}, $item->{status}
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
@ -0,0 +1,63 @@
|
||||
#
|
||||
# Copyright 2022 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::purestorage::flashblade::v2::restapi::mode::components::ethport;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub load {}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "checking ethport");
|
||||
$self->{components}->{ethport} = { name => 'ethport', total => 0, skip => 0 };
|
||||
return if ($self->check_filter(section => 'ethport'));
|
||||
|
||||
foreach my $item (@{$self->{results}}) {
|
||||
next if ($item->{type} ne 'eth');
|
||||
my $instance = $item->{index};
|
||||
|
||||
next if ($self->check_filter(section => 'ethport', instance => $instance));
|
||||
$self->{components}->{ethport}->{total}++;
|
||||
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
"eth port '%s' status is %s [instance: %s]",
|
||||
$item->{name},
|
||||
$item->{status},
|
||||
$instance
|
||||
)
|
||||
);
|
||||
|
||||
my $exit = $self->get_severity(label => 'default', section => 'ethport', instance => $instance, value => $item->{status});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf(
|
||||
"Eth port '%s' status is %s", $item->{name}, $item->{status}
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
@ -0,0 +1,63 @@
|
||||
#
|
||||
# Copyright 2022 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::purestorage::flashblade::v2::restapi::mode::components::fan;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub load {}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "checking fans");
|
||||
$self->{components}->{fan} = { name => 'fans', total => 0, skip => 0 };
|
||||
return if ($self->check_filter(section => 'fan'));
|
||||
|
||||
foreach my $item (@{$self->{results}}) {
|
||||
next if ($item->{type} ne 'fan');
|
||||
my $instance = defined($item->{index}) ? $item->{index} : $item->{slot};
|
||||
|
||||
next if ($self->check_filter(section => 'fan', instance => $instance));
|
||||
$self->{components}->{fan}->{total}++;
|
||||
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
"fan '%s' status is %s [instance: %s]",
|
||||
$item->{name},
|
||||
$item->{status},
|
||||
$instance
|
||||
)
|
||||
);
|
||||
|
||||
my $exit = $self->get_severity(label => 'default', section => 'fan', instance => $instance, value => $item->{status});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf(
|
||||
"Fan '%s' status is %s", $item->{name}, $item->{status}
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
@ -0,0 +1,63 @@
|
||||
#
|
||||
# Copyright 2022 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::purestorage::flashblade::v2::restapi::mode::components::fb;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub load {}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "checking flash blades");
|
||||
$self->{components}->{fb} = { name => 'fb', total => 0, skip => 0 };
|
||||
return if ($self->check_filter(section => 'fb'));
|
||||
|
||||
foreach my $item (@{$self->{results}}) {
|
||||
next if ($item->{type} ne 'fb');
|
||||
my $instance = defined($item->{index}) ? $item->{index} : $item->{slot};
|
||||
|
||||
next if ($self->check_filter(section => 'fb', instance => $instance));
|
||||
$self->{components}->{fb}->{total}++;
|
||||
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
"flash blade '%s' status is %s [instance: %s]",
|
||||
$item->{name},
|
||||
$item->{status},
|
||||
$instance
|
||||
)
|
||||
);
|
||||
|
||||
my $exit = $self->get_severity(label => 'default', section => 'fbs', instance => $instance, value => $item->{status});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf(
|
||||
"Flash blade '%s' status is %s", $item->{name}, $item->{status}
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
@ -0,0 +1,63 @@
|
||||
#
|
||||
# Copyright 2022 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::purestorage::flashblade::v2::restapi::mode::components::fm;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub load {}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "checking fabric modules");
|
||||
$self->{components}->{fm} = { name => 'fm', total => 0, skip => 0 };
|
||||
return if ($self->check_filter(section => 'fm'));
|
||||
|
||||
foreach my $item (@{$self->{results}}) {
|
||||
next if ($item->{type} ne 'fm');
|
||||
my $instance = defined($item->{index}) ? $item->{index} : $item->{slot};
|
||||
|
||||
next if ($self->check_filter(section => 'fm', instance => $instance));
|
||||
$self->{components}->{fm}->{total}++;
|
||||
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
"fabric module '%s' status is %s [instance: %s]",
|
||||
$item->{name},
|
||||
$item->{status},
|
||||
$instance
|
||||
)
|
||||
);
|
||||
|
||||
my $exit = $self->get_severity(label => 'default', section => 'fm', instance => $instance, value => $item->{status});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf(
|
||||
"Fabric module '%s' status is %s", $item->{name}, $item->{status}
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
@ -0,0 +1,63 @@
|
||||
#
|
||||
# Copyright 2022 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::purestorage::flashblade::v2::restapi::mode::components::mgmtport;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub load {}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "checking mgmtport");
|
||||
$self->{components}->{mgmtport} = { name => 'mgmtport', total => 0, skip => 0 };
|
||||
return if ($self->check_filter(section => 'mgmtport'));
|
||||
|
||||
foreach my $item (@{$self->{results}}) {
|
||||
next if ($item->{type} ne 'mgmt_port');
|
||||
my $instance = defined($item->{index}) ? $item->{index} : $item->{slot};
|
||||
|
||||
next if ($self->check_filter(section => 'mgmtport', instance => $instance));
|
||||
$self->{components}->{mgmtport}->{total}++;
|
||||
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
"mgmt port '%s' status is %s [instance: %s]",
|
||||
$item->{name},
|
||||
$item->{status},
|
||||
$instance
|
||||
)
|
||||
);
|
||||
|
||||
my $exit = $self->get_severity(label => 'default', section => 'mgmtport', instance => $instance, value => $item->{status});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf(
|
||||
"Mgmt port '%s' status is %s", $item->{name}, $item->{status}
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
@ -0,0 +1,63 @@
|
||||
#
|
||||
# Copyright 2022 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::purestorage::flashblade::v2::restapi::mode::components::psu;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub load {}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "checking power supplies");
|
||||
$self->{components}->{psu} = { name => 'psus', total => 0, skip => 0 };
|
||||
return if ($self->check_filter(section => 'psu'));
|
||||
|
||||
foreach my $item (@{$self->{results}}) {
|
||||
next if ($item->{type} ne 'pwr');
|
||||
my $instance = defined($item->{index}) ? $item->{index} : $item->{slot};
|
||||
|
||||
next if ($self->check_filter(section => 'psus', instance => $instance));
|
||||
$self->{components}->{psu}->{total}++;
|
||||
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
"power supply '%s' status is %s [instance: %s]",
|
||||
$item->{name},
|
||||
$item->{status},
|
||||
$instance
|
||||
)
|
||||
);
|
||||
|
||||
my $exit = $self->get_severity(label => 'default', section => 'psu', instance => $instance, value => $item->{status});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf(
|
||||
"Power supply '%s' status is %s", $item->{name}, $item->{status}
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
@ -0,0 +1,179 @@
|
||||
#
|
||||
# Copyright 2023 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::purestorage::flashblade::v2::restapi::mode::filesystems;
|
||||
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub custom_usage_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
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});
|
||||
return sprintf(
|
||||
'space 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 filesystem_long_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "checking filesystem '" . $options{instance_value}->{name} . "'";
|
||||
}
|
||||
|
||||
sub prefix_filesystem_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Filesystem '" . $options{instance_value}->{name} . "' ";
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{
|
||||
name => 'filesystems', type => 3, cb_prefix_output => 'prefix_filesystem_output', cb_long_output => 'filesystem_long_output', indent_long_output => ' ',
|
||||
message_multiple => 'All filesystems are ok',
|
||||
group => [
|
||||
{ name => 'space', type => 0, skipped_code => { -10 => 1 } },
|
||||
{ name => 'reduction', type => 0, skipped_code => { -10 => 1 } }
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{space} = [
|
||||
{ label => 'space-usage', nlabel => 'filesystem.space.usage.bytes', set => {
|
||||
key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ],
|
||||
closure_custom_output => $self->can('custom_usage_output'),
|
||||
perfdatas => [
|
||||
{ template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1, label_extra_instance => 1 }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'space-usage-free', display_ok => 0, nlabel => 'filesystem.space.free.bytes', set => {
|
||||
key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ],
|
||||
closure_custom_output => $self->can('custom_usage_output'),
|
||||
perfdatas => [
|
||||
{ template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1, label_extra_instance => 1 }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'space-usage-prct', display_ok => 0, nlabel => 'filesystem.space.usage.percentage', set => {
|
||||
key_values => [ { name => 'prct_used' }, { name => 'used' }, { name => 'free' }, { name => 'prct_free' }, { name => 'total' } ],
|
||||
closure_custom_output => $self->can('custom_usage_output'),
|
||||
perfdatas => [
|
||||
{ template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1 }
|
||||
]
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{reduction} = [
|
||||
{ label => 'data-reduction', nlabel => 'filesystem.data.reduction.count', set => {
|
||||
key_values => [ { name => 'data' } ],
|
||||
output_template => 'data reduction: %.3f',
|
||||
perfdatas => [
|
||||
{ template => '%.3f', min => 0, label_extra_instance => 1 }
|
||||
]
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
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-id:s' => { name => 'filter_id' },
|
||||
'filter-name:s' => { name => 'filter_name' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $items = $options{custom}->request(endpoint => '/file-systems');
|
||||
|
||||
$self->{filesystems} = {};
|
||||
foreach my $item (@$items) {
|
||||
next if (defined($self->{option_results}->{filter_id}) && $self->{option_results}->{filter_id} ne '' &&
|
||||
$item->{id} !~ /$self->{option_results}->{filter_id}/);
|
||||
next if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
||||
$item->{name} !~ /$self->{option_results}->{filter_name}/);
|
||||
|
||||
$self->{filesystems}->{ $item->{name} } = {
|
||||
name => $item->{name},
|
||||
reduction => {
|
||||
data => $item->{space}->{data_reduction}
|
||||
},
|
||||
space => {
|
||||
total => $item->{provisioned},
|
||||
used => $item->{space}->{virtual},
|
||||
free => $item->{provisioned} - $item->{space}->{virtual},
|
||||
prct_used => $item->{space}->{virtual} * 100 / $item->{provisioned},
|
||||
prct_free => (100 - ($item->{space}->{virtual} * 100 / $item->{provisioned}))
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check filesystems.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--filter-counters>
|
||||
|
||||
Only display some counters (regexp can be used).
|
||||
Example: --filter-counters='data-reduction'
|
||||
|
||||
=item B<--filter-id>
|
||||
|
||||
Filter filesystems by id (can be a regexp).
|
||||
|
||||
=item B<--filter-name>
|
||||
|
||||
Filter filesystems by name (can be a regexp).
|
||||
|
||||
=item B<--warning-*> B<--critical-*>
|
||||
|
||||
Thresholds.
|
||||
Can be: 'space-usage' (B), 'space-usage-free' (B), 'space-usage-prct' (%),
|
||||
'data-reduction'.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
@ -0,0 +1,100 @@
|
||||
#
|
||||
# Copyright 2022 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::purestorage::flashblade::v2::restapi::mode::hardware;
|
||||
|
||||
use base qw(centreon::plugins::templates::hardware);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub set_system {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{regexp_threshold_numeric_check_section_option} = '^(?:temperature)$';
|
||||
|
||||
$self->{cb_hook2} = 'api_execute';
|
||||
|
||||
$self->{thresholds} = {
|
||||
default => [
|
||||
['unhealthy', 'CRITICAL'],
|
||||
['healthy', 'OK'],
|
||||
['unused', 'OK'],
|
||||
['unknown', 'UNKNOWN'],
|
||||
['critical', 'CRITICAL'],
|
||||
['identifying', 'OK'],
|
||||
['not_installed', 'OK']
|
||||
]
|
||||
};
|
||||
|
||||
$self->{components_path} = 'storage::purestorage::flashblade::v2::restapi::mode::components';
|
||||
$self->{components_module} = ['chassis', 'ethport', 'fan', 'fb', 'fm', 'mgmtport', 'psu'];
|
||||
}
|
||||
|
||||
sub api_execute {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{results} = $options{custom}->request(endpoint => '/hardware');
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1, force_new_perfdata => 1);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check hardware.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--component>
|
||||
|
||||
Which component to check (Default: '.*').
|
||||
Can be: 'chassis', 'ethport', 'fan', 'fb', 'fm', 'mgmtport', 'psu'.
|
||||
|
||||
=item B<--filter>
|
||||
|
||||
Exclude some parts (comma seperated list) (Example: --filter=fan)
|
||||
Can also exclude specific instance: --filter=fan,1
|
||||
|
||||
=item B<--no-component>
|
||||
|
||||
Return an error if no compenents are checked.
|
||||
If total (with skipped) is 0. (Default: 'critical' returns).
|
||||
|
||||
=item B<--threshold-overload>
|
||||
|
||||
Set to overload default threshold values (syntax: section,[instance,]status,regexp)
|
||||
It used before default thresholds (order stays).
|
||||
Example: --threshold-overload='fb,WARNING,unused'
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
@ -0,0 +1,108 @@
|
||||
#
|
||||
# Copyright 2022 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::purestorage::flashblade::v2::restapi::mode::listarrays;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
}
|
||||
|
||||
my @labels = ('id', 'name', 'capacity');
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $items = $options{custom}->request(endpoint => '/arrays/space');
|
||||
|
||||
my $results = {};
|
||||
foreach my $item (@$items) {
|
||||
$results->{ $item->{id} } = {
|
||||
id => $item->{id},
|
||||
name => $item->{name},
|
||||
capacity => $item->{capacity}
|
||||
};
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $results = $self->manage_selection(custom => $options{custom});
|
||||
foreach my $instance (sort keys %$results) {
|
||||
$self->{output}->output_add(long_msg =>
|
||||
join('', map("[$_: " . $results->{$instance}->{$_} . ']', @labels))
|
||||
);
|
||||
}
|
||||
|
||||
$self->{output}->output_add(
|
||||
severity => 'OK',
|
||||
short_msg => 'List arrays:'
|
||||
);
|
||||
$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 => [@labels]);
|
||||
}
|
||||
|
||||
sub disco_show {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $results = $self->manage_selection(custom => $options{custom});
|
||||
foreach (sort keys %$results) {
|
||||
$self->{output}->add_disco_entry(
|
||||
%{$results->{$_}}
|
||||
);
|
||||
}
|
||||
}
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
List arrays.
|
||||
|
||||
=over 8
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
@ -0,0 +1,108 @@
|
||||
#
|
||||
# Copyright 2022 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::purestorage::flashblade::v2::restapi::mode::listfilesystems;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
}
|
||||
|
||||
my @labels = ('id', 'name', 'provisioned');
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $items = $options{custom}->request(endpoint => '/file-systems');
|
||||
|
||||
my $results = {};
|
||||
foreach my $item (@$items) {
|
||||
$results->{ $item->{id} } = {
|
||||
id => $item->{id},
|
||||
name => $item->{name},
|
||||
provisioned => $item->{provisioned}
|
||||
};
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $results = $self->manage_selection(custom => $options{custom});
|
||||
foreach my $instance (sort keys %$results) {
|
||||
$self->{output}->output_add(long_msg =>
|
||||
join('', map("[$_: " . $results->{$instance}->{$_} . ']', @labels))
|
||||
);
|
||||
}
|
||||
|
||||
$self->{output}->output_add(
|
||||
severity => 'OK',
|
||||
short_msg => 'List filesystems:'
|
||||
);
|
||||
$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 => [@labels]);
|
||||
}
|
||||
|
||||
sub disco_show {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $results = $self->manage_selection(custom => $options{custom});
|
||||
foreach (sort keys %$results) {
|
||||
$self->{output}->add_disco_entry(
|
||||
%{$results->{$_}}
|
||||
);
|
||||
}
|
||||
}
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
List filesystems.
|
||||
|
||||
=over 8
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
@ -0,0 +1,53 @@
|
||||
#
|
||||
# Copyright 2023 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::purestorage::flashblade::v2::restapi::plugin;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use base qw(centreon::plugins::script_custom);
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{modes} = {
|
||||
'alerts' => 'storage::purestorage::flashblade::v2::restapi::mode::alerts',
|
||||
'arrays' => 'storage::purestorage::flashblade::v2::restapi::mode::arrays',
|
||||
'filesystems' => 'storage::purestorage::flashblade::v2::restapi::mode::filesystems',
|
||||
'hardware' => 'storage::purestorage::flashblade::v2::restapi::mode::hardware',
|
||||
'list-arrays' => 'storage::purestorage::flashblade::v2::restapi::mode::listarrays',
|
||||
'list-filesystems' => 'storage::purestorage::flashblade::v2::restapi::mode::listfilesystems'
|
||||
};
|
||||
|
||||
$self->{custom_modes}->{api} = 'storage::purestorage::flashblade::v2::restapi::custom::api';
|
||||
return $self;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 PLUGIN DESCRIPTION
|
||||
|
||||
Check Pure Storage FlashBlade through HTTP/REST API v2.
|
||||
|
||||
=cut
|
Loading…
x
Reference in New Issue
Block a user