Last active
November 28, 2021 21:24
-
-
Save DanielOaks/ac3dc2341e0876188eca2190b3aa0cdb to your computer and use it in GitHub Desktop.
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 | |
# SMARTd discord notifier | |
export WEBHOOK_URL="https://discord.com/api/webhooks/YOUR_WEBHOOK_HERE" | |
export TMP_FILE=/tmp/smartd-discord | |
# assemble file | |
echo "**S.M.A.R.T. ERROR**" > $TMP_FILE | |
echo "> $SMARTD_MESSAGE" >> $TMP_FILE | |
#echo "> $SMARTD_DEVICEINFO" >> $TMP_FILE | |
echo '> ```' >> $TMP_FILE | |
lsblk $SMARTD_DEVICE | sed 's/^/> /' >> $TMP_FILE | |
echo '> ```' >> $TMP_FILE | |
echo "> Error first appeared $SMARTD_TFIRST and has appeared $SMARTD_PREVCNT times previously" >> $TMP_FILE | |
# send | |
export CONTENT=$(jq -n --arg username "smartd" --arg content "$(cat $TMP_FILE)" '{"username": $username, "content": $content}') | |
curl -s \ | |
-H "Content-Type: application/json" \ | |
-d "$CONTENT" \ | |
"$WEBHOOK_URL" \ | |
> /dev/null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment