Comment 13 for bug 1833331

Revision history for this message
Christian Franke (christian-franke) wrote :

> At quick glance, I don't see a quick and easy way to test email notifications.

1. '-M test' in smartd.conf enables test messages. Here a quick example which does not touch smartd.conf and runs only one smartd check cycle in debug mode:

# sed -n '/^DEVICESCAN/s,$, -M test,p' /etc/smartd.conf \
  | /usr/sbin/smartd -c - -q onecheck

2. Or: run smartd's internal warning script directly. This does not require root and does not access any device. Set SMARTD_ADDRESS from '-m ...' and SMARTD_MAILER from '-M exec ...'. Example:

$ <email address hidden>' \
  SMARTD_MAILER=/usr/share/smartmontools/smartd-runner \
  /usr/share/smartd_warning.sh --dryrun

Remove --dryrun to actually exec .../smartd-runner.

@Christian E. - A possible enhancement for 10mail would be to fall back to sendmail if mail is not available. Something like:

#!/bin/bash
mail=/usr/bin/mail
sendmail=/usr/sbin/sendmail
if [ -x $mail ]; then
  echo "$SMARTD_FULLMESSAGE" | $mail -s "$SMARTD_SUBJECT" $SMARTD_ADDRESS
elif [ -x $sendmail ]; then
  $sendmail $SMARTD_ADDRESS <<EOF
Subject: $SMARTD_SUBJECT
To: ${SMARTD_ADDRESS// /, }

$SMARTD_FULLMESSAGE
EOF
else
  echo "Found neither $mail nor $sendmail"
  exit 1
fi