Created
November 8, 2018 20:44
-
-
Save xotonic/2794946da534155da5f521eff4778a8e to your computer and use it in GitHub Desktop.
Setting up Telegram bot to check alive status for LUX masternode
This file contains hidden or 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/bash | |
# Setup: | |
# sudo apt-get install python3-pip python3-setuputils | |
# sudo pip3 install --upgrade pip | |
# sudo pip3 install telegram-send | |
# telegram-send --configure | |
# Follow instuctions to create bot | |
# Place this file to $HOME(now it is /home/luxadmin) and replace IP var with your this masternode address | |
# crontab -e | |
# add line: * * * * * /home/luxadmin/healthcheck.sh >> /home/luxadmin/log-health.log 2>&1 | |
# Now you should receive messages about the node status change (up, down) | |
STATUS="/home/luxadmin/.mn_status" | |
BOT="/usr/local/bin/telegram-send" | |
IP="0.0.0.0" # replace it | |
UP=$(/home/luxadmin/lux-cli masternode list | grep $IP | wc -l) | |
if [ $UP -ne "1" ] ; then | |
if [ ! -f "$STATUS" ] ; then | |
echo -e "\U0001F480 Masternode is down! ($IP)" | /usr/local/bin/telegram-send --pre --stdin | |
fi | |
echo $UP > $STATUS | |
else | |
if [ -f "$STATUS" ] ; then | |
echo -e "\U0001F4B0 Masternode is back ($IP)" | /usr/local/bin/telegram-send --pre --stdin | |
fi | |
rm -f $STATUS | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment