# Version and similar info
$NAME = 'check_openmanage';
-$VERSION = '3.6.2-beta6';
+$VERSION = '3.6.2-beta7';
$AUTHOR = 'Trond H. Amundsen';
$CONTACT = 't.h.amundsen@usit.uio.no';
CTRL:
foreach my $out (@output) {
if ($snmp) {
- $name = $out->{controllerName};
+ $name = $out->{controllerName} || 'Unknown controller';
$state = get_hashval($out->{controllerState}, \%ctrl_state);
$status = get_snmp_status($out->{controllerComponentStatus});
- $minfw = exists $out->{controllerMinFWVersion}
- ? $out->{controllerMinFWVersion} : undef;
- $mindr = exists $out->{controllerMinDriverVersion}
- ? $out->{controllerMinDriverVersion} : undef;
- $firmware = exists $out->{controllerFWVersion}
- ? $out->{controllerFWVersion} : 'N/A';
- $driver = exists $out->{controllerDriverVersion}
- ? $out->{controllerDriverVersion} : 'N/A';
- $minstdr = exists $out->{'controllerMinRequiredStorportVer'}
- ? $out->{controllerMinRequiredStorportVer} : undef;
- $stdr = exists $out->{controllerStorportDriverVersion}
- ? $out->{controllerStorportDriverVersion} : undef;
+ $minfw = $out->{controllerMinFWVersion} || undef;
+ $mindr = $out->{controllerMinDriverVersion} || undef;
+ $firmware = $out->{controllerFWVersion} || 'N/A';
+ $driver = $out->{controllerDriverVersion} || 'N/A';
+ $minstdr = $out->{'controllerMinRequiredStorportVer'} || undef;
+ $stdr = $out->{controllerStorportDriverVersion} || undef;
$nexus = convert_nexus($out->{controllerNexusID});
}
else {
- $nexus = $out->{ID};
- $name = $out->{Name};
- $state = $out->{State};
+ $nexus = get_nonempty_string('ID', $out, '9999');
+ $name = get_nonempty_string('Name', $out, 'Unknown controller');
+ $state = get_nonempty_string('State', $out, 'Unknown state');
$status = get_nonempty_string('Status', $out, 'Unknown');
$minfw = $out->{'Minimum Required Firmware Version'} ne 'Not Applicable'
? $out->{'Minimum Required Firmware Version'} : undef;
PDISK:
foreach my $out (@output) {
if ($snmp) {
- $name = $out->{arrayDiskName};
+ $name = $out->{arrayDiskName} || 'Unknown disk';
$state = get_hashval($out->{arrayDiskState}, \%pdisk_state);
$status = get_snmp_status($out->{arrayDiskComponentStatus});
- $fpred = exists $out->{arrayDiskSmartAlertIndication}
+ $fpred = defined $out->{arrayDiskSmartAlertIndication}
&& $out->{arrayDiskSmartAlertIndication} == 2 ? 1 : 0;
$progr = q{};
$nexus = convert_nexus($out->{arrayDiskNexusID});
- $vendor = exists $out->{arrayDiskVendor}
- ? $out->{arrayDiskVendor} : 'Unknown Vendor';
- $product = exists $out->{arrayDiskProductID}
- ? $out->{arrayDiskProductID} : 'Unknown Product ID';
+ $vendor = $out->{arrayDiskVendor} || 'Unknown vendor';
+ $product = $out->{arrayDiskProductID} || 'Unknown product ID';
$spare = get_hashval($out->{arrayDiskSpareState}, \%spare_state);
$bus = exists $out->{arrayDiskBusType}
? get_hashval($out->{arrayDiskBusType}, \%bus_type) : undef;
}
}
else {
- $name = $out->{'Name'};
- $state = $out->{'State'};
+ $name = get_nonempty_string('Name', $out, 'Unknown disk');
+ $state = get_nonempty_string('State', $out, 'Unknown state');
$status = get_nonempty_string('Status', $out, 'Unknown');
- $fpred = lc($out->{'Failure Predicted'}) eq 'yes' ? 1 : 0;
- $progr = ' [' . $out->{'Progress'} . ']';
- $ctrl = $out->{'ctrl'};
+ $fpred = lc(get_nonempty_string('Failure Predicted', $out, q{})) eq 'yes' ? 1 : 0;
+ $progr = ' [' . get_nonempty_string('Progress', $out, q{}) . ']';
$nexus = join q{:}, $out->{ctrl}, $out->{'ID'};
- $vendor = $out->{'Vendor ID'} ne q{} ? $out->{'Vendor ID'} : 'Unknown Vendor';
- $product = $out->{'Product ID'} ne q{} ? $out->{'Product ID'} : 'Unknown Product ID';
- $media = $out->{'Media'};
- $spare = $out->{'Hot Spare'};
- $bus = $out->{'Bus Protocol'};
- $capacity = $out->{'Capacity'};
+ $vendor = get_nonempty_string('Vendor ID', $out, 'Unknown Vendor');
+ $product = get_nonempty_string('Product ID', $out, 'Unknown Product ID');
+ $media = get_nonempty_string('Media', $out, undef);
+ $bus = get_nonempty_string('Bus Protocol', $out, undef);
+ $spare = get_nonempty_string('Hot Spare', $out, q{});
+ $ctrl = $out->{ctrl};
+ $capacity = get_nonempty_string('Capacity', $out, q{});
$capacity =~ s{\A .*? \((\d+) \s bytes\) \z}{$1}xms;
if ($capacity eq 'Unavailable') {
$capacity = -1;
VDISK:
foreach my $out (@output) {
if ($snmp) {
- $dev = $out->{virtualDiskDeviceName};
+ $dev = $out->{virtualDiskDeviceName} || 'Unknown device';
$state = get_hashval($out->{virtualDiskState}, \%vdisk_state);
$layout = get_hashval($out->{virtualDiskLayout}, \%vdisk_layout);
$status = get_snmp_status($out->{virtualDiskComponentStatus});
- $size = sprintf '%.2f GB', $out->{virtualDiskLengthInMB} / 1024;
- $progr = q{}; # can't get this from SNMP(?)
- $nexus = convert_nexus($out->{virtualDiskNexusID});
+ $size = sprintf '%.2f GB', ($out->{virtualDiskLengthInMB} || 0) / 1024;
+ $progr = q{}; # not available via SNMP
+ $nexus = convert_nexus(($out->{virtualDiskNexusID} || 9999));
}
else {
- $dev = $out->{'Device Name'};
- $state = $out->{State};
+ $dev = get_nonempty_string('Device Name', $out, 'Unknown device');
+ $state = get_nonempty_string('State', $out, 'Unknown state');
$status = get_nonempty_string('Status', $out, 'Unknown');
- $layout = $out->{Layout};
- $size = $out->{Size};
- $progr = ' [' . $out->{Progress} . ']';
+ $layout = get_nonempty_string('Layout', $out, 'Unknown layout');
+ $size = get_nonempty_string('Size', $out, 'Unavailable');
$size =~ s{\A (.*GB).* \z}{$1}xms;
- $nexus = join q{:}, $out->{ctrl}, $out->{ID};
+ $progr = ' [' . get_nonempty_string('Progress', $out, q{}) . ']';
$ctrl = $out->{ctrl};
+ $nexus = join q{:}, $ctrl, get_nonempty_string('ID', $out, '9999');
}
next VDISK if blacklisted('vdisk', $nexus);
$state = get_hashval($out->{batteryState}, \%bat_state);
$learn = get_hashval($out->{batteryLearnState}, \%bat_learn_state);
$pred = get_hashval($out->{batteryPredictedCapacity}, \%bat_pred_cap);
- $ctrl = $out->{batteryConnectionControllerNumber} - 1;
- $nexus = convert_nexus($out->{batteryNexusID});
+ $ctrl = ($out->{batteryConnectionControllerNumber} || 10000) - 1;
+ $nexus = convert_nexus(($out->{batteryNexusID} || 9999));
$id = $nexus;
$id =~ s{\A \d+:(\d+) \z}{$1}xms;
}
else {
- $id = $out->{'ID'};
- $state = $out->{'State'};
+ $id = get_nonempty_string('ID', $out, 9999);
+ $state = get_nonempty_string('State', $out, 'Unknown state');
$status = get_nonempty_string('Status', $out, 'Unknown');
- $learn = $out->{'Learn State'};
- $pred = $out->{'Predicted Capacity Status'};
+ $learn = get_nonempty_string('Learn State', $out, 'Unknown learn state');
+ $pred = get_nonempty_string('Predicted Capacity Status', $out, 'Unknown predicted capacity status');
$ctrl = $out->{'ctrl'};
$nexus = join q{:}, $out->{ctrl}, $id;
}
CHANNEL:
foreach my $out (@output) {
if ($snmp) {
- $name = $out->{channelName};
+ $name = $out->{channelName} || 'Unknown channel';
$status = get_snmp_status($out->{channelComponentStatus});
$state = get_hashval($out->{channelState}, \%conn_state);
$type = get_hashval($out->{channelBusType}, \%conn_bustype);
- $nexus = convert_nexus($out->{channelNexusID});
+ $nexus = convert_nexus(($out->{channelNexusID} || 9999));
$ctrl = $nexus;
$ctrl =~ s{(\d+):\d+}{$1}xms;
- # workaround for ancient OMSA versions
- if (! defined $type) { $type = 'n/a'; }
}
else {
- $name = $out->{'Name'};
- $state = $out->{'State'};
+ $name = get_nonempty_string('Name', $out, 'Unknown channel');
+ $state = get_nonempty_string('State', $out, 'Unknown state');
$status = get_nonempty_string('Status', $out, 'Unknown');
- $type = $out->{'Connector Type'};
+ $type = get_nonempty_string('Connector Type', $out, 'Unknown type');
$ctrl = $out->{ctrl};
$nexus = join q{:}, $out->{ctrl}, $out->{'ID'};
}
ENCLOSURE:
foreach my $out (@output) {
if ($snmp) {
- $id = $out->{enclosureNumber} - 1;
- $name = $out->{enclosureName};
+ $id = ($out->{enclosureNumber} || 10000) - 1;
+ $name = $out->{enclosureName} || 'Unknown enclosure';
$state = get_hashval($out->{enclosureState}, \%encl_state);
$status = get_snmp_status($out->{enclosureComponentStatus});
- $firmware = exists $out->{enclosureFirmwareVersion}
- ? $out->{enclosureFirmwareVersion} : 'N/A';
- $nexus = convert_nexus($out->{enclosureNexusID});
+ $firmware = $out->{enclosureFirmwareVersion} || 'N/A';
+ $nexus = convert_nexus(($out->{enclosureNexusID} || 9999));
$ctrl = $nexus;
$ctrl =~ s{\A (\d+):.* \z}{$1}xms;
# for the next two, a value of 9999 means feature not available
- $occupied_slots = exists $out->{enclosureOccupiedSlotCount}
+ $occupied_slots = defined $out->{enclosureOccupiedSlotCount}
&& $out->{enclosureOccupiedSlotCount} != 9999
? $out->{enclosureOccupiedSlotCount} : undef;
- $total_slots = exists $out->{enclosureTotalSlots}
+ $total_slots = defined $out->{enclosureTotalSlots}
&& $out->{enclosureTotalSlots} != 9999
? $out->{enclosureTotalSlots} : undef;
}
else {
- $id = $out->{ID};
- $name = $out->{Name};
- $state = $out->{State};
+ $id = get_nonempty_string('ID', $out, 9999);
+ $name = get_nonempty_string('Name', $out, 'Unknown enclosure');
+ $state = get_nonempty_string('State', $out, 'Unknown state');
$status = get_nonempty_string('Status', $out, 'Unknown');
- $firmware = $out->{'Firmware Version'} ne 'Not Applicable'
- ? $out->{'Firmware Version'} : 'N/A';
+ $firmware = get_nonempty_string('Firmware Version', $out, 'N/A');
+ $firmware =~ s{Not\sApplicable}{N/A}xms;
$nexus = join q{:}, $out->{ctrl}, $id;
$ctrl = $out->{ctrl};
}
FAN:
foreach my $out (@output) {
if ($snmp) {
- $name = $out->{fanName};
+ $name = $out->{fanName} || 'Unknown fan';
$state = get_hashval($out->{fanState}, \%fan_state);
$status = get_snmp_status($out->{fanComponentStatus});
- $speed = $out->{fanProbeCurrValue};
- $encl_name = $out->{fanConnectionEnclosureName};
+ $speed = $out->{fanProbeCurrValue} || 'N/A';
+ $encl_name = $out->{fanConnectionEnclosureName} || 'Unknown enclosure';
$encl_id = $snmp_enclosure{$out->{fanConnectionEnclosureNumber}}{nexus};
- $nexus = convert_nexus($out->{fanNexusID});
+ $nexus = convert_nexus(($out->{fanNexusID} || 9999));
}
else {
- $name = $out->{'Name'};
- $state = $out->{'State'};
+ $name = get_nonempty_string('Name', $out, 'Unknown fan');
+ $state = get_nonempty_string('State', $out, 'Unknown state');
$status = get_nonempty_string('Status', $out, 'Unknown');
- $speed = $out->{'Speed'};
+ $speed = get_nonempty_string('Speed', $out, 'N/A');
$encl_id = join q{:}, $out->{ctrl}, $out->{'encl_id'};
$encl_name = $out->{encl_name};
- $nexus = join q{:}, $out->{ctrl}, $out->{'encl_id'}, $out->{'ID'};
+ $nexus = join q{:}, $out->{ctrl}, $out->{'encl_id'}, get_nonempty_string('ID', $out, '9999');
}
next FAN if blacklisted('encl_fan', $nexus);
PS:
foreach my $out (@output) {
if ($snmp) {
- $name = $out->{powerSupplyName};
+ $name = $out->{powerSupplyName} || 'Unknown PSU';
$state = get_hashval($out->{powerSupplyState}, \%ps_state);
$status = get_snmp_status($out->{powerSupplyComponentStatus});
$encl_id = $snmp_enclosure{$out->{powerSupplyConnectionEnclosureNumber}}{nexus};
- $encl_name = $out->{powerSupplyConnectionEnclosureName};
- $nexus = convert_nexus($out->{powerSupplyNexusID});
+ $encl_name = $out->{powerSupplyConnectionEnclosureName} || 'Unknown enclosure';
+ $nexus = convert_nexus(($out->{powerSupplyNexusID} || 9999));
}
else {
- $name = $out->{'Name'};
- $state = $out->{'State'};
+ $name = get_nonempty_string('Name', $out, 'Unknown PSU');
+ $state = get_nonempty_string('State', $out, 'Unknown state');
$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'};
+ $nexus = join q{:}, $out->{ctrl}, $out->{'encl_id'}, get_nonempty_string('ID', $out, '9999');
}
next PS if blacklisted('encl_ps', $nexus);
TEMP:
foreach my $out (@output) {
if ($snmp) {
- $name = $out->{temperatureProbeName};
+ $name = $out->{temperatureProbeName} || 'Unknown temp probe';
$state = get_hashval($out->{temperatureProbeState}, \%temp_state);
$status = get_snmp_probestatus($out->{temperatureProbeComponentStatus});
- $unit = $out->{temperatureProbeUnit};
- $reading = exists $out->{temperatureProbeCurValue}
- ? $out->{temperatureProbeCurValue} : '[N/A]';
- $max_warn = exists $out->{temperatureProbeMaxWarning}
- ? $out->{temperatureProbeMaxWarning} : '[N/A]';
- $max_crit = exists $out->{temperatureProbeMaxCritical}
- ? $out->{temperatureProbeMaxCritical} : '[N/A]';
- $min_warn = exists $out->{temperatureProbeMinWarning}
- ? $out->{temperatureProbeMinWarning} : '[N/A]';
- $min_crit = exists $out->{temperatureProbeMinCritical}
- ? $out->{temperatureProbeMinCritical} : '[N/A]';
+ $unit = $out->{temperatureProbeUnit} || 'Unknown unit';
+ $reading = $out->{temperatureProbeCurValue} || '[N/A]';
+ $max_warn = $out->{temperatureProbeMaxWarning} || '[N/A]';
+ $max_crit = $out->{temperatureProbeMaxCritical} || '[N/A]';
+ $min_warn = $out->{temperatureProbeMinWarning} || '[N/A]';
+ $min_crit = $out->{temperatureProbeMinCritical} || '[N/A]';
$encl_id = $snmp_enclosure{$out->{temperatureConnectionEnclosureNumber}}{nexus};
- $encl_name = $out->{temperatureConnectionEnclosureName};
- $nexus = convert_nexus($out->{temperatureProbeNexusID});
+ $encl_name = $out->{temperatureConnectionEnclosureName} || 'Unknown enclosure';
+ $nexus = convert_nexus(($out->{temperatureProbeNexusID} || 9999));
}
else {
- $name = $out->{'Name'};
- $state = $out->{'State'};
+ $name = get_nonempty_string('Name', $out, 'Unknown temp probe');
+ $state = get_nonempty_string('State', $out, 'Unknown state');
$status = get_nonempty_string('Status', $out, 'Unknown');
$unit = 'FIXME';
- $reading = $out->{'Reading'};
- $max_warn = $out->{'Maximum Warning Threshold'};
- $max_crit = $out->{'Maximum Failure Threshold'};
- $min_warn = $out->{'Minimum Warning Threshold'};
- $min_crit = $out->{'Minimum Failure Threshold'};
+ $reading = get_nonempty_string('Reading', $out, '[N/A]');
+ $max_warn = get_nonempty_string('Maximum Warning Threshold', $out, '[N/A]');
+ $max_crit = get_nonempty_string('Maximum Failure Threshold', $out, '[N/A]');
+ $min_warn = get_nonempty_string('Minimum Warning Threshold', $out, '[N/A]');
+ $min_crit = get_nonempty_string('Minimum Failure Threshold', $out, '[N/A]');
$encl_id = join q{:}, $out->{ctrl}, $out->{'encl_id'};
$encl_name = $out->{encl_name};
- $nexus = join q{:}, $out->{ctrl}, $out->{'encl_id'}, $out->{'ID'};
+ $nexus = join q{:}, $out->{ctrl}, $out->{'encl_id'}, get_nonempty_string('ID', $out, '9999');
}
next TEMP if blacklisted('encl_temp', $nexus);
EMM:
foreach my $out (@output) {
if ($snmp) {
- $name = $out->{enclosureManagementModuleName};
+ $name = $out->{enclosureManagementModuleName} || 'Unknown EMM';
$state = get_hashval($out->{enclosureManagementModuleState}, \%emms_state);
$status = get_snmp_status($out->{enclosureManagementModuleComponentStatus});
$encl_id = $snmp_enclosure{$out->{enclosureManagementModuleConnectionEnclosureNumber}}{nexus};
- $encl_name = $out->{enclosureManagementModuleConnectionEnclosureName};
- $nexus = convert_nexus($out->{enclosureManagementModuleNexusID});
+ $encl_name = $out->{enclosureManagementModuleConnectionEnclosureName} || 'Unknown enclosure';
+ $nexus = convert_nexus(($out->{enclosureManagementModuleNexusID} || 9999));
}
else {
- $name = $out->{'Name'};
- $state = $out->{'State'};
+ $name = get_nonempty_string('Name', $out, 'Unknown EMM');
+ $state = get_nonempty_string('State', $out, 'Unknown state');
$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'};
+ $nexus = join q{:}, $out->{ctrl}, $out->{'encl_id'}, get_nonempty_string('ID', $out, '9999');
}
next EMM if blacklisted('encl_emm', $nexus);