(plugin) storage::fujitsu::eternus::dx::ssh - use ssh backends (#3967)

* (plugin) storage::fujitsu::eternus::dx::ssh - use ssh backends

* wip
This commit is contained in:
qgarnier 2022-10-07 14:46:13 +02:00 committed by GitHub
parent 659f053768
commit a23791d3f5
8 changed files with 105 additions and 398 deletions

View File

@ -110,7 +110,8 @@ sub execute_command {
command_path => defined($self->{option_results}->{command_path}) && $self->{option_results}->{command_path} ne '' ? $self->{option_results}->{command_path} : $options{command_path}, command_path => defined($self->{option_results}->{command_path}) && $self->{option_results}->{command_path} ne '' ? $self->{option_results}->{command_path} : $options{command_path},
command_options => $command_options, command_options => $command_options,
timeout => $timeout, timeout => $timeout,
no_quit => $options{no_quit} no_quit => $options{no_quit},
ssh_pipe => $options{ssh_pipe}
); );
} else { } else {
($stdout, $exit_code) = centreon::plugins::misc::execute( ($stdout, $exit_code) = centreon::plugins::misc::execute(

View File

@ -58,40 +58,21 @@ sub new {
bless $self, $class; bless $self, $class;
$options{options}->add_options(arguments => { $options{options}->add_options(arguments => {
"hostname:s" => { name => 'hostname' }, 'filter-name:s' => { name => 'filter_name' }
"ssh-option:s@" => { name => 'ssh_option' },
"ssh-path:s" => { name => 'ssh_path' },
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
"timeout:s" => { name => 'timeout', default => 30 },
"command:s" => { name => 'command', default => 'show' },
"command-path:s" => { name => 'command_path' },
"command-options:s" => { name => 'command_options', default => 'performance -type cm' },
"filter-name:s" => { name => 'filter_name' },
}); });
return $self; return $self;
} }
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
if (defined($self->{option_results}->{hostname}) && $self->{option_results}->{hostname} ne '') {
$self->{option_results}->{remote} = 1;
}
}
sub manage_selection { sub manage_selection {
my ($self, %options) = @_; my ($self, %options) = @_;
my $stdout = centreon::plugins::misc::execute( my ($stdout) = $options{custom}->execute_command(
output => $self->{output}, command => 'show',
options => $self->{option_results}, command_options => "performance -type cm\n",
ssh_pipe => 1, ssh_pipe => 1
command => $self->{option_results}->{command},
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)
@ -107,13 +88,13 @@ sub manage_selection {
foreach (split /\n/, $stdout) { foreach (split /\n/, $stdout) {
next if ($_ !~ /^(CM.*?)\s{2,}(\d+)\s+\S+/); next if ($_ !~ /^(CM.*?)\s{2,}(\d+)\s+\S+/);
my ($cpu_name, $cpu_value) = ($1, $2); my ($cpu_name, $cpu_value) = ($1, $2);
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;
} }
$self->{cpu}->{$cpu_name} = { display => $cpu_name, usage => $cpu_value }; $self->{cpu}->{$cpu_name} = { display => $cpu_name, usage => $cpu_value };
} }
@ -131,41 +112,10 @@ __END__
Check CPUs usage. Check CPUs usage.
Command used: show performance -type cm
=over 8 =over 8
=item B<--hostname>
Hostname to query.
=item B<--ssh-option>
Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52').
=item B<--ssh-path>
Specify ssh command path (default: none)
=item B<--ssh-command>
Specify ssh command (default: 'ssh'). Useful to use 'plink'.
=item B<--timeout>
Timeout in seconds for the command (Default: 30).
=item B<--command>
Command to get information (Default: 'show').
Can be changed if you have output in a file.
=item B<--command-path>
Command path (Default: none).
=item B<--command-options>
Command options (Default: 'performance -type cm').
=item B<--filter-name> =item B<--filter-name>
Filter by name (regexp can be used). Filter by name (regexp can be used).

View File

@ -42,7 +42,7 @@ my $thresholds = {
['Broken', 'CRITICAL'], ['Broken', 'CRITICAL'],
['Not Exist', 'CRITICAL'], ['Not Exist', 'CRITICAL'],
['Unknown', 'UNKNOWN'] ['Unknown', 'UNKNOWN']
], ]
}; };
sub new { sub new {
@ -50,18 +50,10 @@ sub new {
my $self = $class->SUPER::new(package => __PACKAGE__, %options); my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class; bless $self, $class;
$options{options}->add_options(arguments => { $options{options}->add_options(arguments => {
"hostname:s" => { name => 'hostname' }, 'filter:s@' => { name => 'filter' },
"ssh-option:s@" => { name => 'ssh_option' }, 'threshold-overload:s@' => { name => 'threshold_overload' },
"ssh-path:s" => { name => 'ssh_path' }, 'no-component:s' => { name => 'no_component' }
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
"timeout:s" => { name => 'timeout', default => 30 },
"command:s" => { name => 'command', default => 'show' },
"command-path:s" => { name => 'command_path' },
"command-options:s" => { name => 'command_options', default => 'disks' },
"filter:s@" => { name => 'filter' },
"threshold-overload:s@" => { name => 'threshold_overload' },
"no-component:s" => { name => 'no_component' }
}); });
$self->{no_components} = undef; $self->{no_components} = undef;
@ -71,10 +63,6 @@ sub new {
sub check_options { sub check_options {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->SUPER::init(%options); $self->SUPER::init(%options);
if (defined($self->{option_results}->{hostname}) && $self->{option_results}->{hostname} ne '') {
$self->{option_results}->{remote} = 1;
}
$self->{filter} = []; $self->{filter} = [];
foreach my $val (@{$self->{option_results}->{filter}}) { foreach my $val (@{$self->{option_results}->{filter}}) {
@ -110,12 +98,11 @@ sub check_options {
sub run { sub run {
my ($self, %options) = @_; my ($self, %options) = @_;
my $stdout = centreon::plugins::misc::execute(output => $self->{output}, my ($stdout) = $options{custom}->execute_command(
options => $self->{option_results}, command => 'show',
ssh_pipe => 1, command_options => "disks\n",
command => $self->{option_results}->{command}, ssh_pipe => 1
command_path => $self->{option_results}->{command_path}, );
command_options => $self->{option_results}->{command_options});
#Location Status Size Type Speed(rpm) Usage Health(%) #Location Status Size Type Speed(rpm) Usage Health(%)
#------------- ----------------------------- ------- ------------------- ---------- ------------------- --------- #------------- ----------------------------- ------- ------------------- ---------- ------------------- ---------
@ -136,17 +123,23 @@ sub run {
$self->{output}->output_add(long_msg => sprintf("Physical Disk '%s' status is '%s'", $disk_name, $disk_status)); $self->{output}->output_add(long_msg => sprintf("Physical Disk '%s' status is '%s'", $disk_name, $disk_status));
my $exit = $self->get_severity(section => 'disk', value => $disk_status); my $exit = $self->get_severity(section => 'disk', value => $disk_status);
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit, $self->{output}->output_add(
short_msg => sprintf("Physical Disk '%s' status is '%s'.", $disk_name, $disk_status)); severity => $exit,
short_msg => sprintf("Physical Disk '%s' status is '%s'.", $disk_name, $disk_status)
);
} }
} }
$self->{output}->output_add(severity => 'OK', $self->{output}->output_add(
short_msg => sprintf("All %d physical disks are ok.", $total_components)); severity => 'OK',
short_msg => sprintf("All %d physical disks are ok.", $total_components)
);
if (defined($self->{option_results}->{no_component}) && $total_components == 0) { if (defined($self->{option_results}->{no_component}) && $total_components == 0) {
$self->{output}->output_add(severity => $self->{no_components}, $self->{output}->output_add(
short_msg => 'No components are checked.'); severity => $self->{no_components},
short_msg => 'No components are checked.'
);
} }
$self->{output}->display(); $self->{output}->display();
@ -174,7 +167,7 @@ sub check_filter {
sub get_severity { sub get_severity {
my ($self, %options) = @_; my ($self, %options) = @_;
my $status = 'UNKNOWN'; # default my $status = 'UNKNOWN'; # default
if (defined($self->{overload_th}->{$options{section}})) { if (defined($self->{overload_th}->{$options{section}})) {
foreach (@{$self->{overload_th}->{$options{section}}}) { foreach (@{$self->{overload_th}->{$options{section}}}) {
if ($options{value} =~ /$_->{filter}/i) { if ($options{value} =~ /$_->{filter}/i) {
@ -189,7 +182,7 @@ sub get_severity {
return $status; return $status;
} }
} }
return $status; return $status;
} }
@ -201,41 +194,10 @@ __END__
Check Physical disks. Check Physical disks.
Command used: show disks
=over 8 =over 8
=item B<--hostname>
Hostname to query.
=item B<--ssh-option>
Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52').
=item B<--ssh-path>
Specify ssh command path (default: none)
=item B<--ssh-command>
Specify ssh command (default: 'ssh'). Useful to use 'plink'.
=item B<--timeout>
Timeout in seconds for the command (Default: 30).
=item B<--command>
Command to get information (Default: 'show').
Can be changed if you have output in a file.
=item B<--command-path>
Command path (Default: none).
=item B<--command-options>
Command options (Default: 'disks').
=item B<--filter> =item B<--filter>
Exclude some parts (comma seperated list) Exclude some parts (comma seperated list)

View File

@ -28,11 +28,11 @@ use centreon::plugins::misc;
sub set_counters { sub set_counters {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->{maps_counters_type} = [ $self->{maps_counters_type} = [
{ name => 'port', type => 1, cb_prefix_output => 'prefix_port_output', message_multiple => 'All ports are ok' } { name => 'port', type => 1, cb_prefix_output => 'prefix_port_output', message_multiple => 'All ports are ok' }
]; ];
$self->{maps_counters}->{port} = [ $self->{maps_counters}->{port} = [
{ label => 'read-iops', nlabel => 'port.io.read.usage.iops', set => { { label => 'read-iops', nlabel => 'port.io.read.usage.iops', set => {
key_values => [ { name => 'read_iops' }, { name => 'display' } ], key_values => [ { name => 'read_iops' }, { name => 'display' } ],
@ -84,40 +84,20 @@ sub new {
my $self = $class->SUPER::new(package => __PACKAGE__, %options); my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class; bless $self, $class;
$options{options}->add_options(arguments => { $options{options}->add_options(arguments => {
"hostname:s" => { name => 'hostname' }, 'filter-name:s' => { name => 'filter_name' }
"ssh-option:s@" => { name => 'ssh_option' },
"ssh-path:s" => { name => 'ssh_path' },
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
"timeout:s" => { name => 'timeout', default => 30 },
"command:s" => { name => 'command', default => 'show' },
"command-path:s" => { name => 'command_path' },
"command-options:s" => { name => 'command_options', default => 'performance -type port' },
"filter-name:s" => { name => 'filter_name' },
}); });
return $self; return $self;
} }
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
if (defined($self->{option_results}->{hostname}) && $self->{option_results}->{hostname} ne '') {
$self->{option_results}->{remote} = 1;
}
}
sub manage_selection { sub manage_selection {
my ($self, %options) = @_; my ($self, %options) = @_;
my $stdout = centreon::plugins::misc::execute( my ($stdout) = $options{custom}->execute_command(
output => $self->{output}, command => 'show',
options => $self->{option_results}, command_options => "performance -type port\n",
ssh_pipe => 1, ssh_pipe => 1
command => $self->{option_results}->{command},
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)
@ -136,7 +116,7 @@ sub manage_selection {
$self->{output}->output_add(long_msg => "Skipping '" . $port_name . "': no matching filter name."); $self->{output}->output_add(long_msg => "Skipping '" . $port_name . "': no matching filter name.");
next; next;
} }
$self->{port}->{$port_name} = { $self->{port}->{$port_name} = {
display => $port_name, display => $port_name,
read_iops => $port_read_iops, write_iops => $port_write_iops, read_iops => $port_read_iops, write_iops => $port_write_iops,
@ -159,41 +139,10 @@ __END__
Check Port statistics. Check Port statistics.
Command used: show performance -type port
=over 8 =over 8
=item B<--hostname>
Hostname to query.
=item B<--ssh-option>
Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52').
=item B<--ssh-path>
Specify ssh command path (default: none)
=item B<--ssh-command>
Specify ssh command (default: 'ssh'). Useful to use 'plink'.
=item B<--timeout>
Timeout in seconds for the command (Default: 30).
=item B<--command>
Command to get information (Default: 'show').
Can be changed if you have output in a file.
=item B<--command-path>
Command path (Default: none).
=item B<--command-options>
Command options (Default: 'performance -type port').
=item B<--filter-name> =item B<--filter-name>
Filter by name (regexp can be used). Filter by name (regexp can be used).

View File

@ -44,18 +44,10 @@ sub new {
my $self = $class->SUPER::new(package => __PACKAGE__, %options); my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class; bless $self, $class;
$options{options}->add_options(arguments => { $options{options}->add_options(arguments => {
'hostname:s' => { name => 'hostname' }, 'filter:s@' => { name => 'filter' },
'ssh-option:s@' => { name => 'ssh_option' }, 'threshold-overload:s@' => { name => 'threshold_overload' },
'ssh-path:s' => { name => 'ssh_path' }, 'no-component:s' => { name => 'no_component' }
'ssh-command:s' => { name => 'ssh_command', default => 'ssh' },
'timeout:s' => { name => 'timeout', default => 30 },
'command:s' => { name => 'command', default => 'show' },
'command-path:s' => { name => 'command_path' },
'command-options:s' => { name => 'command_options', default => 'enclosure-status -type all' },
'filter:s@' => { name => 'filter' },
'threshold-overload:s@' => { name => 'threshold_overload' },
'no-component:s' => { name => 'no_component' }
}); });
$self->{no_components} = undef; $self->{no_components} = undef;
@ -65,10 +57,6 @@ sub new {
sub check_options { sub check_options {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->SUPER::init(%options); $self->SUPER::init(%options);
if (defined($self->{option_results}->{hostname}) && $self->{option_results}->{hostname} ne '') {
$self->{option_results}->{remote} = 1;
}
$self->{filter} = []; $self->{filter} = [];
foreach my $val (@{$self->{option_results}->{filter}}) { foreach my $val (@{$self->{option_results}->{filter}}) {
@ -104,13 +92,10 @@ sub check_options {
sub run { sub run {
my ($self, %options) = @_; my ($self, %options) = @_;
my $stdout = centreon::plugins::misc::execute( my ($stdout) = $options{custom}->execute_command(
output => $self->{output}, command => 'show',
options => $self->{option_results}, command_options => "enclosure-status -type all\n",
ssh_pipe => 1, ssh_pipe => 1
command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path},
command_options => $self->{option_results}->{command_options}
); );
#Controller Enclosure #0 Information #Controller Enclosure #0 Information
@ -242,41 +227,10 @@ __END__
Check power supplies. Check power supplies.
Command used: show enclosure-status -type all
=over 8 =over 8
=item B<--hostname>
Hostname to query.
=item B<--ssh-option>
Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52').
=item B<--ssh-path>
Specify ssh command path (default: none)
=item B<--ssh-command>
Specify ssh command (default: 'ssh'). Useful to use 'plink'.
=item B<--timeout>
Timeout in seconds for the command (Default: 30).
=item B<--command>
Command to get information (Default: 'show').
Can be changed if you have output in a file.
=item B<--command-path>
Command path (Default: none).
=item B<--command-options>
Command options (Default: 'enclosure-status -type all').
=item B<--filter> =item B<--filter>
Exclude some parts (comma seperated list) Exclude some parts (comma seperated list)

View File

@ -32,13 +32,6 @@ sub custom_threshold_output {
return $self->{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 {
my ($self, %options) = @_;
$self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_status'};
return 0;
}
sub custom_usage_perfdata { sub custom_usage_perfdata {
my ($self, %options) = @_; my ($self, %options) = @_;
@ -86,6 +79,12 @@ sub custom_usage_calc {
return 0; return 0;
} }
sub prefix_rg_output {
my ($self, %options) = @_;
return "Raid Group '" . $options{instance_value}->{display} . "' ";
}
sub set_counters { sub set_counters {
my ($self, %options) = @_; my ($self, %options) = @_;
@ -96,7 +95,6 @@ sub set_counters {
$self->{maps_counters}->{rg} = [ $self->{maps_counters}->{rg} = [
{ label => 'status', threshold => 0, set => { { label => 'status', threshold => 0, set => {
key_values => [ { name => 'status' } ], key_values => [ { name => 'status' } ],
closure_custom_calc => $self->can('custom_status_calc'),
output_template => 'Status : %s', output_error_template => 'Status : %s', output_template => 'Status : %s', output_error_template => 'Status : %s',
output_use => 'status', output_use => 'status',
closure_custom_perfdata => sub { return 0; }, closure_custom_perfdata => sub { return 0; },
@ -114,29 +112,15 @@ sub set_counters {
]; ];
} }
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;
$options{options}->add_options(arguments => { $options{options}->add_options(arguments => {
"hostname:s" => { name => 'hostname' }, 'threshold-overload:s@' => { name => 'threshold_overload' },
"ssh-option:s@" => { name => 'ssh_option' }, 'filter-name:s' => { name => 'filter_name' },
"ssh-path:s" => { name => 'ssh_path' }, 'filter-level:s' => { name => 'filter_level' }
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
"timeout:s" => { name => 'timeout', default => 30 },
"command:s" => { name => 'command', default => 'show' },
"command-path:s" => { name => 'command_path' },
"command-options:s" => { name => 'command_options', default => 'raid-groups -csv' },
"threshold-overload:s@" => { name => 'threshold_overload' },
"filter-name:s" => { name => 'filter_name' },
"filter-level:s" => { name => 'filter_level' },
}); });
return $self; return $self;
@ -146,10 +130,6 @@ sub check_options {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->SUPER::check_options(%options); $self->SUPER::check_options(%options);
if (defined($self->{option_results}->{hostname}) && $self->{option_results}->{hostname} ne '') {
$self->{option_results}->{remote} = 1;
}
$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 !~ /^(.*?),(.*?),(.*)$/) {
@ -169,13 +149,10 @@ sub check_options {
sub manage_selection { sub manage_selection {
my ($self, %options) = @_; my ($self, %options) = @_;
my $stdout = centreon::plugins::misc::execute( my ($stdout) = $options{custom}->execute_command(
output => $self->{output}, command => 'show',
options => $self->{option_results}, command_options => "raid-groups -csv\n",
ssh_pipe => 1, ssh_pipe => 1
command => $self->{option_results}->{command},
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)]
@ -215,8 +192,8 @@ sub manage_selection {
my $thresholds = { my $thresholds = {
rg => [ rg => [
['Available', 'OK'], ['Available', 'OK'],
['Spare in Use', 'WARNING'], ['Spare in Use', 'WARNING']
], ]
}; };
sub get_severity { sub get_severity {
@ -249,41 +226,10 @@ __END__
Check raid groups. Check raid groups.
Command used: show raid-groups -csv
=over 8 =over 8
=item B<--hostname>
Hostname to query.
=item B<--ssh-option>
Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52').
=item B<--ssh-path>
Specify ssh command path (default: none)
=item B<--ssh-command>
Specify ssh command (default: 'ssh'). Useful to use 'plink'.
=item B<--timeout>
Timeout in seconds for the command (Default: 30).
=item B<--command>
Command to get information (Default: 'show').
Can be changed if you have output in a file.
=item B<--command-path>
Command path (Default: none).
=item B<--command-options>
Command options (Default: 'raid-groups -csv').
=item B<--threshold-overload> =item B<--threshold-overload>
Set to overload default threshold values (syntax: section,status,regexp) Set to overload default threshold values (syntax: section,status,regexp)

View File

@ -89,7 +89,7 @@ sub set_counters {
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', template => '%d', { label => 'write_response_time', template => '%d',
unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display' }, unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display' },
], ],
} }
@ -138,40 +138,20 @@ sub new {
my $self = $class->SUPER::new(package => __PACKAGE__, %options); my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class; bless $self, $class;
$options{options}->add_options(arguments => { $options{options}->add_options(arguments => {
'hostname:s' => { name => 'hostname' }, 'filter-name:s' => { name => 'filter_name' }
'ssh-option:s@' => { name => 'ssh_option' },
'ssh-path:s' => { name => 'ssh_path' },
'ssh-command:s' => { name => 'ssh_command', default => 'ssh' },
'timeout:s' => { name => 'timeout', default => 30 },
'command:s' => { name => 'command', default => 'show' },
'command-path:s' => { name => 'command_path' },
'command-options:s' => { name => 'command_options', default => ' performance -type host-io' },
'filter-name:s' => { name => 'filter_name' }
}); });
return $self; return $self;
} }
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
if (defined($self->{option_results}->{hostname}) && $self->{option_results}->{hostname} ne '') {
$self->{option_results}->{remote} = 1;
}
}
sub manage_selection { sub manage_selection {
my ($self, %options) = @_; my ($self, %options) = @_;
my $stdout = centreon::plugins::misc::execute( my ($stdout) = $options{custom}->execute_command(
output => $self->{output}, command => 'show',
options => $self->{option_results}, command_options => "performance -type host-io\n",
ssh_pipe => 1, ssh_pipe => 1
command => $self->{option_results}->{command},
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(%)
@ -201,6 +181,8 @@ sub manage_selection {
next; next;
} }
next if (/----|Name/i); next if (/----|Name/i);
next if (/^CLI>/);
my $value = centreon::plugins::misc::trim($_); my $value = centreon::plugins::misc::trim($_);
my @matches = split(/\s+/, $value); my @matches = split(/\s+/, $value);
@ -211,7 +193,7 @@ sub manage_selection {
$self->{output}->output_add(long_msg => "Skipping '" . $matches[1] . "': no matching filter name.", debug => 1); $self->{output}->output_add(long_msg => "Skipping '" . $matches[1] . "': no matching filter name.", debug => 1);
next; next;
} }
my %counters = (); my %counters = ();
for (my $i = 0; $i < scalar(@template_values); $i++) { for (my $i = 0; $i < scalar(@template_values); $i++) {
$counters{$template_values[$i]->{label}} = $matches[$i + 2]; $counters{$template_values[$i]->{label}} = $matches[$i + 2];
@ -224,7 +206,7 @@ sub manage_selection {
%counters %counters
}; };
} }
if (scalar(keys %{$self->{volume}}) <= 0) { if (scalar(keys %{$self->{volume}}) <= 0) {
$self->{output}->add_option_msg(short_msg => "No volume found."); $self->{output}->add_option_msg(short_msg => "No volume found.");
$self->{output}->option_exit(); $self->{output}->option_exit();
@ -237,57 +219,19 @@ __END__
=head1 MODE =head1 MODE
Check Volume statistics. Check volume statistics.
Command used: show performance -type host-io
=over 8 =over 8
=item B<--hostname>
Hostname to query.
=item B<--ssh-option>
Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52').
=item B<--ssh-path>
Specify ssh command path (default: none)
=item B<--ssh-command>
Specify ssh command (default: 'ssh'). Useful to use 'plink'.
=item B<--timeout>
Timeout in seconds for the command (Default: 30).
=item B<--command>
Command to get information (Default: 'show').
Can be changed if you have output in a file.
=item B<--command-path>
Command path (Default: none).
=item B<--command-options>
Command options (Default: 'performance -type host-io').
=item B<--filter-name> =item B<--filter-name>
Filter by name (regexp can be used). Filter by name (regexp can be used).
=item B<--warning-*> =item B<--warning-*> B<--critical-*>
Threshold warning. Thresholds.
Can be: 'read-iops', 'write-iops', 'read-traffic', 'write-traffic',
'read-response-time', 'write-response-time', 'read-processing-time', 'write-processing-time',
'read-cache-hit-rate', 'write-cache-hit-rate'.
=item B<--critical-*>
Threshold critical.
Can be: 'read-iops', 'write-iops', 'read-traffic', 'write-traffic', Can be: 'read-iops', 'write-iops', 'read-traffic', 'write-traffic',
'read-response-time', 'write-response-time', 'read-processing-time', 'write-processing-time', 'read-response-time', 'write-response-time', 'read-processing-time', 'write-processing-time',
'read-cache-hit-rate', 'write-cache-hit-rate'. 'read-cache-hit-rate', 'write-cache-hit-rate'.

View File

@ -22,22 +22,23 @@ package storage::fujitsu::eternus::dx::ssh::plugin;
use strict; use strict;
use warnings; use warnings;
use base qw(centreon::plugins::script_simple); use base qw(centreon::plugins::script_custom);
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->{modes} = {
%{$self->{modes}} = ( 'cpu' => 'storage::fujitsu::eternus::dx::ssh::mode::cpu',
'physicaldisk' => 'storage::fujitsu::eternus::dx::ssh::mode::physicaldisk', 'physicaldisk' => 'storage::fujitsu::eternus::dx::ssh::mode::physicaldisk',
'psu' => 'storage::fujitsu::eternus::dx::ssh::mode::psu', 'port-stats' => 'storage::fujitsu::eternus::dx::ssh::mode::portstats',
'raid-groups' => 'storage::fujitsu::eternus::dx::ssh::mode::raidgroups', 'psu' => 'storage::fujitsu::eternus::dx::ssh::mode::psu',
'volume-stats' => 'storage::fujitsu::eternus::dx::ssh::mode::volumestats', 'raid-groups' => 'storage::fujitsu::eternus::dx::ssh::mode::raidgroups',
'cpu' => 'storage::fujitsu::eternus::dx::ssh::mode::cpu', 'volume-stats' => 'storage::fujitsu::eternus::dx::ssh::mode::volumestats'
'port-stats' => 'storage::fujitsu::eternus::dx::ssh::mode::portstats', };
);
$self->{custom_modes}->{cli} = 'centreon::plugins::script_custom::cli';
return $self; return $self;
} }