Created
April 7, 2013 06:09
-
-
Save yath/5329253 to your computer and use it in GitHub Desktop.
smartd mail script
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
#!/bin/sh | |
# send smartd mail plus serial and smartctl -a. | |
# usage: -m root -M exec /path/to/this/script | |
# test with: -m root -M exec /path/to/this/script -M test and smartctl -q onecheck afterwards. | |
tempfile=$(mktemp) | |
# message is passed via stdin | |
cat > $tempfile | |
# append smartctl -a | |
/usr/sbin/smartctl -a -d "$SMARTD_DEVICETYPE" "$SMARTD_DEVICE" >> $tempfile | |
SERIAL="$(hdparm -I "$SMARTD_DEVICE" | awk '/Serial Number/ { print $3 }')" | |
mail -s "$SMARTD_SUBJECT [$SERIAL $SMARTD_DEVICE]" $SMARTD_ADDRESS < $tempfile | |
rm -f "$tempfile" | |
# And exit | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment