#!/bin/bash # Checks status of disks SMART STATUS_LABEL="SMART Health Status:" STATUS_OK="$STATUS_LABEL OK" if [[ "$#" == "0" ]]; then echo "Usage: $0 [ ... ]" exit fi for DISK in "$@" do STATUS=$(sudo /usr/sbin/smartctl -H -d scsi "$DISK" | grep "$STATUS_LABEL") if [ "$STATUS" != "$STATUS_OK" ]; then echo "CRITICAL: $DISK: $STATUS" exit 2 fi done echo "OK: $STATUS_OK"