Created
September 15, 2018 13:07
-
-
Save FlorianHeigl/a23aba3a96a27733fb94fdb0a4922b95 to your computer and use it in GitHub Desktop.
check_mk local check for smart on freeebsd (from elsewhere, limited functionality, better than none)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/bash | |
# https://github.com/zmielna/smart_diskinfo | |
# Backblaze chaps have 40k disks and they care about SMART 187 mainly | |
# see https://www.backblaze.com/blog/hard-drive-smart-stats/ | |
# This is Check_mk local check script for FreeBSD based NAS like NAS4FREE | |
# Drop a copy to /usr/lib/check_mk_agent/local/ | |
# you can "telnet nas4free.domain.com 6556" from your OMD server to see if it works. | |
# | |
# SMART 5 \u2013 Reallocated_Sector_Count. | |
# SMART 187 \u2013 Reported_Uncorrectable_Errors. | |
# SMART 188 \u2013 Command_Timeout. | |
# SMART 197 \u2013 Current_Pending_Sector_Count. | |
# SMART 198 \u2013 Offline_Uncorrectable. | |
# So we care mostly about 187 but if your disk doesn't return this value use 198 or other | |
# | |
# For linux change /dev/ada? to /dev/sd? | |
function get_smart() { | |
unset SMARTDATA | |
SMARTDATA=$( smartctl -a "${_disk}" ) | |
export SMARTDATA | |
} | |
function check_errors() { | |
ERRORS=0 | |
if echo "${SMARTDATA}" | grep ^187 ; then | |
ERRORS=$( echo "${SMARTDATA}" | grep ^187 | awk '{print $NF}' ) | |
fi | |
} | |
for _disk in $(ls /dev/da? /dev/da??) ; do | |
get_smart ${_disk} | |
check_errors ${_disk} | |
if [[ "$ERRORS" -gt "0" ]] ; then | |
echo "2 Disk_${_disk} Reported_Uncorrectable_Errors=$ERRORS;1;5 CRITICAL - Disk ${_disk} has $ERRORS Uncorrectable Errors Reported!" | |
else | |
echo "0 Disk_${_disk} Reported_Uncorrectable_Errors=$ERRORS;1;5 OK - Disk ${_disk} has $ERRORS Uncorrectable Errors Reported" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment