I developed this code to notify me when my node it’s down
#!/bin/bash VAR1=`timeout --foreground -s SIGINT 1s docker exec -it storagenode /app/dashboard.sh | grep "Last Contact"` VAR2=`cat output.txt` if [[ $VAR1 =~ "ONLINE" ]]; then rm output.txt echo "Online" elif [[ -n $VAR2 ]]; then echo "Continues Offline" else rm output.txt echo "Offline" > output.txt GET "http://api.callmebot.com/start.php?user=@telegram user&text=urlencodedmessage&lang=lenguage&rpt=timestorepeat" fi
It uses the CLI dashboard and the grep command to store the status line as a varible, if it’s online, it does nothing, if it’s offline and it’s first time it sees it offline, it will use GET and CallMeBot to call me on Telegram (you can obtain you URL from callmebot.com with your Telegram user and message in your lenguage and set up the times it repeats the message), then, it will save a file called output.txt so that when the script runs again, it will know that you have been already notified and it won’t call you every minute.
You can set this up as a cron job, so it runs it every minute or what ever you want it to be, I recommend putting it in a folder so output.txt doesn’t mess with other programs outputs.
Keep in mind that this will not work if your server is offline because it is powered off