Created
August 16, 2015 17:35
-
-
Save hardware/bcf4c5543c02eee82f67 to your computer and use it in GitHub Desktop.
Smartd notification
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 | |
TMP_FILE=/tmp/smartd_report | |
echo "" > $TMP_FILE | |
# Arguments | |
echo "Command line argument 1:" >> $TMP_FILE | |
echo $1 >> $TMP_FILE | |
echo "Command line argument 2:" >> $TMP_FILE | |
echo $2 >> $TMP_FILE | |
echo "Command line argument 3:" >> $TMP_FILE | |
echo $3 >> $TMP_FILE | |
# Variables d'environnement | |
echo "Variables are:" >> $TMP_FILE | |
echo "$SMARTD_DEVICE" >> $TMP_FILE | |
echo "$SMARTD_DEVICESTRING" >> $TMP_FILE | |
echo "$SMARTD_DEVICETYPE" >> $TMP_FILE | |
echo "$SMARTD_MESSAGE" >> $TMP_FILE | |
echo "$SMARTD_FULLMESSAGE" >> $TMP_FILE | |
echo "$SMARTD_ADDRESS" >> $TMP_FILE | |
echo "$SMARTD_SUBJECT" >> $TMP_FILE | |
echo "$SMARTD_TFIRST" >> $TMP_FILE | |
echo "$SMARTD_TFIRSTEPOCH" >> $TMP_FILE | |
# Génération d'un rapport complet sur le disque concerné | |
/usr/sbin/smartctl -a -d $SMARTD_DEVICETYPE $SMARTD_DEVICE >> $TMP_FILE | |
MESSAGE="[SMARTD ALERT] Une erreur est survenue sur le disque ${SMARTD_DEVICE}, veuillez procéder à une sauvegarde immédiate des données !" | |
# Notification KDE | |
/usr/bin/kdialog --error "$MESSAGE" --title "Erreur S.M.A.R.T - ${SMARTD_DEVICE}" | |
# Notification console | |
wall <<EOF | |
/!\ [SMARTD ALERT] /!\\ | |
Problem detected with disk: $SMARTD_DEVICESTRING | |
Warning message from smartd is: $SMARTD_MESSAGE | |
Report is available here : $TMP_FILE | |
EOF | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment