# Check that a hash entry is defined and not an empty string. Return a
# chosen string (parameter) if these conditions are not met
-sub get_hash_string {
+sub get_nonempty_string {
my $key = shift; # key to check
my $hash = shift; # hash where the key belongs
my $alt = shift; # alternate return value
$nexus = $out->{ID};
$name = $out->{Name};
$state = $out->{State};
- $status = get_hash_string('Status', $out, 'Unknown');
+ $status = get_nonempty_string('Status', $out, 'Unknown');
$minfw = $out->{'Minimum Required Firmware Version'} ne 'Not Applicable'
? $out->{'Minimum Required Firmware Version'} : undef;
$mindr = $out->{'Minimum Required Driver Version'} ne 'Not Applicable'
else {
$name = $out->{'Name'};
$state = $out->{'State'};
- $status = get_hash_string('Status', $out, 'Unknown');
+ $status = get_nonempty_string('Status', $out, 'Unknown');
$fpred = lc($out->{'Failure Predicted'}) eq 'yes' ? 1 : 0;
$progr = ' [' . $out->{'Progress'} . ']';
$ctrl = $out->{'ctrl'};
else {
$dev = $out->{'Device Name'};
$state = $out->{State};
- $status = get_hash_string('Status', $out, 'Unknown');
+ $status = get_nonempty_string('Status', $out, 'Unknown');
$layout = $out->{Layout};
$size = $out->{Size};
$progr = ' [' . $out->{Progress} . ']';
else {
$id = $out->{'ID'};
$state = $out->{'State'};
- $status = get_hash_string('Status', $out, 'Unknown');
+ $status = get_nonempty_string('Status', $out, 'Unknown');
$learn = $out->{'Learn State'};
$pred = $out->{'Predicted Capacity Status'};
$ctrl = $out->{'ctrl'};
else {
$name = $out->{'Name'};
$state = $out->{'State'};
- $status = get_hash_string('Status', $out, 'Unknown');
+ $status = get_nonempty_string('Status', $out, 'Unknown');
$type = $out->{'Connector Type'};
$ctrl = $out->{ctrl};
$nexus = join q{:}, $out->{ctrl}, $out->{'ID'};
$id = $out->{ID};
$name = $out->{Name};
$state = $out->{State};
- $status = get_hash_string('Status', $out, 'Unknown');
+ $status = get_nonempty_string('Status', $out, 'Unknown');
$firmware = $out->{'Firmware Version'} ne 'Not Applicable'
? $out->{'Firmware Version'} : 'N/A';
$nexus = join q{:}, $out->{ctrl}, $id;
else {
$name = $out->{'Name'};
$state = $out->{'State'};
- $status = get_hash_string('Status', $out, 'Unknown');
+ $status = get_nonempty_string('Status', $out, 'Unknown');
$speed = $out->{'Speed'};
$encl_id = join q{:}, $out->{ctrl}, $out->{'encl_id'};
$encl_name = $out->{encl_name};
else {
$name = $out->{'Name'};
$state = $out->{'State'};
- $status = get_hash_string('Status', $out, 'Unknown');
+ $status = get_nonempty_string('Status', $out, 'Unknown');
$encl_id = join q{:}, $out->{ctrl}, $out->{'encl_id'};
$encl_name = $out->{encl_name};
$nexus = join q{:}, $out->{ctrl}, $out->{'encl_id'}, $out->{'ID'};
else {
$name = $out->{'Name'};
$state = $out->{'State'};
- $status = get_hash_string('Status', $out, 'Unknown');
+ $status = get_nonempty_string('Status', $out, 'Unknown');
$unit = 'FIXME';
$reading = $out->{'Reading'};
$max_warn = $out->{'Maximum Warning Threshold'};
else {
$name = $out->{'Name'};
$state = $out->{'State'};
- $status = get_hash_string('Status', $out, 'Unknown');
+ $status = get_nonempty_string('Status', $out, 'Unknown');
$encl_id = join q{:}, $out->{ctrl}, $out->{'encl_id'};
$encl_name = $out->{encl_name};
$nexus = join q{:}, $out->{ctrl}, $out->{'encl_id'}, $out->{'ID'};
}
else {
$index = $out->{'Type'} eq '[Not Occupied]' ? undef : $out->{'Index'};
- $status = get_hash_string('Status', $out, 'Unknown');
+ $status = get_nonempty_string('Status', $out, 'Unknown');
$location = $out->{'Connector Name'};
$size = $out->{'Size'};
if (defined $size) {
}
else {
$index = $out->{'Index'};
- $status = get_hash_string('Status', $out, 'Unknown');
+ $status = get_nonempty_string('Status', $out, 'Unknown');
$reading = $out->{'Reading'};
$location = $out->{'Probe Name'};
$max_crit = $out->{'Maximum Failure Threshold'} ne '[N/A]'
}
else {
$index = $out->{'Index'};
- $status = get_hash_string('Status', $out, 'Unknown');
+ $status = get_nonempty_string('Status', $out, 'Unknown');
$type = $out->{'Type'};
$state = $out->{'Online Status'};
}
}
else {
$index = $out->{'Index'};
- $status = get_hash_string('Status', $out, 'Unknown');
+ $status = get_nonempty_string('Status', $out, 'Unknown');
$reading = $out->{'Reading'}; $reading =~ s{\.0\s+C}{}xms;
$location = $out->{'Probe Name'};
$max_crit = $out->{'Maximum Failure Threshold'}; $max_crit =~ s{\.0\s+C}{}xms;
}
else {
$index = $out->{'Index'};
- $status = get_hash_string('Status', $out, 'Unknown');
+ $status = get_nonempty_string('Status', $out, 'Unknown');
$state = $out->{'State'};
$brand = exists $out->{'Processor Brand'} ? $out->{'Processor Brand'} : undef;
$family = exists $out->{'Processor Family'} ? $out->{'Processor Family'} : undef;
}
else {
$index = $out->{'Index'};
- $status = get_hash_string('Status', $out, 'Unknown');
+ $status = get_nonempty_string('Status', $out, 'Unknown');
$reading = $out->{'Reading'};
$location = $out->{'Probe Name'};
}
}
else {
$index = $out->{'Index'};
- $status = get_hash_string('Status', $out, 'Unknown');
+ $status = get_nonempty_string('Status', $out, 'Unknown');
$reading = $out->{'Reading'};
$location = $out->{'Probe Name'};
}
else {
$index = $out->{'Index'};
next AMP if (!defined $index || $index !~ m/^\d+$/x);
- $status = get_hash_string('Status', $out, 'Unknown');
+ $status = get_nonempty_string('Status', $out, 'Unknown');
$reading = $out->{'Reading'};
$location = $out->{'Probe Name'};
$max_crit = $out->{'Failure Threshold'} ne '[N/A]'
}
else {
$index = $out->{'Index'};
- $status = get_hash_string('Status', $out, 'Unknown');
+ $status = get_nonempty_string('Status', $out, 'Unknown');
$reading = $out->{'State'};
}
}
else {
$index = $c++;
- $status = get_hash_string('Status', $out, 'Ok');
+ $status = get_nonempty_string('Status', $out, 'Ok');
$state = $out->{'State'};
$location = $out->{'Connector Name'};
$capacity = $out->{'Storage Size'} ne '[Not Available]'