Browse Source

Merge pull request #11 from dwygit/master

Added Lazynode
revert-24-test_rpcbind_to_assetname
patchkez 7 years ago
committed by GitHub
parent
commit
88fa9a6368
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      README.md
  2. 94
      dwy/README.md
  3. 534
      dwy/lazynode

3
README.md

@ -30,6 +30,9 @@ It was Kolo's idea to create this repository and here is his concept how it shou
### ansible-playbooks
- This is demonstration that central yaml file can be used by other tools. I expect people to start using Ansible for system configuration.
### dwy
- lazynode script : get the status of your node in few commands. Check everything is running fine. Run "allinone". Testing on my test node.
## Contacts
Ideas can be discussed in [#notarynode](https://komodo-platform.slack.com) Slack channel, but please all code proposals discuss via PRs on Github.

94
dwy/README.md

@ -0,0 +1,94 @@
## Lazynode
Still in dev. Purpose is to get the maximum info, with the minimum commands :D. It is NOT optimized, but in its current state, it works (for me :D)
The goal is to see in one command how is node running, if everything is fine, and if there is any action needed. It's obvious any NN operator can do this manually, but simplifying it with global commands can save time.
One thing that is possible is to get a checksequence, and be able to manage it. Possible just to check everything, and/or act on any failed test (sync nok, process KO, etc...)
## Params
Check that your BTC/KMD address are the good ones, or the validate just will throw that it's not yours :).
check that you don't have any specific path for bitcoind/chipsd/komodod. By default it will assume it has been installed as the NN setup guide advised.
## Functions
### check
Checks the actual state of your node.
If a coin is missing, it will just relaunch it, based on assetchains file (komodo/src/assetchains).
When all non commented coins are launched and synced, will launch iguana on a screen called 'iguana'
When every coin and iguana is OK, will call validateaddress.
To work properly, check has to be the "launcher" of all coins/assetchains, just because when it checks coins running/not running, the isrunningcall is based on specific syntax, for example, if you call ./komodod -pubkey=XXX manually, and the check search for komodod -gen, it will return that coin is not properly launched.
Will fix this in future versions.
To summarize it, check will be able to launch everything just after a boot / when everything is stopped : In that case it will launch everything you need.
In case everything is already launched, it will just check that everything is ok. Something missing : It will be relaunched.
### utxo
galtmines script searching for utxo matching the size needed for notarization. Just added parsing file to get those counts for every coin.
### stats
webworker notarization check adapted to get count from every coin.
### validateaddress [' '|coinname|ac|dpow]
Validate that the address you typed in params (top of the lazynode file) is yours.
That could seem useless, but you can just add parameters :
'' : will validate for BTC/CHIPS/KOMODO and any coin on komodo/src/assetchains that are not commented.
coin : will validate for that specific coin
ac : will validate every AC not commented on komodo/src/assetchains
dpow : will validate every AC called by dpowassets (in case you launched it manually)
### isrunning "coinname|iguana" [nolog]
Is this process running? :)
### startac "coinname"
Will launch every AC not commented on assetchains file, if not running
### countac
returns 1 if on AC not commented from assetchains file is missing
### stopiguana
Stops iguana and wipe iguana screen
### stopprocess "coinname"
Stops that coin from running.
### checksync "coinname"
Checks status of the sync for that coin. In case it is not synced, will wait and show the progress.
### startprocess "coinname"
Start that coin. Special case for iguana, starts a screen called iguana, then start all commands to get it running on that screen.
### listac
Lists all AC that are not commented on assetchains file.
### listdpow
Lists all AC that are on dpowassets file.
### listall
Lists everything that will be launched with a check call. To summarize : BTC/KMD/CHIPS/AC*/IGUANA
### listallcommented
List everycoin : BTC/KMD/CHIPS and all AC, commented or not on assetchains file.
### getdebug [' '|coinname|ac|dpow] [tailsize]
Print the debug file for the coin passed as arg, tailsize modifying the... tailsize :D
If no coin arg, will just use all coins / AC not commented.
If numeric value : will change the tail size.
If specific coin : will only show the debug for that coin.
Possible to get previous build lists (ac: all AC not commented - dpow: all coins from dpowassets file)
### stopall
stops everything, iguana included (and its screen)
(manual AC not launched via lazynode won't be stopped)
### shouldrun
is everything running ? BTC/KMD/CHIPS/AC not commented on assetchains/IGUANA ? 1 command, all the info.
### help
list of commands.
## info
Not intended to replace anything... but just help seeing in a very fast way how things are doing.

534
dwy/lazynode

@ -0,0 +1,534 @@
#!/bin/bash
pwdvalue=$(pwd)
homeuser=$(echo '/'$(cat ~/SuperNET/iguana/userhome.txt)'/')
komodo_binary=$(echo $homeuser"komodo/src/komodod")
komodo_cli=$(echo $homeuser"komodo/src/komodo-cli")
komodo_binary_dir=$(echo $homeuser"komodo/src")
komodo_binary_name='komodod'
seed_ip=`getent hosts zero.kolo.supernet.org | awk '{ print $1 }'`
delay=20
notalllaunched='0'
source $homeuser/SuperNET/iguana/pubkey.txt
re='^[0-9]+$'
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m'
btcaddress="1BCJ3Rs6U9eqwsYJ5AjVZYEP3XxQLRt9kH"
kmdaddress="RKUV7wkP4yTR1suVYLicf4ZaooQzz8u5iR"
#Take a coin/ac/soft in param, ant initialize values to get other functions to work.
inputparams() {
case $1 in
"iguana")
processname="iguana notary"
;;
"iguanascreen")
processname="SCREEN -d -m -S iguana"
;;
"chp"|"CHIPS")
processname="chipsd"
processcli="chips-cli"
processmincount=1
processargs=""
processpath="."
processlaunch="$processname"
processaddress="$kmdaddress"
notarysize='0.0001'
debugpath="$homeuser.chips/debug.log"
;;
"btc")
processname="bitcoind"
processcli="bitcoin-cli"
processmincount=1
processargs=""
processpath="."
processlaunch="$processname"
processaddress="$btcaddress"
notarysize='0.0001'
debugpath="$homeuser.bitcoin/debug.log"
;;
"kmd")
processname="$komodo_binary_name -gen -genproclimit=2 -notary"
processcli="$komodo_cli"
processmincount=1
processargs="-pubkey=\"$pubkey\""
processpath="$komodo_binary_dir"
processlaunch="./$processname $processargs"
processaddress="$kmdaddress"
notarysize='0.0001'
debugpath="$homeuser.komodo/debug.log"
;;
*)
aclist=$(echo $launchlistallcommented | grep $1 | wc -l)
if [ $aclist -eq 1 ]
then
supplyac=$(cat $homeuser/komodo/src/assetchains | grep $1 | cut -d ' ' -f3)
processname="$komodo_binary_name -ac_name=$1"
processcli="$komodo_cli -ac_name=$1"
processmincount=1
processargs="-pubkey=\"$pubkey\" -ac_supply=$supplyac -addnode=$seed_ip"
processpath="$komodo_binary_dir"
processlaunch="./$processname $processargs"
processaddress="$kmdaddress"
notarysize='0.0001'
debugpath="$homeuser.komodo/$1/debug.log"
else
echo -e "$NC$(date '+%Y-%m-%d %H:%M:%S')$RED\tinputparams\t$1\tunknown param$NC" | tee -a logcheckagents
exit
fi
;;
esac
}
launchlisting () {
launchlistac="init"
launchlistall=$(echo -e "btc\nchp\nkmd")
launchlistallcommented=$launchlistall
while read line; do
if [ ! $line == 'komodo_asset' ]
then
launchlistall+=$(echo -e "\n$line")
if [ "$launchlistac" == "init" ]
then
launchlistac=$(echo "$line")
else
launchlistac+=$(echo -e "\n$line")
fi
fi
done <<< "$(cat $homeuser/komodo/src/assetchains | grep komodo_asset | grep -v '#' | cut -d ' ' -f2)"
launchlistallcoins=$launchlistall
launchlistall+=$(echo -e "\niguana")
#SPECIAL : INCLUDING ALL ASSETCHAINS THAT WILL BE PROCESSED BY IGUANA
while read line; do
if [ ! $line == 'komodo_asset' ]
then
launchlistallcommented+=$(echo -e "\n$line")
fi
done <<< "$(cat $homeuser/komodo/src/assetchains | grep komodo_asset | cut -d ' ' -f2)"
launchlistdpow="init"
while read line2; do
if [ "$launchlistdpow" == "init" ]
then
launchlistdpow=$(echo "$line2")
else
launchlistdpow+=$(echo -e "\n$line2")
fi
done <<< "$(cat $homeuser/komodo/src/dpowassets | grep curl | grep -v \# | sed 's/symbol\\"\:\\\"/\n/g' | grep -v curl | cut -d '\' -f1)"
}
startprocess() {
if [ "$1" == "iguana" ]
then
echo "$(date '+%Y-%m-%d %H:%M:%S') startprocess - iguana" | tee -a logcheckagents
screen -d -m -S iguana
screen -S iguana -X stuff 'cd'`echo -ne '\015'`'cd ~/SuperNET/iguana'`echo -ne '\015'`'git checkout beta && git pull && ./m_notary && cd ~/komodo/src && ./dpowassets'`echo -ne '\015'`
else
inputparams $1
echo -e "$NC$(date '+%Y-%m-%d %H:%M:%S')$NC\tstartprocess\t$1$NC" | tee -a logcheckagents
cd $processpath
$processlaunch &
fi
}
checksync() {
inputparams $1
if isrunning $1
then
checkinprogress='1'
while [ 1 ];do
processblockstatus=$($processcli getblockchaininfo 2>/dev/null | jq -r .blocks)
processblockheaders=$($processcli getblockchaininfo 2>/dev/null | jq -r .headers)
if [[ $processblockstatus =~ $re ]]
then
if ! [ $processblockstatus == "0" ]
then
if [ ! $processblockheaders == $processblockstatus ]
then
echo -e "$NC$(date '+%Y-%m-%d %H:%M:%S')$RED\tchecksync\t$1\tsync NOK$NC" | tee -a logcheckagents
else
break
fi
else
echo -e "$NC$(date '+%Y-%m-%d %H:%M:%S')$NC\tchecksync\t$1\tgetting best chain$NC" | tee -a logcheckagents
fi
else
echo -e "$NC$(date '+%Y-%m-%d %H:%M:%S')$NC\tchecksync\t$1\tstart in progress$NC" | tee -a logcheckagents
fi
sleep 5
done
checkinprogress='0'
echo -e "$NC$(date '+%Y-%m-%d %H:%M:%S')$GREEN\tchecksync\t$1\tsync OK$NC" | tee -a logcheckagents
else
echo -e "$NC$(date '+%Y-%m-%d %H:%M:%S')$RED\tchecksync\t$1\tnot running$NC" | tee -a logcheckagents
fi
}
stopprocess() {
inputparams $1
PIDtokill=$(eval "pgrep -f '$processname'")
if [ ! $PIDtokill = "" ]
then
kill -15 $PIDtokill
echo -e "$NC$(date '+%Y-%m-%d %H:%M:%S')$NC\tstopprocess\t$1\tterminating : $PIDtokill$NC" | tee -a logcheckagents
sleep 2
fi
}
stopiguana() {
stopprocess iguana
stopprocess iguanascreen
screen -wipe
}
countac () {
while read line; do
if [ ! $line == 'komodo_asset' ]
then
if [ ! "$(pgrep -f $(echo "ac_name=${line}") | wc -l)" == '1' ]
then
notalllaunched='1'
fi
fi
done <<< "$launchlistac"
}
startac () {
echo -e "$NC$(date '+%Y-%m-%d %H:%M:%S')$NC\tstartac\tinit$NC" | tee -a logcheckagents
while read line; do
if [ ! $line == 'komodo_asset' ]
then
if ! isrunning $line
then
startprocess $line
sleep 20
fi
fi
done <<< "$launchlistac"
}
isrunning() {
inputparams $1
if [ $(eval "pgrep -f '$processname'" | wc -l) == "1" ]
then
if [ -z "$2" ]
then
echo -e "$NC$(date '+%Y-%m-%d %H:%M:%S')$GREEN\tisrunning\t$1\tis running$NC" | tee -a logcheckagents
fi
true
else
if [ -z "$2" ]
then
echo -e "$NC$(date '+%Y-%m-%d %H:%M:%S')$RED\tisrunning\t$1\tis not running$NC" | tee -a logcheckagents
fi
false
fi
}
globalrelaunch () {
echo "$launchlistall"
while read line; do
if [ ! "$line" == "iguana" ]
then
if ! isrunning $line
then
startprocess $line
sleep $delay
fi
else
while read line2; do
checksync $line2
while [ 1 ];do
if [ "$checkinprogress" == "1" ]
then
echo -e "$(date '+%Y-%m-%d %H:%M:%S')$NC\tglobalrelaunch\t$line2\twaiting sync to be finished"
sleep $delay
else
echo -e "$(date '+%Y-%m-%d %H:%M:%S')$NC\tglobalrelaunch\t$line2\tsync OK going to next"
break
fi
done
done <<< "$launchlistallcoins"
if ! isrunning $line
then
startprocess $line
fi
fi
done <<< "$launchlistall"
validateaddress
}
globalstop () {
while read line; do
if [ ! "$line" == "iguana" ]
then
if isrunning $line nolog
then
stopprocess $line
sleep 1
fi
else
if isrunning $line nolog
then
stopiguana
fi
fi
done <<< "$launchlistall"
}
shouldrun () {
while read line; do
isrunning $line
done <<< "$launchlistall"
}
validateaddress() {
searchvalidate='init'
if [ -z "$1" ]
then
searchvalidate=$launchlistallcoins
else
if [ "$(echo $launchlistallcommented | grep $1 | wc -l)" -eq 1 ]
then
searchvalidate=$1
else
if [ "$1" == "ac" ]
then
searchvalidate=$launchlistac
else
if [ "$1" == "dpow" ]
then
searchvalidate=$(echo -e "$launchlistdpow")
fi
fi
fi
fi
if [ ! "$searchvalidate" == "init" ]
then
while read line; do
if isrunning $line nolog
then
inputparams $line
cd $processpath
if $($processcli validateaddress $processaddress | jq -r .isvalid)
then
if $($processcli validateaddress $processaddress | jq -r .ismine) == "true"
then
echo -e "$NC$(date '+%Y-%m-%d %H:%M:%S')$GREEN\tvalidateaddress\t$line\tismine$NC" | tee -a logcheckagents
else
echo -e "$NC$(date '+%Y-%m-%d %H:%M:%S')$RED\tvalidateaddress\t$line\tisnotmine$NC" | tee -a logcheckagents
fi
else
echo -e "$NC$(date '+%Y-%m-%d %H:%M:%S')$RED\tvalidateaddress\t$line\tinvalidaddress$NC" | tee -a logcheckagents
fi
else
echo -e "$NC$(date '+%Y-%m-%d %H:%M:%S')$RED\tvalidateaddress\t$line\tprocess not running$NC" | tee -a logcheckagents
fi
done <<< "$searchvalidate"
else
echo -e "$NC$(date '+%Y-%m-%d %H:%M:%S')$RED\tvalidateaddress\t$line\tis invalid coin name$NC" | tee -a logcheckagents
fi
}
utxoreporting() {
#galtmines inspired :)
while read line; do
if isrunning $line
then
inputparams $line
cd $processpath
exactutxo=$($processcli listunspent|grep amount|awk '{print $2}'|sed s/.$//|awk -v not="$notarysize" '$1 == not'|wc -l)
uselessutxo=$($processcli listunspent|grep amount|awk '{print $2}'|sed s/.$//|awk -v not="$notarysize" '$1 < not'|wc -l)
thisbalance=$($processcli getbalance)
utxocount=$($processcli listunspent|grep amount |wc -l)
if [ "$exactutxo" -ge "50" ]
then
TMPCOLOR=$GREEN
else
TMPCOLOR=$RED
fi
echo -e "$NC$(date '+%Y-%m-%d %H:%M:%S')$TMPCOLOR\tutxoreporting\t$line\twellsized : $exactutxo$NC" | tee -a logcheckagents
echo -e "$NC$(date '+%Y-%m-%d %H:%M:%S')$TMPCOLOR\tutxoreporting\t$line\tdust : $uselessutxo$NC" | tee -a logcheckagents
echo -e "$NC$(date '+%Y-%m-%d %H:%M:%S')$NC\tutxoreporting\t$line\tbalance : $thisbalance$NC" | tee -a logcheckagents
echo -e "$NC$(date '+%Y-%m-%d %H:%M:%S')$NC\tutxoreporting\t$line\tUTXO_Count : $utxocount$NC" | tee -a logcheckagents
fi
done <<< "$launchlistallcoins"
}
checknotarization () {
#I don't know who did this !
if isrunning btc nolog && isrunning kmd nolog
then
printf -- "-ASSET-%s\t-NTRZd-%s\t-UTXOs-%s\t-BAL-%s\n";
while read line; do
if isrunning $line nolog
then
inputparams $line
cd $processpath
if [ "$line" == "btc" ]
then
printf "$line%s\t-\t$($processcli listunspent | grep $notarysize | wc -l)%s\t"; $processcli getwalletinfo | grep balance -m 1
else
printf "$line%s\t$($processcli listtransactions "" 77777 | grep -- -0.00418000 | wc -l)%s\t$($processcli listunspent | grep .0005 | wc -l)%s\t"; $processcli getinfo | grep balance
fi
fi
done <<< "$launchlistallcoins"
fi
}
getdebug () {
if [ -z "$2" ]
then
tailsize='5'
else
tailsize=$2
fi
debuglist='init'
if [ -z "$1" ]
then
debuglist=$launchlistallcoins
else
if [[ $1 =~ $re ]]
then
debuglist=$launchlistallcoins
tailsize=$1
else
if [ "$(echo $launchlistallcommented | grep $1 | wc -l)" -eq 1 ]
then
debuglist=$1
else
if [ "$1" == "ac" ]
then
debuglist=$launchlistac
else
if [ "$1" == "dpow" ]
then
debuglist=$(echo -e "$launchlistdpow")
fi
fi
fi
fi
fi
if [ ! "$debuglist" == "init" ]
then
while read line; do
inputparams $line
echo -e "$GREEN$debugpath$NC"
echo "$(tail -$tailsize $debugpath)"
done <<< "$debuglist"
else
echo -e "$NC$(date '+%Y-%m-%d %H:%M:%S')$RED\tgetdebug\t$line\tis invalid coin name$NC" | tee -a logcheckagents
fi
}
helpme () {
if [ -z "$1" ]
then
echo -e "\n\tCOMMAND LIST"
echo -e "\n\n\tcheck"
echo -e "\tutxo"
echo -e "\tvalidateaddress [' '|coinname|ac|dpow]"
echo -e "\tisrunning \"coinname|iguana\" [nolog]"
echo -e "\tstartac"
echo -e "\tcountac"
echo -e "\tstopiguana"
echo -e "\tstopprocess \"coinname\""
echo -e "\tchecksync \"coinname\""
echo -e "\tstartprocess \"coinname\""
echo -e "\tlistac"
echo -e "\tlistdpow"
echo -e "\tlistall"
echo -e "\tlistallcommented"
echo -e "\tgetdebug [' '|coinname|ac|dpow] [tailsize]"
echo -e "\tstopall"
echo -e "\tshouldrun\n"
fi
}
launchlisting
case $1 in
"check")
globalrelaunch
;;
"stats")
echo -e "$NC$(date '+%Y-%m-%d %H:%M:%S')$NC\tManual Call\t$1$NC"
checknotarization
;;
"utxo")
echo -e "$NC$(date '+%Y-%m-%d %H:%M:%S')$NC\tManual Call\t$1$NC"
utxoreporting
;;
"validateaddress")
echo -e "$NC$(date '+%Y-%m-%d %H:%M:%S')$NC\tManual Call\t$1\t$2$NC"
validateaddress $2
;;
"isrunning")
echo -e "$NC$(date '+%Y-%m-%d %H:%M:%S')$NC\tManual Call\t$1\t$2$NC"
isrunning $2
;;
"startac")
echo -e "$NC$(date '+%Y-%m-%d %H:%M:%S')$NC\tManual Call\t$1$NC"
startac
;;
"countac")
echo -e "$NC$(date '+%Y-%m-%d %H:%M:%S')$NC\tManual Call\t$1$NC"
countac
echo "$notalllaunched"
;;
"stopiguana")
echo -e "$NC$(date '+%Y-%m-%d %H:%M:%S')$NC\tManual Call\t$1$NC"
stopiguana
;;
"stopprocess")
echo -e "$NC$(date '+%Y-%m-%d %H:%M:%S')$NC\tManual Call\t$1\t$2$NC"
stopprocess $2
;;
"checksync")
echo -e "$NC$(date '+%Y-%m-%d %H:%M:%S')$NC\tManual Call\t$1\t$2$NC"
checksync $2
;;
"startprocess")
echo -e "$NC$(date '+%Y-%m-%d %H:%M:%S')$NC\tManual Call\t$1\t$2$NC"
startprocess $2
;;
"listac")
echo -e "$NC$(date '+%Y-%m-%d %H:%M:%S')$NC\tManual Call\t$1$NC"
echo "$launchlistac"
;;
"listdpow")
echo -e "$NC$(date '+%Y-%m-%d %H:%M:%S')$NC\tManual Call\t$1$NC"
echo "$launchlistdpow"
;;
"listall")
echo -e "$NC$(date '+%Y-%m-%d %H:%M:%S')$NC\tManual Call\t$1$NC"
echo "$launchlistall"
;;
"listallcommented")
echo -e "$NC$(date '+%Y-%m-%d %H:%M:%S')$NC\tManual Call\t$1$NC"
echo "$launchlistallcommented"
;;
"getdebug")
echo -e "$NC$(date '+%Y-%m-%d %H:%M:%S')$NC\tManual Call\t$1$NC"
getdebug $2 $3
;;
"stopall")
echo -e "$NC$(date '+%Y-%m-%d %H:%M:%S')$NC\tManual Call\t$1$NC"
globalstop
;;
"shouldrun")
echo -e "$NC$(date '+%Y-%m-%d %H:%M:%S')$NC\tManual Call\t$1$NC"
shouldrun
;;
"help")
helpme
;;
*)
echo "Wtf are you doin here"
;;
esac
Loading…
Cancel
Save