Skip to content

Instantly share code, notes, and snippets.

@gobenji
Created February 11, 2022 00:53
Show Gist options
  • Save gobenji/576593ab5e5fd5b2d131627b01164f54 to your computer and use it in GitHub Desktop.
Save gobenji/576593ab5e5fd5b2d131627b01164f54 to your computer and use it in GitHub Desktop.
Modified /etc/smartmontools/run.d/10mail to workaround https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=900244
#!/bin/bash -e
# Send mail if /usr/bin/mail exists
if ! [ -x /usr/bin/mail ]; then
echo "Your system does not have /usr/bin/mail. Install the mailx or mailutils package"
exit 1
fi
# workaround debian bug 900244
if [[ $SMARTD_MESSAGE == "Device: /dev/nvme1, number of Error Log entries increased from"* ]] && \
[ $(/usr/sbin/nvme error-log -o json "$SMARTD_DEVICE" | \
jq '.errors | map(select(.status_field |
IN(0, 8194, 16388) | not)) | length') -eq 0 ]; then
echo "Spurious error count increase, not sending mail."
exit
fi
input=$1
shift
/usr/bin/mail "$@" < $input
@gobenji
Copy link
Author

gobenji commented Feb 11, 2022

From my observations, the apparently spurious error log entries have status_field values 0x2002 or 0x4004. The second part of the condition checks that those are the only entries before suppressing the email notification.
I think the meaning of status_field is according to the following bits nvme.h

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment