update fujitsu eternus dx modes with class counter
This commit is contained in:
parent
df2d54036e
commit
46c7f13946
|
@ -20,26 +20,37 @@
|
||||||
|
|
||||||
package storage::fujitsu::eternus::dx::ssh::mode::cpu;
|
package storage::fujitsu::eternus::dx::ssh::mode::cpu;
|
||||||
|
|
||||||
use base qw(centreon::plugins::mode);
|
use base qw(centreon::plugins::templates::counter);
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use centreon::plugins::values;
|
use centreon::plugins::misc;
|
||||||
|
|
||||||
my $maps_counters = {
|
sub set_counters {
|
||||||
cpu => {
|
my ($self, %options) = @_;
|
||||||
'001_usage' => {
|
|
||||||
set => {
|
$self->{maps_counters_type} = [
|
||||||
|
{ name => 'cpu', type => 1, cb_prefix_output => 'prefix_cpu_output', message_multiple => 'All CPUs are ok' }
|
||||||
|
];
|
||||||
|
|
||||||
|
$self->{maps_counters}->{cpu} = [
|
||||||
|
{ label => 'usage', nlabel => 'cpu.utilization.percentage', set => {
|
||||||
key_values => [ { name => 'usage' }, { name => 'display' } ],
|
key_values => [ { name => 'usage' }, { name => 'display' } ],
|
||||||
output_template => 'Usage : %d %%',
|
output_template => 'Usage : %d %%',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ label => 'cpu', value => 'usage_absolute', template => '%d',
|
{ label => 'cpu', value => 'usage_absolute', template => '%d',
|
||||||
unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' },
|
unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' },
|
||||||
],
|
],
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
}
|
];
|
||||||
};
|
}
|
||||||
|
|
||||||
|
sub prefix_cpu_output {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return "CPU '" . $options{instance_value}->{display} . "' ";
|
||||||
|
}
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
my ($class, %options) = @_;
|
my ($class, %options) = @_;
|
||||||
|
@ -47,132 +58,41 @@ sub new {
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$self->{version} = '1.0';
|
$self->{version} = '1.0';
|
||||||
$options{options}->add_options(arguments =>
|
$options{options}->add_options(arguments => {
|
||||||
{
|
"hostname:s" => { name => 'hostname' },
|
||||||
"hostname:s" => { name => 'hostname' },
|
"ssh-option:s@" => { name => 'ssh_option' },
|
||||||
"ssh-option:s@" => { name => 'ssh_option' },
|
"ssh-path:s" => { name => 'ssh_path' },
|
||||||
"ssh-path:s" => { name => 'ssh_path' },
|
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
|
||||||
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
|
"timeout:s" => { name => 'timeout', default => 30 },
|
||||||
"timeout:s" => { name => 'timeout', default => 30 },
|
"command:s" => { name => 'command', default => 'show' },
|
||||||
"command:s" => { name => 'command', default => 'show' },
|
"command-path:s" => { name => 'command_path' },
|
||||||
"command-path:s" => { name => 'command_path' },
|
"command-options:s" => { name => 'command_options', default => 'performance -type cm' },
|
||||||
"command-options:s" => { name => 'command_options', default => 'performance -type cm' },
|
"filter-name:s" => { name => 'filter_name' },
|
||||||
"no-component:s" => { name => 'no_component' },
|
});
|
||||||
"filter-name:s" => { name => 'filter_name' },
|
|
||||||
});
|
|
||||||
$self->{no_components} = undef;
|
|
||||||
|
|
||||||
foreach my $key (('cpu')) {
|
|
||||||
foreach (keys %{$maps_counters->{$key}}) {
|
|
||||||
my ($id, $name) = split /_/;
|
|
||||||
if (!defined($maps_counters->{$key}->{$_}->{threshold}) || $maps_counters->{$key}->{$_}->{threshold} != 0) {
|
|
||||||
$options{options}->add_options(arguments => {
|
|
||||||
'warning-' . $name . ':s' => { name => 'warning-' . $name },
|
|
||||||
'critical-' . $name . ':s' => { name => 'critical-' . $name },
|
|
||||||
});
|
|
||||||
}
|
|
||||||
$maps_counters->{$key}->{$_}->{obj} = centreon::plugins::values->new(output => $self->{output}, perfdata => $self->{perfdata},
|
|
||||||
label => $name);
|
|
||||||
$maps_counters->{$key}->{$_}->{obj}->set(%{$maps_counters->{$key}->{$_}->{set}});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub check_options {
|
sub check_options {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
$self->SUPER::init(%options);
|
$self->SUPER::check_options(%options);
|
||||||
|
|
||||||
if (defined($self->{option_results}->{hostname}) && $self->{option_results}->{hostname} ne '') {
|
if (defined($self->{option_results}->{hostname}) && $self->{option_results}->{hostname} ne '') {
|
||||||
$self->{option_results}->{remote} = 1;
|
$self->{option_results}->{remote} = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach my $key (('cpu')) {
|
|
||||||
foreach (keys %{$maps_counters->{$key}}) {
|
|
||||||
$maps_counters->{$key}->{$_}->{obj}->init(option_results => $self->{option_results});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (defined($self->{option_results}->{no_component})) {
|
|
||||||
if ($self->{option_results}->{no_component} ne '') {
|
|
||||||
$self->{no_components} = $self->{option_results}->{no_component};
|
|
||||||
} else {
|
|
||||||
$self->{no_components} = 'critical';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sub run {
|
|
||||||
my ($self, %options) = @_;
|
|
||||||
|
|
||||||
$self->manage_selection();
|
|
||||||
|
|
||||||
my $multiple = 1;
|
|
||||||
if (scalar(keys %{$self->{cpu}}) == 1) {
|
|
||||||
$multiple = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($multiple == 1) {
|
|
||||||
$self->{output}->output_add(severity => 'OK',
|
|
||||||
short_msg => 'All CPUs are ok');
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach my $id (sort keys %{$self->{cpu}}) {
|
|
||||||
my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', '');
|
|
||||||
my @exits = ();
|
|
||||||
foreach (sort keys %{$maps_counters->{cpu}}) {
|
|
||||||
my $obj = $maps_counters->{cpu}->{$_}->{obj};
|
|
||||||
$obj->set(instance => $id);
|
|
||||||
|
|
||||||
my ($value_check) = $obj->execute(values => $self->{cpu}->{$id});
|
|
||||||
|
|
||||||
if ($value_check != 0) {
|
|
||||||
$long_msg .= $long_msg_append . $obj->output_error();
|
|
||||||
$long_msg_append = ', ';
|
|
||||||
next;
|
|
||||||
}
|
|
||||||
my $exit2 = $obj->threshold_check();
|
|
||||||
push @exits, $exit2;
|
|
||||||
|
|
||||||
my $output = $obj->output();
|
|
||||||
$long_msg .= $long_msg_append . $output;
|
|
||||||
$long_msg_append = ', ';
|
|
||||||
|
|
||||||
if (!$self->{output}->is_status(litteral => 1, value => $exit2, compare => 'ok')) {
|
|
||||||
$short_msg .= $short_msg_append . $output;
|
|
||||||
$short_msg_append = ', ';
|
|
||||||
}
|
|
||||||
|
|
||||||
$obj->perfdata(level => 1, extra_instance => $multiple);
|
|
||||||
}
|
|
||||||
|
|
||||||
$self->{output}->output_add(long_msg => "CPU '$self->{cpu}->{$id}->{display}' $long_msg");
|
|
||||||
my $exit = $self->{output}->get_most_critical(status => [ @exits ]);
|
|
||||||
if (!$self->{output}->is_status(litteral => 1, value => $exit, compare => 'ok')) {
|
|
||||||
$self->{output}->output_add(severity => $exit,
|
|
||||||
short_msg => "CPU '$self->{cpu}->{$id}->{display}' $short_msg"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($multiple == 0) {
|
|
||||||
$self->{output}->output_add(short_msg => "CPU '$self->{cpu}->{$id}->{display}' $long_msg");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$self->{output}->display();
|
|
||||||
$self->{output}->exit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub manage_selection {
|
sub manage_selection {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my $stdout = centreon::plugins::misc::execute(output => $self->{output},
|
my $stdout = centreon::plugins::misc::execute(
|
||||||
options => $self->{option_results},
|
output => $self->{output},
|
||||||
ssh_pipe => 1,
|
options => $self->{option_results},
|
||||||
command => $self->{option_results}->{command},
|
ssh_pipe => 1,
|
||||||
command_path => $self->{option_results}->{command_path},
|
command => $self->{option_results}->{command},
|
||||||
command_options => $self->{option_results}->{command_options});
|
command_path => $self->{option_results}->{command_path},
|
||||||
|
command_options => $self->{option_results}->{command_options}
|
||||||
|
);
|
||||||
# Can have 4 columns also.
|
# Can have 4 columns also.
|
||||||
|
|
||||||
#Location Busy Rate(%) Copy Residual Quantity(MB)
|
#Location Busy Rate(%) Copy Residual Quantity(MB)
|
||||||
|
@ -191,7 +111,7 @@ sub manage_selection {
|
||||||
|
|
||||||
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
||||||
$cpu_name !~ /$self->{option_results}->{filter_name}/) {
|
$cpu_name !~ /$self->{option_results}->{filter_name}/) {
|
||||||
$self->{output}->output_add(long_msg => "Skipping '" . $cpu_name . "': no matching filter name.");
|
$self->{output}->output_add(long_msg => "skipping '" . $cpu_name . "': no matching filter name.");
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,8 +119,8 @@ sub manage_selection {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scalar(keys %{$self->{cpu}}) <= 0) {
|
if (scalar(keys %{$self->{cpu}}) <= 0) {
|
||||||
$self->{output}->output_add(severity => defined($self->{no_components}) ? $self->{no_components} : 'unknown',
|
$self->{output}->add_option_msg(short_msg => "No component found.");
|
||||||
short_msg => 'No components are checked.');
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,10 +167,6 @@ Command path (Default: none).
|
||||||
|
|
||||||
Command options (Default: 'performance -type cm').
|
Command options (Default: 'performance -type cm').
|
||||||
|
|
||||||
=item B<--no-component>
|
|
||||||
|
|
||||||
Set the threshold where no components (Default: 'unknown' returns).
|
|
||||||
|
|
||||||
=item B<--filter-name>
|
=item B<--filter-name>
|
||||||
|
|
||||||
Filter by name (regexp can be used).
|
Filter by name (regexp can be used).
|
||||||
|
|
|
@ -20,56 +20,64 @@
|
||||||
|
|
||||||
package storage::fujitsu::eternus::dx::ssh::mode::portstats;
|
package storage::fujitsu::eternus::dx::ssh::mode::portstats;
|
||||||
|
|
||||||
use base qw(centreon::plugins::mode);
|
use base qw(centreon::plugins::templates::counter);
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use centreon::plugins::values;
|
use centreon::plugins::misc;
|
||||||
|
|
||||||
my $maps_counters = {
|
sub set_counters {
|
||||||
port => {
|
my ($self, %options) = @_;
|
||||||
'000_read-iops' => {
|
|
||||||
set => {
|
$self->{maps_counters_type} = [
|
||||||
|
{ name => 'port', type => 1, cb_prefix_output => 'prefix_port_output', message_multiple => 'All ports are ok' }
|
||||||
|
];
|
||||||
|
|
||||||
|
$self->{maps_counters}->{port} = [
|
||||||
|
{ label => 'read-iops', nlabel => 'port.io.read.usage.iops', set => {
|
||||||
key_values => [ { name => 'read_iops' }, { name => 'display' } ],
|
key_values => [ { name => 'read_iops' }, { name => 'display' } ],
|
||||||
output_template => 'Read IOPS : %d',
|
output_template => 'Read IOPS : %d',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ label => 'read_iops', value => 'read_iops_absolute', template => '%d',
|
{ label => 'read_iops', value => 'read_iops_absolute', template => '%d',
|
||||||
unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' },
|
unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' },
|
||||||
],
|
],
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
'001_write-iops' => {
|
{ label => 'write-iops', nlabel => 'port.io.write.usage.iops', set => {
|
||||||
set => {
|
|
||||||
key_values => [ { name => 'write_iops' }, { name => 'display' } ],
|
key_values => [ { name => 'write_iops' }, { name => 'display' } ],
|
||||||
output_template => 'Write IOPS : %d',
|
output_template => 'Write IOPS : %d',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ label => 'write_iops', value => 'write_iops_absolute', template => '%d',
|
{ label => 'write_iops', value => 'write_iops_absolute', template => '%d',
|
||||||
unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' },
|
unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' },
|
||||||
],
|
],
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
'002_read-traffic' => {
|
{ label => 'read-traffic', nlabel => 'port.traffic.read.usage.bitspersecond', set => {
|
||||||
set => {
|
|
||||||
key_values => [ { name => 'read_traffic' }, { name => 'display' } ],
|
key_values => [ { name => 'read_traffic' }, { name => 'display' } ],
|
||||||
output_template => 'Read Traffic : %s %s/s', output_change_bytes => 2,
|
output_template => 'Read Traffic : %s %s/s', output_change_bytes => 2,
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ label => 'read_traffic', value => 'read_traffic_absolute', template => '%d',
|
{ label => 'read_traffic', value => 'read_traffic_absolute', template => '%d',
|
||||||
unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' },
|
unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' },
|
||||||
],
|
],
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
'003_write-traffic' => {
|
{ label => 'write-traffic', nlabel => 'port.traffic.write.usage.bitspersecond', set => {
|
||||||
set => {
|
|
||||||
key_values => [ { name => 'write_traffic' }, { name => 'display' } ],
|
key_values => [ { name => 'write_traffic' }, { name => 'display' } ],
|
||||||
output_template => 'Write Traffic : %s %s/s', output_change_bytes => 2,
|
output_template => 'Write Traffic : %s %s/s', output_change_bytes => 2,
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ label => 'write_traffic', value => 'write_traffic_absolute', template => '%d',
|
{ label => 'write_traffic', value => 'write_traffic_absolute', template => '%d',
|
||||||
unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' },
|
unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' },
|
||||||
],
|
],
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
}
|
];
|
||||||
};
|
}
|
||||||
|
|
||||||
|
sub prefix_port_output {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return "Port '" . $options{instance_value}->{display} . "' ";
|
||||||
|
}
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
my ($class, %options) = @_;
|
my ($class, %options) = @_;
|
||||||
|
@ -77,132 +85,41 @@ sub new {
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$self->{version} = '1.0';
|
$self->{version} = '1.0';
|
||||||
$options{options}->add_options(arguments =>
|
$options{options}->add_options(arguments => {
|
||||||
{
|
"hostname:s" => { name => 'hostname' },
|
||||||
"hostname:s" => { name => 'hostname' },
|
"ssh-option:s@" => { name => 'ssh_option' },
|
||||||
"ssh-option:s@" => { name => 'ssh_option' },
|
"ssh-path:s" => { name => 'ssh_path' },
|
||||||
"ssh-path:s" => { name => 'ssh_path' },
|
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
|
||||||
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
|
"timeout:s" => { name => 'timeout', default => 30 },
|
||||||
"timeout:s" => { name => 'timeout', default => 30 },
|
"command:s" => { name => 'command', default => 'show' },
|
||||||
"command:s" => { name => 'command', default => 'show' },
|
"command-path:s" => { name => 'command_path' },
|
||||||
"command-path:s" => { name => 'command_path' },
|
"command-options:s" => { name => 'command_options', default => 'performance -type port' },
|
||||||
"command-options:s" => { name => 'command_options', default => 'performance -type port' },
|
"filter-name:s" => { name => 'filter_name' },
|
||||||
"no-component:s" => { name => 'no_component' },
|
});
|
||||||
"filter-name:s" => { name => 'filter_name' },
|
|
||||||
});
|
|
||||||
$self->{no_components} = undef;
|
|
||||||
|
|
||||||
foreach my $key (('port')) {
|
|
||||||
foreach (keys %{$maps_counters->{$key}}) {
|
|
||||||
my ($id, $name) = split /_/;
|
|
||||||
if (!defined($maps_counters->{$key}->{$_}->{threshold}) || $maps_counters->{$key}->{$_}->{threshold} != 0) {
|
|
||||||
$options{options}->add_options(arguments => {
|
|
||||||
'warning-' . $name . ':s' => { name => 'warning-' . $name },
|
|
||||||
'critical-' . $name . ':s' => { name => 'critical-' . $name },
|
|
||||||
});
|
|
||||||
}
|
|
||||||
$maps_counters->{$key}->{$_}->{obj} = centreon::plugins::values->new(output => $self->{output}, perfdata => $self->{perfdata},
|
|
||||||
label => $name);
|
|
||||||
$maps_counters->{$key}->{$_}->{obj}->set(%{$maps_counters->{$key}->{$_}->{set}});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub check_options {
|
sub check_options {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
$self->SUPER::init(%options);
|
$self->SUPER::check_options(%options);
|
||||||
|
|
||||||
if (defined($self->{option_results}->{hostname}) && $self->{option_results}->{hostname} ne '') {
|
if (defined($self->{option_results}->{hostname}) && $self->{option_results}->{hostname} ne '') {
|
||||||
$self->{option_results}->{remote} = 1;
|
$self->{option_results}->{remote} = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach my $key (('port')) {
|
|
||||||
foreach (keys %{$maps_counters->{$key}}) {
|
|
||||||
$maps_counters->{$key}->{$_}->{obj}->init(option_results => $self->{option_results});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (defined($self->{option_results}->{no_component})) {
|
|
||||||
if ($self->{option_results}->{no_component} ne '') {
|
|
||||||
$self->{no_components} = $self->{option_results}->{no_component};
|
|
||||||
} else {
|
|
||||||
$self->{no_components} = 'critical';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sub run {
|
|
||||||
my ($self, %options) = @_;
|
|
||||||
|
|
||||||
$self->manage_selection();
|
|
||||||
|
|
||||||
my $multiple = 1;
|
|
||||||
if (scalar(keys %{$self->{port}}) == 1) {
|
|
||||||
$multiple = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($multiple == 1) {
|
|
||||||
$self->{output}->output_add(severity => 'OK',
|
|
||||||
short_msg => 'All Ports are ok');
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach my $id (sort keys %{$self->{port}}) {
|
|
||||||
my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', '');
|
|
||||||
my @exits = ();
|
|
||||||
foreach (sort keys %{$maps_counters->{port}}) {
|
|
||||||
my $obj = $maps_counters->{port}->{$_}->{obj};
|
|
||||||
$obj->set(instance => $id);
|
|
||||||
|
|
||||||
my ($value_check) = $obj->execute(values => $self->{port}->{$id});
|
|
||||||
|
|
||||||
if ($value_check != 0) {
|
|
||||||
$long_msg .= $long_msg_append . $obj->output_error();
|
|
||||||
$long_msg_append = ', ';
|
|
||||||
next;
|
|
||||||
}
|
|
||||||
my $exit2 = $obj->threshold_check();
|
|
||||||
push @exits, $exit2;
|
|
||||||
|
|
||||||
my $output = $obj->output();
|
|
||||||
$long_msg .= $long_msg_append . $output;
|
|
||||||
$long_msg_append = ', ';
|
|
||||||
|
|
||||||
if (!$self->{output}->is_status(litteral => 1, value => $exit2, compare => 'ok')) {
|
|
||||||
$short_msg .= $short_msg_append . $output;
|
|
||||||
$short_msg_append = ', ';
|
|
||||||
}
|
|
||||||
|
|
||||||
$obj->perfdata(level => 1, extra_instance => $multiple);
|
|
||||||
}
|
|
||||||
|
|
||||||
$self->{output}->output_add(long_msg => "Port '$self->{port}->{$id}->{display}' $long_msg");
|
|
||||||
my $exit = $self->{output}->get_most_critical(status => [ @exits ]);
|
|
||||||
if (!$self->{output}->is_status(litteral => 1, value => $exit, compare => 'ok')) {
|
|
||||||
$self->{output}->output_add(severity => $exit,
|
|
||||||
short_msg => "Port '$self->{port}->{$id}->{display}' $short_msg"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($multiple == 0) {
|
|
||||||
$self->{output}->output_add(short_msg => "Port '$self->{port}->{$id}->{display}' $long_msg");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$self->{output}->display();
|
|
||||||
$self->{output}->exit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub manage_selection {
|
sub manage_selection {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my $stdout = centreon::plugins::misc::execute(output => $self->{output},
|
my $stdout = centreon::plugins::misc::execute(
|
||||||
options => $self->{option_results},
|
output => $self->{output},
|
||||||
ssh_pipe => 1,
|
options => $self->{option_results},
|
||||||
command => $self->{option_results}->{command},
|
ssh_pipe => 1,
|
||||||
command_path => $self->{option_results}->{command_path},
|
command => $self->{option_results}->{command},
|
||||||
command_options => $self->{option_results}->{command_options});
|
command_path => $self->{option_results}->{command_path},
|
||||||
|
command_options => $self->{option_results}->{command_options}
|
||||||
|
);
|
||||||
|
|
||||||
#Location IOPS(IOPS) Throughput(MB/s)
|
#Location IOPS(IOPS) Throughput(MB/s)
|
||||||
# Read / Write Read / Write
|
# Read / Write Read / Write
|
||||||
|
@ -221,16 +138,17 @@ sub manage_selection {
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{port}->{$port_name} = { display => $port_name,
|
$self->{port}->{$port_name} = {
|
||||||
read_iops => $port_read_iops, write_iops => $port_write_iops,
|
display => $port_name,
|
||||||
read_traffic => $port_read_traffic * 1000 * 1000 * 8,
|
read_iops => $port_read_iops, write_iops => $port_write_iops,
|
||||||
write_traffic => $port_write_traffic * 1000 * 1000 * 8
|
read_traffic => $port_read_traffic * 1000 * 1000 * 8,
|
||||||
};
|
write_traffic => $port_write_traffic * 1000 * 1000 * 8
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scalar(keys %{$self->{port}}) <= 0) {
|
if (scalar(keys %{$self->{port}}) <= 0) {
|
||||||
$self->{output}->output_add(severity => defined($self->{no_components}) ? $self->{no_components} : 'unknown',
|
$self->{output}->add_option_msg(short_msg => "No port found.");
|
||||||
short_msg => 'No components are checked.');
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,10 +195,6 @@ Command path (Default: none).
|
||||||
|
|
||||||
Command options (Default: 'performance -type port').
|
Command options (Default: 'performance -type port').
|
||||||
|
|
||||||
=item B<--no-component>
|
|
||||||
|
|
||||||
Set the threshold where no components (Default: 'unknown' returns).
|
|
||||||
|
|
||||||
=item B<--filter-name>
|
=item B<--filter-name>
|
||||||
|
|
||||||
Filter by name (regexp can be used).
|
Filter by name (regexp can be used).
|
||||||
|
|
|
@ -20,48 +20,16 @@
|
||||||
|
|
||||||
package storage::fujitsu::eternus::dx::ssh::mode::raidgroups;
|
package storage::fujitsu::eternus::dx::ssh::mode::raidgroups;
|
||||||
|
|
||||||
use base qw(centreon::plugins::mode);
|
use base qw(centreon::plugins::templates::counter);
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use centreon::plugins::values;
|
use centreon::plugins::misc;
|
||||||
|
|
||||||
my $thresholds = {
|
|
||||||
rg => [
|
|
||||||
['Available', 'OK'],
|
|
||||||
['Spare in Use', 'WARNING'],
|
|
||||||
],
|
|
||||||
};
|
|
||||||
my $instance_mode;
|
|
||||||
|
|
||||||
my $maps_counters = {
|
|
||||||
rg => {
|
|
||||||
'000_status' => {
|
|
||||||
set => { threshold => 0,
|
|
||||||
key_values => [ { name => 'status' } ],
|
|
||||||
closure_custom_calc => \&custom_status_calc,
|
|
||||||
output_template => 'Status : %s', output_error_template => 'Status : %s',
|
|
||||||
output_use => 'status',
|
|
||||||
closure_custom_perfdata => sub { return 0; },
|
|
||||||
closure_custom_threshold_check => \&custom_threshold_output,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'001_usage' => {
|
|
||||||
set => {
|
|
||||||
key_values => [ { name => 'display' }, { name => 'total' }, { name => 'used' } ],
|
|
||||||
closure_custom_calc => \&custom_usage_calc,
|
|
||||||
closure_custom_output => \&custom_usage_output,
|
|
||||||
closure_custom_perfdata => \&custom_usage_perfdata,
|
|
||||||
closure_custom_threshold_check => \&custom_usage_threshold,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
sub custom_threshold_output {
|
sub custom_threshold_output {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
return $instance_mode->get_severity(section => 'rg', value => $self->{result_values}->{status});
|
return $self->{instance_mode}->get_severity(section => 'rg', value => $self->{result_values}->{status});
|
||||||
}
|
}
|
||||||
|
|
||||||
sub custom_status_calc {
|
sub custom_status_calc {
|
||||||
|
@ -74,21 +42,21 @@ sub custom_status_calc {
|
||||||
sub custom_usage_perfdata {
|
sub custom_usage_perfdata {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my $extra_label = '';
|
$self->{output}->perfdata_add(
|
||||||
if (!defined($options{extra_instance}) || $options{extra_instance} != 0) {
|
label => 'used', unit => 'B',
|
||||||
$extra_label .= '_' . $self->{result_values}->{display};
|
nlabel => $self->{nlabel},
|
||||||
}
|
instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef,
|
||||||
$self->{output}->perfdata_add(label => 'used' . $extra_label, unit => 'B',
|
value => $self->{result_values}->{used},
|
||||||
value => $self->{result_values}->{used},
|
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}, total => $self->{result_values}->{total}, cast_int => 1),
|
||||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, total => $self->{result_values}->{total}, cast_int => 1),
|
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}, total => $self->{result_values}->{total}, cast_int => 1),
|
||||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, total => $self->{result_values}->{total}, cast_int => 1),
|
min => 0, max => $self->{result_values}->{total}
|
||||||
min => 0, max => $self->{result_values}->{total});
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub custom_usage_threshold {
|
sub custom_usage_threshold {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my $exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{prct_used}, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{label}, exit_litteral => 'warning' } ]);
|
my $exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{prct_used}, threshold => [ { label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{thlabel}, exit_litteral => 'warning' } ]);
|
||||||
return $exit;
|
return $exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,62 +86,71 @@ sub custom_usage_calc {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub set_counters {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
$self->{maps_counters_type} = [
|
||||||
|
{ name => 'rg', type => 1, cb_prefix_output => 'prefix_rg_output', message_multiple => 'All raid groups are ok' }
|
||||||
|
];
|
||||||
|
|
||||||
|
$self->{maps_counters}->{rg} = [
|
||||||
|
{ label => 'status', threshold => 0, set => {
|
||||||
|
key_values => [ { name => 'status' } ],
|
||||||
|
closure_custom_calc => $self->can('custom_status_calc'),
|
||||||
|
output_template => 'Status : %s', output_error_template => 'Status : %s',
|
||||||
|
output_use => 'status',
|
||||||
|
closure_custom_perfdata => sub { return 0; },
|
||||||
|
closure_custom_threshold_check => $self->can('custom_threshold_output'),
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'usage', nlabel => 'raidgroup.space.usage.bytes', set => {
|
||||||
|
key_values => [ { name => 'display' }, { name => 'total' }, { name => 'used' } ],
|
||||||
|
closure_custom_calc => $self->can('custom_usage_calc'),
|
||||||
|
closure_custom_output => $self->can('custom_usage_output'),
|
||||||
|
closure_custom_perfdata => $self->can('custom_usage_perfdata'),
|
||||||
|
closure_custom_threshold_check => $self->can('custom_usage_threshold'),
|
||||||
|
}
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
sub prefix_rg_output {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return "Raid Group '" . $options{instance_value}->{display} . "' ";
|
||||||
|
}
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
my ($class, %options) = @_;
|
my ($class, %options) = @_;
|
||||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$self->{version} = '1.0';
|
$self->{version} = '1.0';
|
||||||
$options{options}->add_options(arguments =>
|
$options{options}->add_options(arguments => {
|
||||||
{
|
"hostname:s" => { name => 'hostname' },
|
||||||
"hostname:s" => { name => 'hostname' },
|
"ssh-option:s@" => { name => 'ssh_option' },
|
||||||
"ssh-option:s@" => { name => 'ssh_option' },
|
"ssh-path:s" => { name => 'ssh_path' },
|
||||||
"ssh-path:s" => { name => 'ssh_path' },
|
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
|
||||||
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
|
"timeout:s" => { name => 'timeout', default => 30 },
|
||||||
"timeout:s" => { name => 'timeout', default => 30 },
|
"command:s" => { name => 'command', default => 'show' },
|
||||||
"command:s" => { name => 'command', default => 'show' },
|
"command-path:s" => { name => 'command_path' },
|
||||||
"command-path:s" => { name => 'command_path' },
|
"command-options:s" => { name => 'command_options', default => 'raid-groups -csv' },
|
||||||
"command-options:s" => { name => 'command_options', default => 'raid-groups -csv' },
|
"threshold-overload:s@" => { name => 'threshold_overload' },
|
||||||
"threshold-overload:s@" => { name => 'threshold_overload' },
|
"filter-name:s" => { name => 'filter_name' },
|
||||||
"no-component:s" => { name => 'no_component' },
|
"filter-level:s" => { name => 'filter_level' },
|
||||||
"filter-name:s" => { name => 'filter_name' },
|
});
|
||||||
"filter-level:s" => { name => 'filter_level' },
|
|
||||||
});
|
|
||||||
$self->{no_components} = undef;
|
|
||||||
|
|
||||||
foreach my $key (('rg')) {
|
|
||||||
foreach (keys %{$maps_counters->{$key}}) {
|
|
||||||
my ($id, $name) = split /_/;
|
|
||||||
if (!defined($maps_counters->{$key}->{$_}->{threshold}) || $maps_counters->{$key}->{$_}->{threshold} != 0) {
|
|
||||||
$options{options}->add_options(arguments => {
|
|
||||||
'warning-' . $name . ':s' => { name => 'warning-' . $name },
|
|
||||||
'critical-' . $name . ':s' => { name => 'critical-' . $name },
|
|
||||||
});
|
|
||||||
}
|
|
||||||
$maps_counters->{$key}->{$_}->{obj} = centreon::plugins::values->new(output => $self->{output}, perfdata => $self->{perfdata},
|
|
||||||
label => $name);
|
|
||||||
$maps_counters->{$key}->{$_}->{obj}->set(%{$maps_counters->{$key}->{$_}->{set}});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub check_options {
|
sub check_options {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
$self->SUPER::init(%options);
|
$self->SUPER::check_options(%options);
|
||||||
|
|
||||||
if (defined($self->{option_results}->{hostname}) && $self->{option_results}->{hostname} ne '') {
|
if (defined($self->{option_results}->{hostname}) && $self->{option_results}->{hostname} ne '') {
|
||||||
$self->{option_results}->{remote} = 1;
|
$self->{option_results}->{remote} = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach my $key (('rg')) {
|
|
||||||
foreach (keys %{$maps_counters->{$key}}) {
|
|
||||||
$maps_counters->{$key}->{$_}->{obj}->init(option_results => $self->{option_results});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$instance_mode = $self;
|
|
||||||
|
|
||||||
$self->{overload_th} = {};
|
$self->{overload_th} = {};
|
||||||
foreach my $val (@{$self->{option_results}->{threshold_overload}}) {
|
foreach my $val (@{$self->{option_results}->{threshold_overload}}) {
|
||||||
if ($val !~ /^(.*?),(.*?),(.*)$/) {
|
if ($val !~ /^(.*?),(.*?),(.*)$/) {
|
||||||
|
@ -188,86 +165,19 @@ sub check_options {
|
||||||
$self->{overload_th}->{$section} = [] if (!defined($self->{overload_th}->{$section}));
|
$self->{overload_th}->{$section} = [] if (!defined($self->{overload_th}->{$section}));
|
||||||
push @{$self->{overload_th}->{$section}}, {filter => $filter, status => $status};
|
push @{$self->{overload_th}->{$section}}, {filter => $filter, status => $status};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (defined($self->{option_results}->{no_component})) {
|
|
||||||
if ($self->{option_results}->{no_component} ne '') {
|
|
||||||
$self->{no_components} = $self->{option_results}->{no_component};
|
|
||||||
} else {
|
|
||||||
$self->{no_components} = 'critical';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sub run {
|
|
||||||
my ($self, %options) = @_;
|
|
||||||
|
|
||||||
$self->manage_selection();
|
|
||||||
|
|
||||||
my $multiple = 1;
|
|
||||||
if (scalar(keys %{$self->{rg}}) == 1) {
|
|
||||||
$multiple = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($multiple == 1) {
|
|
||||||
$self->{output}->output_add(severity => 'OK',
|
|
||||||
short_msg => 'All Raid Groups are ok');
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach my $id (sort keys %{$self->{rg}}) {
|
|
||||||
my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', '');
|
|
||||||
my @exits = ();
|
|
||||||
foreach (sort keys %{$maps_counters->{rg}}) {
|
|
||||||
my $obj = $maps_counters->{rg}->{$_}->{obj};
|
|
||||||
$obj->set(instance => $id);
|
|
||||||
|
|
||||||
my ($value_check) = $obj->execute(values => $self->{rg}->{$id});
|
|
||||||
|
|
||||||
if ($value_check != 0) {
|
|
||||||
$long_msg .= $long_msg_append . $obj->output_error();
|
|
||||||
$long_msg_append = ', ';
|
|
||||||
next;
|
|
||||||
}
|
|
||||||
my $exit2 = $obj->threshold_check();
|
|
||||||
push @exits, $exit2;
|
|
||||||
|
|
||||||
my $output = $obj->output();
|
|
||||||
$long_msg .= $long_msg_append . $output;
|
|
||||||
$long_msg_append = ', ';
|
|
||||||
|
|
||||||
if (!$self->{output}->is_status(litteral => 1, value => $exit2, compare => 'ok')) {
|
|
||||||
$short_msg .= $short_msg_append . $output;
|
|
||||||
$short_msg_append = ', ';
|
|
||||||
}
|
|
||||||
|
|
||||||
$obj->perfdata(level => 1, extra_instance => $multiple);
|
|
||||||
}
|
|
||||||
|
|
||||||
$self->{output}->output_add(long_msg => "Raid Group '$self->{rg}->{$id}->{display}' $long_msg");
|
|
||||||
my $exit = $self->{output}->get_most_critical(status => [ @exits ]);
|
|
||||||
if (!$self->{output}->is_status(litteral => 1, value => $exit, compare => 'ok')) {
|
|
||||||
$self->{output}->output_add(severity => $exit,
|
|
||||||
short_msg => "Raid Group '$self->{rg}->{$id}->{display}' $short_msg"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($multiple == 0) {
|
|
||||||
$self->{output}->output_add(short_msg => "Raid Group '$self->{rg}->{$id}->{display}' $long_msg");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$self->{output}->display();
|
|
||||||
$self->{output}->exit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub manage_selection {
|
sub manage_selection {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my $stdout = centreon::plugins::misc::execute(output => $self->{output},
|
my $stdout = centreon::plugins::misc::execute(
|
||||||
options => $self->{option_results},
|
output => $self->{output},
|
||||||
ssh_pipe => 1,
|
options => $self->{option_results},
|
||||||
command => $self->{option_results}->{command},
|
ssh_pipe => 1,
|
||||||
command_path => $self->{option_results}->{command_path},
|
command => $self->{option_results}->{command},
|
||||||
command_options => $self->{option_results}->{command_options});
|
command_path => $self->{option_results}->{command_path},
|
||||||
|
command_options => $self->{option_results}->{command_options}
|
||||||
|
);
|
||||||
|
|
||||||
#[RAID Group No.],[RAID Group Name],[RAID Level],[Assigned CM],[Status],[Total Capacity(MB)],[Free Capacity(MB)]
|
#[RAID Group No.],[RAID Group Name],[RAID Level],[Assigned CM],[Status],[Total Capacity(MB)],[Free Capacity(MB)]
|
||||||
#1,RAIDGROUP001,RAID1+0,CM#0,Spare in Use,134656,132535
|
#1,RAIDGROUP001,RAID1+0,CM#0,Spare in Use,134656,132535
|
||||||
|
@ -290,17 +200,26 @@ sub manage_selection {
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{rg}->{$raid_num} = { status => $raid_status, total => $raid_total * 1024 * 1024,
|
$self->{rg}->{$raid_num} = {
|
||||||
used => ($raid_total * 1024 * 1024) - ($raid_free * 1024 * 1024),
|
status => $raid_status, total => $raid_total * 1024 * 1024,
|
||||||
display => $raid_name };
|
used => ($raid_total * 1024 * 1024) - ($raid_free * 1024 * 1024),
|
||||||
|
display => $raid_name
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scalar(keys %{$self->{rg}}) <= 0) {
|
if (scalar(keys %{$self->{rg}}) <= 0) {
|
||||||
$self->{output}->output_add(severity => defined($self->{no_components}) ? $self->{no_components} : 'unknown',
|
$self->{output}->add_option_msg(short_msg => "No raid group found.");
|
||||||
short_msg => 'No components are checked.');
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
my $thresholds = {
|
||||||
|
rg => [
|
||||||
|
['Available', 'OK'],
|
||||||
|
['Spare in Use', 'WARNING'],
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
sub get_severity {
|
sub get_severity {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
my $status = 'UNKNOWN'; # default
|
my $status = 'UNKNOWN'; # default
|
||||||
|
@ -372,10 +291,6 @@ Set to overload default threshold values (syntax: section,status,regexp)
|
||||||
It used before default thresholds (order stays).
|
It used before default thresholds (order stays).
|
||||||
Example: --threshold-overload='rg,CRITICAL,^(?!(Available|Spare)$)'
|
Example: --threshold-overload='rg,CRITICAL,^(?!(Available|Spare)$)'
|
||||||
|
|
||||||
=item B<--no-component>
|
|
||||||
|
|
||||||
Set the threshold where no components (Default: 'unknown' returns).
|
|
||||||
|
|
||||||
=item B<--filter-name>
|
=item B<--filter-name>
|
||||||
|
|
||||||
Filter by name (regexp can be used).
|
Filter by name (regexp can be used).
|
||||||
|
|
|
@ -20,116 +20,118 @@
|
||||||
|
|
||||||
package storage::fujitsu::eternus::dx::ssh::mode::volumestats;
|
package storage::fujitsu::eternus::dx::ssh::mode::volumestats;
|
||||||
|
|
||||||
use base qw(centreon::plugins::mode);
|
use base qw(centreon::plugins::templates::counter);
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use centreon::plugins::values;
|
use centreon::plugins::misc;
|
||||||
|
|
||||||
my $maps_counters = {
|
sub set_counters {
|
||||||
vol => {
|
my ($self, %options) = @_;
|
||||||
'000_read-iops' => {
|
|
||||||
set => {
|
$self->{maps_counters_type} = [
|
||||||
|
{ name => 'volume', type => 1, cb_prefix_output => 'prefix_volume_output', message_multiple => 'All Volumes are ok' }
|
||||||
|
];
|
||||||
|
|
||||||
|
$self->{maps_counters}->{volume} = [
|
||||||
|
{ label => 'read-iops', nlabel => 'volume.io.read.usage.iops', set => {
|
||||||
key_values => [ { name => 'read_iops' }, { name => 'display' } ],
|
key_values => [ { name => 'read_iops' }, { name => 'display' } ],
|
||||||
output_template => 'Read IOPS : %d',
|
output_template => 'Read IOPS : %d',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ label => 'read_iops', value => 'read_iops_absolute', template => '%d',
|
{ label => 'read_iops', value => 'read_iops_absolute', template => '%d',
|
||||||
unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' },
|
unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' },
|
||||||
],
|
],
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
'001_write-iops' => {
|
{ label => 'write-iops', nlabel => 'volume.io.write.usage.iops', set => {
|
||||||
set => {
|
|
||||||
key_values => [ { name => 'write_iops' }, { name => 'display' } ],
|
key_values => [ { name => 'write_iops' }, { name => 'display' } ],
|
||||||
output_template => 'Write IOPS : %d',
|
output_template => 'Write IOPS : %d',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ label => 'write_iops', value => 'write_iops_absolute', template => '%d',
|
{ label => 'write_iops', value => 'write_iops_absolute', template => '%d',
|
||||||
unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' },
|
unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' },
|
||||||
],
|
],
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
'002_read-traffic' => {
|
{ label => 'read-traffic', nlabel => 'volume.traffic.read.usage.bitspersecond', set => {
|
||||||
set => {
|
|
||||||
key_values => [ { name => 'read_throughput' }, { name => 'display' } ],
|
key_values => [ { name => 'read_throughput' }, { name => 'display' } ],
|
||||||
output_template => 'Read Traffic : %s %s/s', output_change_bytes => 2,
|
output_template => 'Read Traffic : %s %s/s', output_change_bytes => 2,
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ label => 'read_throughput', value => 'read_throughput_absolute', template => '%d',
|
{ label => 'read_throughput', value => 'read_throughput_absolute', template => '%d',
|
||||||
unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' },
|
unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' },
|
||||||
],
|
],
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
'003_write-traffic' => {
|
{ label => 'write-traffic', nlabel => 'volume.traffic.write.usage.bitspersecond', set => {
|
||||||
set => {
|
|
||||||
key_values => [ { name => 'write_throughput' }, { name => 'display' } ],
|
key_values => [ { name => 'write_throughput' }, { name => 'display' } ],
|
||||||
output_template => 'Write Traffic : %s %s/s', output_change_bytes => 2,
|
output_template => 'Write Traffic : %s %s/s', output_change_bytes => 2,
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ label => 'write_throughput', value => 'write_throughput_absolute', template => '%d',
|
{ label => 'write_throughput', value => 'write_throughput_absolute', template => '%d',
|
||||||
unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' },
|
unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' },
|
||||||
],
|
],
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
'004_read-response-time' => {
|
{ label => 'read-response-time', nlabel => 'volume.io.read.time.response.milliseconds', set => {
|
||||||
set => {
|
|
||||||
key_values => [ { name => 'read_response_time' }, { name => 'display' } ],
|
key_values => [ { name => 'read_response_time' }, { name => 'display' } ],
|
||||||
output_template => 'Read Response Time : %d ms',
|
output_template => 'Read Response Time : %d ms',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ label => 'read_response_time', value => 'read_response_time_absolute', template => '%d',
|
{ label => 'read_response_time', value => 'read_response_time_absolute', template => '%d',
|
||||||
unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' },
|
unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' },
|
||||||
],
|
],
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
'005_write-response-time' => {
|
{ label => 'write-response-time', nlabel => 'volume.io.write.time.response.milliseconds', set => {
|
||||||
set => {
|
|
||||||
key_values => [ { name => 'write_response_time' }, { name => 'display' } ],
|
key_values => [ { name => 'write_response_time' }, { name => 'display' } ],
|
||||||
output_template => 'Write Response Time : %d ms',
|
output_template => 'Write Response Time : %d ms',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ label => 'write_response_time', value => 'write_response_time_absolute', template => '%d',
|
{ label => 'write_response_time', value => 'write_response_time_absolute', template => '%d',
|
||||||
unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' },
|
unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' },
|
||||||
],
|
],
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
'006_read-processing-time' => {
|
{ label => 'read-processing-time', nlabel => 'volume.io.read.time.processing.milliseconds', set => {
|
||||||
set => {
|
|
||||||
key_values => [ { name => 'read_processing_time' }, { name => 'display' } ],
|
key_values => [ { name => 'read_processing_time' }, { name => 'display' } ],
|
||||||
output_template => 'Read Processing Time : %d ms',
|
output_template => 'Read Processing Time : %d ms',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ label => 'read_processing_time', value => 'read_processing_time_absolute', template => '%d',
|
{ label => 'read_processing_time', value => 'read_processing_time_absolute', template => '%d',
|
||||||
unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' },
|
unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' },
|
||||||
],
|
],
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
'007_write-processing-time' => {
|
{ label => 'write-processing-time', nlabel => 'volume.io.write.time.processing.milliseconds', set => {
|
||||||
set => {
|
|
||||||
key_values => [ { name => 'write_processing_time' }, { name => 'display' } ],
|
key_values => [ { name => 'write_processing_time' }, { name => 'display' } ],
|
||||||
output_template => 'Write Processing Time : %d ms',
|
output_template => 'Write Processing Time : %d ms',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ label => 'write_processing_time', value => 'write_processing_time_absolute', template => '%d',
|
{ label => 'write_processing_time', value => 'write_processing_time_absolute', template => '%d',
|
||||||
unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' },
|
unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' },
|
||||||
],
|
],
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
'008_read-cache-hit-rate' => {
|
{ label => 'read-cache-hit-rate', nlabel => 'volume.io.read.cache.hits.percentage', set => {
|
||||||
set => {
|
|
||||||
key_values => [ { name => 'read_cache_hit_rate' }, { name => 'display' } ],
|
key_values => [ { name => 'read_cache_hit_rate' }, { name => 'display' } ],
|
||||||
output_template => 'Read Cache Hit Rate : %d %%',
|
output_template => 'Read Cache Hit Rate : %d %%',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ label => 'read_cache_hit_rate', value => 'read_cache_hit_rate_absolute', template => '%d',
|
{ label => 'read_cache_hit_rate', value => 'read_cache_hit_rate_absolute', template => '%d',
|
||||||
unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' },
|
unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' },
|
||||||
],
|
],
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
'009_write-cache-hit-rate' => {
|
{ label => 'write-cache-hit-rate', nlabel => 'volume.io.write.cache.hits.percentage', set => {
|
||||||
set => {
|
|
||||||
key_values => [ { name => 'write_cache_hit_rate' }, { name => 'display' } ],
|
key_values => [ { name => 'write_cache_hit_rate' }, { name => 'display' } ],
|
||||||
output_template => 'Write Cache Hit Rate : %d %%',
|
output_template => 'Write Cache Hit Rate : %d %%',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ label => 'write_cache_hit_rate', value => 'write_cache_hit_rate_absolute', template => '%d',
|
{ label => 'write_cache_hit_rate', value => 'write_cache_hit_rate_absolute', template => '%d',
|
||||||
unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' },
|
unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' },
|
||||||
],
|
],
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
}
|
];
|
||||||
};
|
}
|
||||||
|
|
||||||
|
sub prefix_volume_output {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return "Volume '" . $options{instance_value}->{display} . "' ";
|
||||||
|
}
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
my ($class, %options) = @_;
|
my ($class, %options) = @_;
|
||||||
|
@ -137,132 +139,41 @@ sub new {
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$self->{version} = '1.0';
|
$self->{version} = '1.0';
|
||||||
$options{options}->add_options(arguments =>
|
$options{options}->add_options(arguments => {
|
||||||
{
|
"hostname:s" => { name => 'hostname' },
|
||||||
"hostname:s" => { name => 'hostname' },
|
"ssh-option:s@" => { name => 'ssh_option' },
|
||||||
"ssh-option:s@" => { name => 'ssh_option' },
|
"ssh-path:s" => { name => 'ssh_path' },
|
||||||
"ssh-path:s" => { name => 'ssh_path' },
|
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
|
||||||
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
|
"timeout:s" => { name => 'timeout', default => 30 },
|
||||||
"timeout:s" => { name => 'timeout', default => 30 },
|
"command:s" => { name => 'command', default => 'show' },
|
||||||
"command:s" => { name => 'command', default => 'show' },
|
"command-path:s" => { name => 'command_path' },
|
||||||
"command-path:s" => { name => 'command_path' },
|
"command-options:s" => { name => 'command_options', default => ' performance -type host-io' },
|
||||||
"command-options:s" => { name => 'command_options', default => ' performance -type host-io' },
|
"filter-name:s" => { name => 'filter_name' },
|
||||||
"no-component:s" => { name => 'no_component' },
|
});
|
||||||
"filter-name:s" => { name => 'filter_name' },
|
|
||||||
});
|
|
||||||
$self->{no_components} = undef;
|
|
||||||
|
|
||||||
foreach my $key (('vol')) {
|
|
||||||
foreach (keys %{$maps_counters->{$key}}) {
|
|
||||||
my ($id, $name) = split /_/;
|
|
||||||
if (!defined($maps_counters->{$key}->{$_}->{threshold}) || $maps_counters->{$key}->{$_}->{threshold} != 0) {
|
|
||||||
$options{options}->add_options(arguments => {
|
|
||||||
'warning-' . $name . ':s' => { name => 'warning-' . $name },
|
|
||||||
'critical-' . $name . ':s' => { name => 'critical-' . $name },
|
|
||||||
});
|
|
||||||
}
|
|
||||||
$maps_counters->{$key}->{$_}->{obj} = centreon::plugins::values->new(output => $self->{output}, perfdata => $self->{perfdata},
|
|
||||||
label => $name);
|
|
||||||
$maps_counters->{$key}->{$_}->{obj}->set(%{$maps_counters->{$key}->{$_}->{set}});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub check_options {
|
sub check_options {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
$self->SUPER::init(%options);
|
$self->SUPER::check_options(%options);
|
||||||
|
|
||||||
if (defined($self->{option_results}->{hostname}) && $self->{option_results}->{hostname} ne '') {
|
if (defined($self->{option_results}->{hostname}) && $self->{option_results}->{hostname} ne '') {
|
||||||
$self->{option_results}->{remote} = 1;
|
$self->{option_results}->{remote} = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach my $key (('vol')) {
|
|
||||||
foreach (keys %{$maps_counters->{$key}}) {
|
|
||||||
$maps_counters->{$key}->{$_}->{obj}->init(option_results => $self->{option_results});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (defined($self->{option_results}->{no_component})) {
|
|
||||||
if ($self->{option_results}->{no_component} ne '') {
|
|
||||||
$self->{no_components} = $self->{option_results}->{no_component};
|
|
||||||
} else {
|
|
||||||
$self->{no_components} = 'critical';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sub run {
|
|
||||||
my ($self, %options) = @_;
|
|
||||||
|
|
||||||
$self->manage_selection();
|
|
||||||
|
|
||||||
my $multiple = 1;
|
|
||||||
if (scalar(keys %{$self->{vol}}) == 1) {
|
|
||||||
$multiple = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($multiple == 1) {
|
|
||||||
$self->{output}->output_add(severity => 'OK',
|
|
||||||
short_msg => 'All Volumes are ok');
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach my $id (sort keys %{$self->{vol}}) {
|
|
||||||
my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', '');
|
|
||||||
my @exits = ();
|
|
||||||
foreach (sort keys %{$maps_counters->{vol}}) {
|
|
||||||
my $obj = $maps_counters->{vol}->{$_}->{obj};
|
|
||||||
$obj->set(instance => $id);
|
|
||||||
|
|
||||||
my ($value_check) = $obj->execute(values => $self->{vol}->{$id});
|
|
||||||
|
|
||||||
if ($value_check != 0) {
|
|
||||||
$long_msg .= $long_msg_append . $obj->output_error();
|
|
||||||
$long_msg_append = ', ';
|
|
||||||
next;
|
|
||||||
}
|
|
||||||
my $exit2 = $obj->threshold_check();
|
|
||||||
push @exits, $exit2;
|
|
||||||
|
|
||||||
my $output = $obj->output();
|
|
||||||
$long_msg .= $long_msg_append . $output;
|
|
||||||
$long_msg_append = ', ';
|
|
||||||
|
|
||||||
if (!$self->{output}->is_status(litteral => 1, value => $exit2, compare => 'ok')) {
|
|
||||||
$short_msg .= $short_msg_append . $output;
|
|
||||||
$short_msg_append = ', ';
|
|
||||||
}
|
|
||||||
|
|
||||||
$obj->perfdata(level => 1, extra_instance => $multiple);
|
|
||||||
}
|
|
||||||
|
|
||||||
$self->{output}->output_add(long_msg => "Volume '$self->{vol}->{$id}->{display}' $long_msg");
|
|
||||||
my $exit = $self->{output}->get_most_critical(status => [ @exits ]);
|
|
||||||
if (!$self->{output}->is_status(litteral => 1, value => $exit, compare => 'ok')) {
|
|
||||||
$self->{output}->output_add(severity => $exit,
|
|
||||||
short_msg => "Volume '$self->{vol}->{$id}->{display}' $short_msg"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($multiple == 0) {
|
|
||||||
$self->{output}->output_add(short_msg => "Volume '$self->{vol}->{$id}->{display}' $long_msg");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$self->{output}->display();
|
|
||||||
$self->{output}->exit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub manage_selection {
|
sub manage_selection {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my $stdout = centreon::plugins::misc::execute(output => $self->{output},
|
my $stdout = centreon::plugins::misc::execute(
|
||||||
options => $self->{option_results},
|
output => $self->{output},
|
||||||
ssh_pipe => 1,
|
options => $self->{option_results},
|
||||||
command => $self->{option_results}->{command},
|
ssh_pipe => 1,
|
||||||
command_path => $self->{option_results}->{command_path},
|
command => $self->{option_results}->{command},
|
||||||
command_options => $self->{option_results}->{command_options});
|
command_path => $self->{option_results}->{command_path},
|
||||||
|
command_options => $self->{option_results}->{command_options}
|
||||||
|
);
|
||||||
|
|
||||||
#Volume IOPS(IOPS) Throughput(MB/s) Response Time(msec.) Processing Time(msec.) Cache Hit Rate(%)
|
#Volume IOPS(IOPS) Throughput(MB/s) Response Time(msec.) Processing Time(msec.) Cache Hit Rate(%)
|
||||||
#No. Name Read / Write Read / Write Read / Write Read / Write Read / Write / Prefetch
|
#No. Name Read / Write Read / Write Read / Write Read / Write Read / Write / Prefetch
|
||||||
|
@ -270,7 +181,7 @@ sub manage_selection {
|
||||||
# 1 VOL001 6621 5192 589 379 17055 12056 10025 10010 41 37 36
|
# 1 VOL001 6621 5192 589 379 17055 12056 10025 10010 41 37 36
|
||||||
# 2 VOL002 7791 6608 613 292 12148 11045 10005 10007 41 37 36
|
# 2 VOL002 7791 6608 613 292 12148 11045 10005 10007 41 37 36
|
||||||
|
|
||||||
$self->{vol} = {};
|
$self->{volume} = {};
|
||||||
my %template_label = (cache_hit_rate => { labels => ['read', 'write', 'prefetch'] });
|
my %template_label = (cache_hit_rate => { labels => ['read', 'write', 'prefetch'] });
|
||||||
my @template_values = ();
|
my @template_values = ();
|
||||||
foreach (split /\n/, $stdout) {
|
foreach (split /\n/, $stdout) {
|
||||||
|
@ -307,14 +218,15 @@ sub manage_selection {
|
||||||
$counters{read_throughput} *= 1000 * 1000 * 8 if (defined($counters{read_throughput}));
|
$counters{read_throughput} *= 1000 * 1000 * 8 if (defined($counters{read_throughput}));
|
||||||
$counters{write_throughput} *= 1000 * 1000 * 8 if (defined($counters{write_throughput}));
|
$counters{write_throughput} *= 1000 * 1000 * 8 if (defined($counters{write_throughput}));
|
||||||
|
|
||||||
$self->{vol}->{$matches[0]} = { display => $matches[1],
|
$self->{volume}->{$matches[0]} = {
|
||||||
%counters
|
display => $matches[1],
|
||||||
};
|
%counters
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scalar(keys %{$self->{vol}}) <= 0) {
|
if (scalar(keys %{$self->{volume}}) <= 0) {
|
||||||
$self->{output}->output_add(severity => defined($self->{no_components}) ? $self->{no_components} : 'unknown',
|
$self->{output}->add_option_msg(short_msg => "No volume found.");
|
||||||
short_msg => 'No components are checked.');
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -361,10 +273,6 @@ Command path (Default: none).
|
||||||
|
|
||||||
Command options (Default: 'performance -type host-io').
|
Command options (Default: 'performance -type host-io').
|
||||||
|
|
||||||
=item B<--no-component>
|
|
||||||
|
|
||||||
Set the threshold where no components (Default: 'unknown' returns).
|
|
||||||
|
|
||||||
=item B<--filter-name>
|
=item B<--filter-name>
|
||||||
|
|
||||||
Filter by name (regexp can be used).
|
Filter by name (regexp can be used).
|
||||||
|
|
Loading…
Reference in New Issue