It is assumed you run a linux distro, the following example works with debian.
Put in your crontab by doing "crontab -e":
#Check bitcoind once every 3 hours. If it's not active, then send an e-mail alert.
00 */3 * * * /bin/bash /home/myuser/path/checknode.sh IPADDRESSOFNODE
Remember to restart crontab daemon every time you have changed the crontab:
su service cron restart
checknode.sh:
#!/bin/bash
#Checks if the bitcoin node is up and accepts connections.
cd /home/myuser/code/bitnodes
#If the server is up and accepts connections, the response below becomes 0, bitcoind down gives 1.
RES=$(/usr/bin/python protocol.py $1 | /bin/grep refused | /usr/bin/wc -l)
if [ $RES -eq 1 ]; then
echo "Admin maintenance alert, daemon down!" | mail -s "Alert message"
[email protected]fi
The bitnodes code including protocol.py can be fetched from here.
https://github.com/ayeowch/bitnodesNot sure about the dependencies, you might experiment if you want to have as few files as possible in the bitnodes directory. Easiest is to get all files. The code is the same that's behind
https://getaddr.bitnodes.ioexample:
git clone
https://github.com/ayeowch/bitnodes.gitConsidered you've set up everything correctly, the node monitoring will check your node every 3 hours, and send you a notice on e-mail if it's not possible to connect to it with the bitcoin protocol. For testing purposes you might manually shut down the daemon and set crontab intervall to let's say every minute, to ensure the e-mail is sent when the node is down.
This method is nice, as if you rely on manually checking your node, it might be down for a while before you notice. Since your node is not critical to the network, checking that is is operating with a 3 hour interval might be ok, if you think it should be checked more often, set the interval to what you want.
You might also extend the script to restart the daemon automatically if it's not reachable, instead of logging in and doing it manually when you get the e-mail alert. In that case, you could just send yourself an e-mail saying something like: "Daemon went down, but was automatically restarted."
As bitcoin core is quite stable and does not go down very often, a simple e-mail notification might be sufficient. The assumption is that if you fork out the money to run a VPS node, you want it to be running most of the time.