Skip to content

Commit

Permalink
Make Off-line Collection More Tolerant
Browse files Browse the repository at this point in the history
It is not uncommon for offline data collection to be aborted, or on
devices that do not have such checks never started.  This removes
the logic that bombs out returning WARNING or UNKNOWN and just echos
the status to the output.  Also corrects a formatting problem which
didn't take into account the longest output text
  • Loading branch information
Simon Murray committed Jan 7, 2016
1 parent 26bf1d8 commit cd8816a
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions check_scsi_smart.c
Original file line number Diff line number Diff line change
Expand Up @@ -512,21 +512,18 @@ int main(int argc, char** argv) {
ata_smart_read_data(fd, (unsigned char*)&sd);

if((sd.offline_data_collection_status & 0x7f) == SMART_OFF_LINE_STATUS_NEVER_STARTED) {
printf("UNKNOWN: Off-line data collection never started\n");
exit(NAGIOS_UNKNOWN);
printf("Off-line data collection: never started\n");
}

if((sd.offline_data_collection_status & 0x7f) == SMART_OFF_LINE_STATUS_SUSPENDED ||
(sd.offline_data_collection_status & 0x7f) == SMART_OFF_LINE_STATUS_ABORTED_HOST ||
(sd.offline_data_collection_status & 0x7f) == SMART_OFF_LINE_STATUS_ABORTED_DEVICE) {
printf("WARNING: Off-line data collection suspended/aborted\n");
exit(NAGIOS_WARNING);
printf("Off-line data collection: suspended/aborted\n");
}

if((sd.offline_data_collection_status & 0x7f) != SMART_OFF_LINE_STATUS_COMPLETED &&
(sd.offline_data_collection_status & 0x7f) != SMART_OFF_LINE_STATUS_IN_PROGRESS) {
printf("UNKNOWN: Off-line data collection in unknown state\n");
exit(NAGIOS_UNKNOWN);
printf("Off-line data collection: unknown state\n");
}

/* Perform actual SMART threshold checks */
Expand All @@ -535,7 +532,7 @@ int main(int argc, char** argv) {
smart_thresholds st;
ata_smart_read_thresholds(fd, (unsigned char*)&st);

printf("ID Name Value Worst Thresh Type Updated Raw Status\n");
printf("ID Name Value Worst Thresh Type Updated Raw Status\n");

int i=0;
for(; i<SMART_ATTRIBUTE_NUM; i++) {
Expand All @@ -558,7 +555,7 @@ int main(int argc, char** argv) {
}
}

printf("%3d %-32s %03d %03d %03d %-8s %-7s %-11d %s\n",
printf("%3d %-44s %03d %03d %03d %-8s %-7s %-11d %s\n",
sd.attributes[i].id,
smart_id_to_text(sd.attributes[i].id),
sd.attributes[i].value,
Expand Down

0 comments on commit cd8816a

Please sign in to comment.