Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/storage/hitachi/eseries/local/custom/cli.pm
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ sub new {

if (!defined($options{noptions})) {
$options{options}->add_options(arguments => {
'baie-id:s' => { name => 'baie_id', default => '' },
'instance-id:s' => { name => 'instance_id', default => '' },
'timeout:s' => { name => 'timeout', default => 45 },
'command-path:s' => { name => 'command_path', default => '' },
'sudo' => { name => 'sudo' }
Expand All @@ -58,25 +58,25 @@ sub set_defaults {}
sub check_options {
my ($self, %options) = @_;

$self->{output}->option_exit(short_msg => "Please set a valid --baie-id option.")
unless $self->{option_results}->{baie_id} =~ /^\d+$/;
$self->{output}->option_exit(short_msg => "Please set a valid --instance-id option.")
unless $self->{option_results}->{instance_id} =~ /^\d+$/;

$self->{$_} = $self->{option_results}->{$_}
foreach qw/baie_id timeout/;
foreach qw/instance_id timeout/;

return 0;
}

sub get_baie_id {
sub get_instance_id {
my ($self, %options) = @_;
return $self->{baie_id};
return $self->{instance_id};
}

sub execute_command {
my ($self, %options) = @_;

my $command_path = $self->{option_results}->{command_path} ne '' ? $self->{option_results}->{command_path}
: $options{command_path};
: $options{command_path};

check_security_command(
output => $self->{output},
Expand Down Expand Up @@ -117,7 +117,7 @@ Hitachi E-Series local client custom connector.

=over 8

=item B<--baie-id>
=item B<--instance-id>

Storage array ID (4 digits, required).

Expand Down
4 changes: 2 additions & 2 deletions src/storage/hitachi/eseries/local/mode/efficiency.pm
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ sub manage_selection {

my ($stdout) = $options{custom}->execute_command(
command => 'raidcom',
command_options => 'get system -key efficiency -I' . $options{custom}->get_baie_id(),
command_options => 'get system -key efficiency -I' . $options{custom}->get_instance_id(),
);

# https://docs.hitachivantara.com/r/en-us/command-control-interface/01-87-03/mk-90rd7009/configuration-setting-commands/raidcom-get-system
Expand Down Expand Up @@ -109,7 +109,7 @@ __END__

Check Hitachi E-Series storage efficiency ratios.

Command used: C<raidcom get system -key efficiency -I<baie-id>>
Command used: C<raidcom get system -key efficiency -I<instance-id>>

=over 8

Expand Down
28 changes: 14 additions & 14 deletions src/storage/hitachi/eseries/local/mode/pairstatus.pm
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ sub new {
bless $self, $class;

$options{options}->add_options(arguments => {
'remote-baie-id:s@' => { name => 'remote_baie_id' },
'remote-instance-id:s@' => { name => 'remote_instance_id' },
'ldev-id:s@' => { name => 'ldev_id' },
'group-id:s' => { name => 'group_id', default => '' },
});
Expand All @@ -85,25 +85,25 @@ sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);

my $baie_id = $self->{option_results}->{baie_id};
# If remote_baie_id starts with + or - then it is added to baie_id to determine the effective array ID to use
my $instance_id = $self->{option_results}->{instance_id};
# If remote_instance_id starts with + or - then it is added to instance_id to determine the effective array ID to use
# otherwise it is used as is

if (ref $self->{option_results}->{remote_baie_id} eq 'ARRAY') {
foreach my $c_id (reverse @{$self->{option_results}->{remote_baie_id}}) {
if (ref $self->{option_results}->{remote_instance_id} eq 'ARRAY') {
foreach my $c_id (reverse @{$self->{option_results}->{remote_instance_id}}) {
next if $c_id eq '';
if ($c_id =~ /^[\+-]\d+$/) {
$baie_id += $c_id;
$instance_id += $c_id;
} elsif ($c_id =~ /^\d+$/) {
$baie_id = $c_id;
$instance_id = $c_id;
} else {
$self->{output}->option_exit(short_msg => "Please set a valid --remote-baie-id option.");
$self->{output}->option_exit(short_msg => "Please set a valid --remote-instance-id option.");
}
last
}
}

$self->{remote_baie_id} = $baie_id;
$self->{remote_instance_id} = $instance_id;

$self->{ldev_ids} = flatten_arrays($self->{option_results}->{ldev_id});

Expand All @@ -117,12 +117,12 @@ sub manage_selection {
my ($self, %options) = @_;

# https://docs.hitachivantara.com/r/en-us/command-control-interface/01-87-03/mk-90rd7009/data-and-system-management-commands/pairdisplay
# pairdisplay -ITC<baie-id+1000> -g <group> -CLI -fxce
# pairdisplay -ITC<instance-id+1000> -g <group> -CLI -fxce

$self->{pairs} = {};
my ($stdout) = $options{custom}->execute_command(
command => 'pairdisplay',
command_options => '-ITC' . $self->{remote_baie_id} . ' -g ' . $self->{group_id} . ' -CLI -fxce'
command_options => '-ITC' . $self->{remote_instance_id} . ' -g ' . $self->{group_id} . ' -CLI -fxce'
);

foreach my $line (split /\n/, $stdout) {
Expand Down Expand Up @@ -173,13 +173,13 @@ __END__

Check Hitachi E-Series TrueCopy/Universal Replicator pair status.

Command used: C<pairdisplay -ITC<baie-id+1000> -g <group> -CLI -fxce>
Command used: C<pairdisplay -ITC<instance-id+1000> -g <group> -CLI -fxce>

=over 8

=item B<--remote-baie-id>
=item B<--remote-instance-id>

Remote array ID. If starts with + or -, it is added to the local array ID, otherwise used as is (e.g. C<--remote-baie-id='100'> or C<--remote-baie-id='+1000'>).
Remote array ID. If starts with + or -, it is added to the local array ID, otherwise used as is (e.g. C<--remote-instance-id='100'> or C<--remote-instance-id='+1000'>).

=item B<--group-id>

Expand Down
8 changes: 4 additions & 4 deletions src/storage/hitachi/eseries/local/mode/pathstatus.pm
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ sub manage_selection {
my ($self, %options) = @_;

# https://docs.hitachivantara.com/r/en-us/command-control-interface/01-87-03/mk-90rd7009/configuration-setting-commands/raidcom-get-path
# raidcom get path -I$<baie_id>
# raidcom get path -I$<instance_id>

my ($stdout) = $options{custom}->execute_command(
command => 'raidcom',
command_options => 'get path -I' . $options{custom}->get_baie_id()
command_options => 'get path -I' . $options{custom}->get_instance_id()
);

# Columns: PHG Group STS CM IF MP Port WWN PR LUN PHS Serial# ...
Expand All @@ -84,7 +84,7 @@ sub manage_selection {
next if $line =~ /^PHG/ || $line =~ /^\s*$/;

my @fields = split /\s+/, $line;
next unless @fields > 10;
next unless @fields > 10;
my ($port, $lun, $phs) = ($fields[6], $fields[9], $fields[10]);

next unless defined($port) && defined($lun) && defined($phs);
Expand All @@ -111,7 +111,7 @@ __END__

Check Hitachi E-Series path status.

Command used: C<raidcom get path -I<baie-id>>
Command used: C<raidcom get path -I<instance-id>>

=over 8

Expand Down
8 changes: 4 additions & 4 deletions src/storage/hitachi/eseries/local/mode/pool.pm
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ sub set_counters {
$self->{maps_counters}->{pools} = [
{ label => 'status', type => COUNTER_KIND_TEXT, critical_default => '%{status} ne "POLN"', set => {
key_values => [ { name => 'status' }, { name => 'display' } ],
output_template => 'Status: %s',
output_template => 'Status: %s',
closure_custom_threshold_check => \&catalog_status_threshold_ng
}
},
Expand Down Expand Up @@ -120,7 +120,7 @@ sub manage_selection {
# https://docs.hitachivantara.com/r/en-us/command-control-interface/01-87-03/mk-90rd7009/configuration-setting-commands/raidcom-get-pool
my ($stdout) = $options{custom}->execute_command(
command => 'raidcom',
command_options => 'get pool -I' . $options{custom}->get_baie_id()
command_options => 'get pool -I' . $options{custom}->get_instance_id()
);

# Columns: PID POLS U(%) SSCNT Av(MB) Tp(MB) Seq# Num LDEV# H TH ...
Expand All @@ -130,7 +130,7 @@ sub manage_selection {
next if $line =~ /^\s*$/;

my @fields = split /\s+/, $line;
next unless @fields > 5;
next unless @fields > 5;

my ($pid, $pols, $usage_prct, $capa_available_mb, $capacity_mb) =
($fields[0], $fields[1], $fields[2], $fields[4], $fields[5]);
Expand Down Expand Up @@ -165,7 +165,7 @@ __END__

Check Hitachi E-Series pool status and capacity.

Command used: C<raidcom get pool -I<baie-id>>
Command used: C<raidcom get pool -I<instance-id>>

=over 8

Expand Down
21 changes: 12 additions & 9 deletions src/storage/hitachi/eseries/local/mode/quorum.pm
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ use centreon::plugins::misc qw/is_excluded is_empty/;

sub prefix_quorum_output {
my ($self, %options) = @_;

return "Quorum '" . $options{instance_value}->{display} . "' serial: ". $options{instance_value}->{qrp_serial}.", ldev: ". $options{instance_value}->{ldev} . ", "
if $self->{output}->is_verbose();
return "Quorum '" . $options{instance_value}->{display} . "' ";
}

Expand All @@ -44,7 +47,7 @@ sub set_counters {
$self->{maps_counters}->{quorums} = [
{ label => 'status', type => COUNTER_KIND_TEXT, critical_default => '%{status} ne "NORMAL"', set => {
key_values => [ { name => 'status' }, { name => 'display' } ],
output_template => 'Status: %s',
output_template => 'Status: %s',
closure_custom_threshold_check => \&catalog_status_threshold_ng
}
}
Expand All @@ -68,7 +71,7 @@ sub check_options {
$self->SUPER::check_options(%options);

$self->{output}->option_exit(short_msg => "Quorum ID is invalid.")
if $self->{option_results}->{quorum_id} ne '' && $self->{option_results}->{quorum_id} !~ /^\d+$/;
if $self->{option_results}->{quorum_id} ne '' && $self->{option_results}->{quorum_id} !~ /^\d+$/;

$self->{quorum_id} = $self->{option_results}->{quorum_id};
}
Expand All @@ -86,17 +89,17 @@ sub manage_selection {
while (1) {
my ($stdout, $exit_code) = $options{custom}->execute_command(
command => 'raidcom',
command_options => 'get quorum -quorum_id ' . $qid . ' -I' . $options{custom}->get_baie_id(),
command_options => 'get quorum -quorum_id ' . $qid . ' -I' . $options{custom}->get_instance_id(),
no_quit => 1
);
last if is_empty($stdout) || $stdout =~ /^\s+$/ || $exit_code != 0;

# Convert "key: value" formatted output into a hash
my %q;
while ($stdout =~ /^([^\s]+)\s*:\s*(.+)$/mg) {
my $value = $2;
my $key = $1 =~ s/\W//gr;
$q{$key} = $value;
my $value = $2;
my $key = $1 =~ s/\W//gr;
$q{$key} = $value;
}
next unless defined $q{STS};

Expand All @@ -109,8 +112,8 @@ sub manage_selection {
ldev => $q{LDEV} // '-'
};

last if $self->{quorum_id} ne '';
$qid++
last if $self->{quorum_id} ne '';
$qid++
}

$self->{output}->option_exit(short_msg => "No quorum found.")
Expand All @@ -125,7 +128,7 @@ __END__

Check Hitachi E-Series quorum status.

Command used: C<raidcom get quorum -quorum_id <id> -I<baie-id>>
Command used: C<raidcom get quorum -quorum_id <id> -I<instance-id>>

=over 8

Expand Down
14 changes: 7 additions & 7 deletions tests/storage/hitachi/eseries/local/bin/raidcom
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@ subcmd="$1 $2"

case "$subcmd" in
"get system")
# raidcom get system -key efficiency -I<baie_id>
# raidcom get system -key efficiency -I<instance_id>
cat<<EOF
Serial# TOTAL_EFF_R TLS_R PLS_R PLS_CMP_R PLS_DDP_R PLS_RECLAIM_R FMD_SAVING_R FMD_CMP_R FMD_RECLAIM_R SNAPSHOT_EFF_R PROVISIONING_EFF CALCULATION_START CALCULATION_END
123456 2.50 1.20 1.30 0.50 0.70 0.10 1.50 0.80 0.70 1.10 1.20 2024-01-01 2024-01-02
EOF
;;

"get path")
# raidcom get path -I<baie_id> (use -I9999 to trigger BLK path)
baie_id=""
# raidcom get path -I<instance_id> (use -I9999 to trigger BLK path)
instance_id=""
for arg in "$@"; do
case "$arg" in -I*) baie_id="${arg#-I}";; esac
case "$arg" in -I*) instance_id="${arg#-I}";; esac
done
echo "PHG Group STS CM IF MP Port WWN PR LUN PHS Serial# Product_ID LB PM DM QD TO PBW"
echo "0 0 E 0 - 0 CL1-A 50014380186af83c 0 0 NML 123456 VSP 0 M N 8 N 4096"
echo "0 0 E 0 - 0 CL1-A 50014380186af83c 0 1 NML 123456 VSP 0 M N 8 N 4096"
if [ "$baie_id" = "9999" ]; then
if [ "$instance_id" = "9999" ]; then
echo "0 0 E 0 - 0 CL2-A 50014380186af83d 0 0 BLK 123456 VSP 0 M N 8 N 4096"
else
echo "0 0 E 0 - 0 CL2-A 50014380186af83d 0 0 NML 123456 VSP 0 M N 8 N 4096"
Expand All @@ -31,14 +31,14 @@ EOF
;;

"get pool")
# raidcom get pool -I<baie_id>
# raidcom get pool -I<instance_id>
echo "PID POLS U(%) SSCNT Av(MB) Tp(MB) Seq# Num LDEV# H TH Expansion_attribute PoolName"
echo "000 POLN 50 0 204800 409600 123456 1 0x0001 - 80 - TestPool0"
echo "001 POLF 98 0 8192 409600 123456 1 0x0011 - 80 - TestPool1"
;;

"get quorum")
# raidcom get quorum -quorum_id <id> -I<baie_id>
# raidcom get quorum -quorum_id <id> -I<instance_id>
qid=""
shift 2
while [ $# -gt 0 ]; do
Expand Down
2 changes: 1 addition & 1 deletion tests/storage/hitachi/eseries/local/efficiency.robot
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Test Timeout 120s


*** Variables ***
${CMD} ${CENTREON_PLUGINS} --plugin=storage::hitachi::eseries::local::plugin --baie-id=0123 --command-path=${CURDIR}${/}bin
${CMD} ${CENTREON_PLUGINS} --plugin=storage::hitachi::eseries::local::plugin --instance-id=0123 --command-path=${CURDIR}${/}bin


*** Test Cases ***
Expand Down
20 changes: 10 additions & 10 deletions tests/storage/hitachi/eseries/local/pair-status.robot
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ pair-status ${tc}
[Tags] storage hitachi eseries local pair
${command} Catenate
... ${CMD}
... --baie-id=0123
... --instance-id=0123
... --mode=pair-status
... ${extra_options}

Ctn Run Command And Check Result As Strings ${command} ${expected_result}
Ctn Run Command And Check Result As Strings ${command} ${expected_result}

Examples: tc extra_options expected_result --
... 1 ${EMPTY} UNKNOWN: Please set --group-id option.
... 2 --group-id=GRP1 CRITICAL: Pair 'GRP1 - GRP1-PAIR02' Status (L/R): COPY/COPY (sync: 50%/50%)
... 3 --group-id=GRP2 OK: Pair 'GRP2 - GRP2-PAIR01' Status (L/R): PAIR/PAIR (sync: 100%/100%)
... 4 --group-id=GRP1 --ldev-id=GRP1-PAIR01 OK: Pair 'GRP1 - GRP1-PAIR01' Status (L/R): PAIR/PAIR (sync: 100%/100%)
... 5 --group-id=GRP1 --ldev-id=NONE UNKNOWN: No pair found.
... 6 --mode=pair-status --group-id=GRPERR CRITICAL: Pair 'GRPERR - GRPERR-PAIR01' Status (L/R): PSUE/PSUE (sync: 0%/0%)
... 7 --group-id=GRP2 --remote-baie-id=+10 OK: Pair 'GRP2 - GRP2-PAIR01' Status (L/R): PAIR/PAIR (sync: 100%/100%)
Examples: tc extra_options expected_result --
... 1 ${EMPTY} UNKNOWN: Please set --group-id option.
... 2 --group-id=GRP1 CRITICAL: Pair 'GRP1 - GRP1-PAIR02' Status (L/R): COPY/COPY (sync: 50%/50%)
... 3 --group-id=GRP2 OK: Pair 'GRP2 - GRP2-PAIR01' Status (L/R): PAIR/PAIR (sync: 100%/100%)
... 4 --group-id=GRP1 --ldev-id=GRP1-PAIR01 OK: Pair 'GRP1 - GRP1-PAIR01' Status (L/R): PAIR/PAIR (sync: 100%/100%)
... 5 --group-id=GRP1 --ldev-id=NONE UNKNOWN: No pair found.
... 6 --mode=pair-status --group-id=GRPERR CRITICAL: Pair 'GRPERR - GRPERR-PAIR01' Status (L/R): PSUE/PSUE (sync: 0%/0%)
... 7 --group-id=GRP2 --remote-instance-id=+10 OK: Pair 'GRP2 - GRP2-PAIR01' Status (L/R): PAIR/PAIR (sync: 100%/100%)
2 changes: 1 addition & 1 deletion tests/storage/hitachi/eseries/local/path-status.robot
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ path-status ${tc}
[Tags] storage hitachi eseries local path
${command} Catenate
... ${CMD}
... --baie-id=0123
... --instance-id=0123
... --mode=path-status
... ${extra_options}

Expand Down
2 changes: 1 addition & 1 deletion tests/storage/hitachi/eseries/local/pool.robot
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Test Timeout 120s


*** Variables ***
${CMD} ${CENTREON_PLUGINS} --plugin=storage::hitachi::eseries::local::plugin --baie-id=0123 --command-path=${CURDIR}${/}bin
${CMD} ${CENTREON_PLUGINS} --plugin=storage::hitachi::eseries::local::plugin --instance-id=0123 --command-path=${CURDIR}${/}bin


*** Test Cases ***
Expand Down
2 changes: 1 addition & 1 deletion tests/storage/hitachi/eseries/local/quorum.robot
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Test Timeout 120s


*** Variables ***
${CMD} ${CENTREON_PLUGINS} --plugin=storage::hitachi::eseries::local::plugin --baie-id=0123 --command-path=${CURDIR}${/}bin
${CMD} ${CENTREON_PLUGINS} --plugin=storage::hitachi::eseries::local::plugin --instance-id=0123 --command-path=${CURDIR}${/}bin


*** Test Cases ***
Expand Down
Loading