Skip to content

Instantly share code, notes, and snippets.

@NiFNi
Last active March 17, 2018 12:40
Show Gist options
  • Save NiFNi/06646bf595fe9fda4d505991913ce82d to your computer and use it in GitHub Desktop.
Save NiFNi/06646bf595fe9fda4d505991913ce82d to your computer and use it in GitHub Desktop.
Check if a local nano node with RPC enabled is reachable. If not send an email.
# Before usage make sure to have a working mail setup.
# If you are not sure what that means and you run Ubuntu just run "apt install mailutils" and
# choose following settings (be sure to replace example.com with your domain):
# General type of mail configuration?: Internet Site
# System mail name: example.com
# Root and postmaster mail recipient: username
# Other destinations to accept mail for: $myhostname, example.com, mail.example.com, localhost.example.com, localhost
# Force synchronous updates on mail queue?: No
# Local networks: 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
# Mailbox size limit: 0
# Local address extension character: +
# Internet protocols to use: all
# Add this to you cronjob by running "crontab -e" and
# add the following line: "*/5 * * * * bash /path/to/your/check_nano_node.sh > /dev/null 2>&1" (without the quotes)
# Be sure that you replaced the path with your local path to the script.
# This will run the script every 5 minutes and discard any output if it is all fine.
# Check if the rpc is reachable with a simple action
if curl -k --data '{"action": "version"}' http://127.0.0.1:7076; then
echo "success"
else
# If not send the email. Be sure to insert your email here.
echo "Alert: Nano node not reachable!" | mail -s "Nano Node RPC not reachable alert!" example@example.com
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment