This bash script designed for monitoring the state of a node and automatically unjail validator and/or restarting node in the case of an unexpected node halt or lost of sync state.
- For keyring password create the file
<pass.key>
and write the password to it.
read -s -p "Enter password: " pass
echo $pass > pass.key
unset pass
- Modify file access to 400 (read only)
chmod 400 pass.key
- Set exec permission for this shell script
chmod +x watchdog.sh
- Add the script launch every 5 min to cron
crontab -e
*/5 * * * * $HOME/watchdog.sh >> $HOME/watchdog.log
- IMPORTANT!!!
Your current user must have a
sudo
privileges and have sudo password request disabled for/bin/systemctl
.
echo "$(whoami) ALL=(ALL) NOPASSWD: /bin/systemctl" | sudo tee -a /etc/sudoers > /dev/null
Change the variables in the watchdog.sh
according to your node settings.
# full path to client binary (NOT node binary)
binary_path=""
# name of the account that signs the transactions
account_name=""
# name of the service file
service_name=""
# max acceptable block production delay in seconds,
# which will be considered as normal
allowed_delay=""
# RPC point for node (default tcp://127.0.0.1:26657
node=""
All restart and unjail events are written to log file $HOME/watchdog.log