This coin daemon for masternode is terribly unreliable.
I host a 32 GB vps with 10 masternodes on it. (yes, swap-file on ssd)
Since there is no solution to get the masternodes running stable, I want to share my script.
I created a crontab (running every 10 minutes). It checks blockcount from explorer and compare to masternode's-blockcount.
If blockcount of any (node or explorer) is newer than (-gap of 5 blocks) OR block is the same as last cron-run (because explorer also hangs sometimes) --> it stop mn-daemon (and systemctl restart it automatically).
Feel free to use this kind of shit-script to keep rewards running. (And yes rewards are still incomming but if your mn hangs on block for several hours, you need to restart mn from wallet again, to get rewards again.
Some of my mn's hangs every ~30-120 minutes, so rewards never began to run.
script.sh#!/bin/bash
#Console Colour
BLUE="\033[0;34m"
YELLOW="\033[0;33m"
CYAN="\033[0;36m"
PURPLE="\033[0;35m"
RED='\033[0;31m'
GREEN="\033[0;32m"
MAG='\e[1;35m'
NC='\033[0m'
coin_cli=/usr/local/bin/quark-cli
blockcount_gap=5
logfile=/root/mnh-status.log
# /root/*subfolder* = masternode-instance
# mn-01 mn-02 mn-03 mn-04 mn-05 mn-06 mn-07 mn-08 mn-09 mn-10
mns=$(ls /root/ | grep mn-)
function log() {
logtime=$(date '+%H:%M:%S')
C=$1
LS="$2"
echo -e "$logtime: ${C}$LS${NC}"
}
function logtf() {
log $1 "$2"
LS="$2"
logtime=$(date '+%Y-%m-%d %H:%M:%S')
echo "$logtime: $LS" >> $logfile
}
blockcount=$(curl -s https://chainz.cryptoid.info/qrk/api.dws?q=getblockcount --max-time 5)
if [ $? -ne 0 ]; then
blockcount=0
fi
lastblockcount=$(cat /root/mnh-lastblock.txt)
if [ $? -ne 0 ]; then
lastblockcount=0
fi
for mn in $mns ; do
mbc=$($coin_cli -datadir=/root/$mn getblockcount 2>/dev/null)
mst=$?
if [ $mst -eq 0 ]; then
if [ $mbc -gt $blockcount ]; then
blockcount=$mbc
fi
fi
done
echo $blockcount > /root/mnh-lastblock.txt
logtf $YELLOW "Highest Block: $blockcount"
logtf $YELLOW " Last Block: $lastblockcount"
if [ $blockcount -le $lastblockcount ]; then
logtf $RED "Same blockcount as last run!"
for mn in $mns ; do
mbc=$($coin_cli -datadir=/root/$mn getblockcount 2>/dev/null)
mst=$?
mbcg=$(($mbc-$blockcount))
logtf $NC "$mn Status: $mst Block: $mbc ($mbcg)"
if [ $mst -eq 0 ]; then
logtf $RED "$mn stopping"
$coin_cli -datadir=/root/$mn stop >/dev/null
fi
done
else
for mn in $mns ; do
mbc=$($coin_cli -datadir=/root/$mn getblockcount 2>/dev/null)
mst=$?
mbcg=$(($mbc-$blockcount))
logtf $NC "$mn Status: $mst Block: $mbc ($mbcg)"
if [ $mst -eq 0 ]; then
if [ $mbc -le $(($blockcount-$blockcount_gap)) ]; then
logtf $RED "$mn stopping"
$coin_cli -datadir=/root/$mn stop >/dev/null
fi
fi
done
fi
to monitor all my nodes I use this little oneliner:
watch -n 1 'echo -n "mn01: " && quark-cli -datadir=/root/mn-01 getblockcount && quark-cli -datadir=/root/mn-01 masternode status | grep status && echo && echo -n "mn02: " && quark-cli -datadir=/root/mn-02 getblockcount && quark-cli -datadir=/root/mn-02 masternode status | grep status && echo && echo -n "mn03: " && quark-cli -datadir=/root/mn-03 getblockcount && quark-cli -datadir=/root/mn-03 masternode status | grep status && echo && echo -n "mn04: " && quark-cli -datadir=/root/mn-04 getblockcount && quark-cli -datadir=/root/mn-04 masternode status | grep status && echo && echo -n "mn05: " && quark-cli -datadir=/root/mn-05 getblockcount && quark-cli -datadir=/root/mn-05 masternode status | grep status && echo && echo -n "mn06: " && quark-cli -datadir=/root/mn-06 getblockcount && quark-cli -datadir=/root/mn-06 masternode status | grep status && echo && echo -n "mn07: " && quark-cli -datadir=/root/mn-07 getblockcount && quark-cli -datadir=/root/mn-07 masternode status | grep status && echo && echo -n "mn08: " && quark-cli -datadir=/root/mn-08 getblockcount && quark-cli -datadir=/root/mn-08 masternode status | grep status && echo && echo -n "mn09: " && quark-cli -datadir=/root/mn-09 getblockcount && quark-cli -datadir=/root/mn-09 masternode status | grep status && echo && echo -n "mn10: " && quark-cli -datadir=/root/mn-10 getblockcount && quark-cli -datadir=/root/mn-10 masternode status | grep status'