Browse Source

Merge pull request #45 from webworker01/master

add remote check to komodostats.com api for checkfork
master
patchkez 7 years ago
committed by GitHub
parent
commit
8c7d7f6f27
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 90
      webworker01/checkfork
  2. 81
      webworker01/stats

90
webworker01/checkfork

@ -1,42 +1,100 @@
#!/bin/bash
#You can modify this list of ACs to exclude or comment out the line to show all
ignoreacs=('VOTE2018' 'BEER' 'PIZZA')
#how far ahead or behind before being marked as a fork
variance=3
source coinlist
forked=false
remotecheck=$(curl -Ssf https://komodostats.com/api/notary/summary.json)
remotecheck2=$(curl -Ssf https://dexstats.info/api/explorerstatus.php)
format="%-8s %8s %8s %8s %8s\n"
redformat="\033[0;31m$format\033[0m"
printf "$format" "-ASSET-" "-BLOCKS-" "-LONG-" "-RMT1-" "-RMT2-"
#KMD
blocks=$(komodo-cli getinfo | jq .blocks)
longest=$(komodo-cli getinfo | jq .longestchain)
remoteblocks=$(echo $remotecheck | jq '.[] | select(.ac_name=="KMD") | .blocks')
remoteblocks2=$(echo $remotecheck2 | jq '.status[] | select(.chain=="KMD") | .height | tonumber')
diff1=$((blocks-remoteblocks))
diff2=$((blocks-remoteblocks2))
thisformat=$format
if ((blocks < longest)); then
forked=true
printf "\033[0;31mKMD - Possible fork!\033[0m Blocks $blocks < LongestChain $longest\n"
else
echo "KMD - Blocks $blocks = LongestChain $longest"
thisformat=$redformat
fi
if (( diff1 < variance * -1 )) || (( diff1 > variance )); then
forked=true
thisformat=$redformat
fi
if (( diff2 < variance * -1 )) || (( diff2 > variance )); then
forked=true
thisformat=$redformat
fi
printf "$thisformat" "KMD" "$blocks" "$longest" "$remoteblocks" "$remoteblocks2"
#CHIPS
blocks=$(chips-cli getinfo | jq .blocks)
longest=$(chips-cli getinfo | jq .headers)
remoteblocks=$(echo $remotecheck | jq '.[] | select(.ac_name=="CHIPS") | .blocks')
diff1=$((blocks-remoteblocks))
thisformat=$format
if ((blocks < longest)); then
forked=true
printf "\033[0;31mCHIPS - Possible fork!\033[0m Blocks $blocks < Headers $longest\n"
else
echo "CHIPS - Blocks $blocks = Headers $longest"
thisformat=$redformat
fi
if (( diff1 < variance * -1 )) || (( diff1 > variance )); then
forked=true
thisformat=$redformat
fi
printf "$thisformat" "CHIPS" "$blocks" "$longest" "$remoteblocks"
#GAME
blocks=$(gamecredits-cli getinfo | jq .blocks)
remoteblocks=$(echo $remotecheck | jq '.[] | select(.ac_name=="GAME") | .blocks')
diff1=$((blocks-remoteblocks))
thisformat=$format
if (( diff1 < variance * -1 )) || (( diff1 > variance )); then
forked=true
thisformat=$redformat
fi
printf "$thisformat" "GAME" "$blocks" " " "$remoteblocks"
for coins in "${coinlist[@]}"; do
coin=($coins)
blocks=$(komodo-cli -ac_name=${coin[0]} getinfo | jq .blocks)
longest=$(komodo-cli -ac_name=${coin[0]} getinfo | jq .longestchain)
if ((blocks < longest)); then
forked=true
printf "\033[0;31m${coin[0]} - Possible fork!\033[0m Blocks $blocks < LongestChain $longest\n"
else
echo "${coin[0]} - Blocks $blocks = LongestChain $longest"
if [[ ! ${ignoreacs[*]} =~ ${coin[0]} ]]; then
blocks=$(komodo-cli -ac_name=${coin[0]} getinfo | jq .blocks)
longest=$(komodo-cli -ac_name=${coin[0]} getinfo | jq .longestchain)
remoteblocks=$(echo $remotecheck | jq --arg acname ${coin[0]} '.[] | select(.ac_name==$acname) | .blocks')
remoteblocks2=$(echo $remotecheck2 | jq --arg acname ${coin[0]} '.status[] | select(.chain==$acname) | .height | tonumber')
diff1=$((blocks-remoteblocks))
diff2=$((blocks-remoteblocks2))
thisformat=$format
if ((blocks < longest)); then
forked=true
thisformat=$redformat
fi
if (( diff1 < variance * -1 )) || (( diff1 > variance )); then
forked=true
thisformat=$redformat
fi
if (( diff2 < variance * -1 )) || (( diff2 > variance )); then
forked=true
thisformat=$redformat
fi
printf "$thisformat" "${coin[0]}" "$blocks" "$longest" "$remoteblocks" "$remoteblocks2"
fi
done
if [ "$forked" = false ]; then
printf "\033[0;32mAll coins are fine\033[0m\n"
else
printf "\033[0;31mPossible fork!\033[0m\n"
fi

81
webworker01/stats

@ -14,18 +14,17 @@ txscanamount=77777
#You can modify this list of ACs to exclude or comment out the line to show all
ignoreacs=('VOTE2018' 'BEER' 'PIZZA')
#git checking - some paths and such
repos=(
'Komodo $HOME/komodo origin/dev'
'Iguana $HOME/SuperNET origin/dev'
'Chips $HOME/chips3 origin/dev'
'GameCredits /home/gamecredits/GameCredits origin/master'
#git checking - path and remote branch
declare -A repos=(
[KMD]='$HOME/komodo origin/dev'
[SUPERNET]='$HOME/SuperNET origin/dev'
[CHIPS]='$HOME/chips3 origin/dev'
[GAME]='/home/gamecredits/GameCredits origin/master'
)
#==End Options==
timeSince()
{
timeSince () {
local currentimestamp=$(date +%s)
local timecompare=$1
@ -54,21 +53,24 @@ timeSince()
fi
}
checkRepo()
{
checkRepo () {
if [ -z $1 ] || [ -z $2 ]; then
return
fi
prevdir=${PWD}
eval cd "$2"
eval cd "$1"
git remote update > /dev/null 2>&1
localrev=$(git rev-parse HEAD)
remoterev=$(git rev-parse $3)
remoterev=$(git rev-parse $2)
cd $prevdir
if [ $localrev != $remoterev ]; then
printf "\n\033[0;31m$1 has an update at $3! Local:${localrev:0:7} Upstream:${remoterev:0:7}\033[0m"
printf "\033[0;31m[U]\033[0m"
fi
cd $prevdir
}
#Do not change below for any reason!
@ -83,7 +85,7 @@ timefilter=1525032458
#Second time filter for assetchains (SuperNET commit 07515fb)
timefilter2=1525513998
format="%-8s %7s %6s %7s %12.8f %8s %7s %7s\n"
format="%-11s %6s %6s %7s %.12s %6s %6s %6s"
othercoins=(
'CHIPS chips-cli'
@ -94,31 +96,32 @@ outputstats ()
{
count=0
totalntrzd=0
now=$(date +"%Y-%m-%d %T%z")
now=$(date +"%H:%M")
printf "\n\n"
printf "%-8s %7s %6s %7s %12s %8s %7s %7s\n" "-ASSET-" "-NTRZd-" "-UTXO-" "-BLOX-" "-BALANCE-" "-LAST-" "-CNCT-";
printf "%-11s %6s %6s %7s %12s %6s %6s %6s\n" "-ASSET-" "-NOTR-" "-UTXO-" "-BLOX-" "-BALANCE-" "-LAST-" "-CNCT-";
btctxinfo=$(bitcoin-cli listtransactions "" $txscanamount)
btclastntrztime=$(echo $btctxinfo | jq -r --arg address "$btcntrzaddr" '[.[] | select(.address==$address)] | sort_by(.time) | last | "\(.time)"')
btcntrzd=$(echo $btctxinfo | jq --arg address "$btcntrzaddr" --arg timefilter $timefilter '[.[] | select(.time>=($timefilter|tonumber) and .address==$address and .category=="send")] | length')
totalntrzd=$(( $totalntrzd + $btcntrzd ))
printf "$format" "BTC" \
printf "$format\n" "BTC" \
"$btcntrzd" \
"$(bitcoin-cli listunspent | jq --arg amt "$utxoamt" '[.[] | select(.amount==($amt|tonumber))] | length')" \
"$(bitcoin-cli getblockchaininfo | jq .blocks)" \
"$(bitcoin-cli getbalance)" \
"$(printf "%12.8f" $(bitcoin-cli getbalance))" \
"$(timeSince $btclastntrztime)" \
"$(bitcoin-cli getnetworkinfo | jq .connections)"
kmdinfo=$(komodo-cli getinfo)
kmdtxinfo=$(komodo-cli listtransactions "" $txscanamount)
kmdlastntrztime=$(echo $kmdtxinfo | jq -r --arg address "$kmdntrzaddr" '[.[] | select(.address==$address)] | sort_by(.time) | last | "\(.time)"')
printf "%-8s %7s %6s %7s %.12s %8s %7s %7s\n" "KMD" \
repo=(${repos[KMD]})
printf "$format\n" "KMD$(checkRepo ${repo[0]} ${repo[1]})" \
" " \
"$(komodo-cli listunspent | jq --arg amt "$utxoamt" '[.[] | select(.amount==($amt|tonumber))] | length')" \
"$(echo $kmdinfo | jq .blocks)" \
"$(echo $kmdinfo | jq .balance)" \
"$(printf "%12.8f" $(echo $kmdinfo | jq .balance))" \
"$(timeSince $kmdlastntrztime)" \
"$(echo $kmdinfo | jq .connections)" \
"$(echo $kmdtxinfo | jq '[.[] | select(.generated==true)] | length') mined"
@ -139,45 +142,51 @@ outputstats ()
coinslastntrztime=$(echo $coinstxinfo | jq -r --arg address "$coinsntraddr" '[.[] | select(.address==$address)] | sort_by(.time) | last | "\(.time)"')
coinsntrzd=$(echo $coinstxinfo | jq --arg address "$coinsntraddr" --arg timefilter $timefilter2 '[.[] | select(.time>=($timefilter|tonumber) and .address==$address and .category=="send")] | length')
totalntrzd=$(( $totalntrzd + $coinsntrzd ))
printf "$format" "${coin[0]}" \
repo=(${repos[${coin[0]}]})
printf "$format\n" "${coin[0]}$(checkRepo ${repo[0]} ${repo[1]})" \
"$coinsntrzd" \
"$(${coin[1]} listunspent | jq --arg amt "$coinsutxoamount" '[.[] | select(.amount==($amt|tonumber))] | length')" \
"$(echo $coinsinfo | jq .blocks)" \
"$(echo $coinsinfo | jq -r '. | (.balance|tostring)')" \
"$(printf "%12.8f" $(echo $coinsinfo | jq -r '. | (.balance|tostring)'))" \
"$(timeSince $coinslastntrztime)" \
"$(echo $coinsinfo | jq .connections)"
done
lastcoin=(${coinlist[-1]})
for coins in "${coinlist[@]}"; do
coin=($coins)
if [[ ! ${ignoreacs[*]} =~ ${coin[0]} ]]
then
if [[ ! ${ignoreacs[*]} =~ ${coin[0]} ]]; then
info=$(komodo-cli -ac_name=${coin[0]} getinfo)
mininginfo=$(komodo-cli -ac_name=${coin[0]} getmininginfo)
txinfo=$(komodo-cli -ac_name=${coin[0]} listtransactions "" $txscanamount)
lastntrztime=$(echo $txinfo | jq -r --arg address "$kmdntrzaddr" '[.[] | select(.address==$address)] | sort_by(.time) | last | "\(.time)"')
acntrzd=$(echo $txinfo | jq --arg address "$kmdntrzaddr" --arg timefilter $timefilter2 '[.[] | select(.time>=($timefilter|tonumber) and .address==$address and .category=="send")] | length')
totalntrzd=$(( $totalntrzd + $acntrzd ))
printf "$format" "${coin[0]}" \
repo=(${repos[${coin[0]}]})
laststring=""
if [[ ${coin[0]} == ${lastcoin[0]} ]]; then
laststring="All:$totalntrzd @$now"
fi
printf "$format" "${coin[0]}$(checkRepo ${repo[0]} ${repo[1]})" \
"$acntrzd" \
"$(komodo-cli -ac_name=${coin[0]} listunspent | jq --arg amt "$utxoamt" '[.[] | select(.amount==($amt|tonumber))] | length')" \
"$(echo $info | jq .blocks)" \
"$(echo $info | jq .balance)" \
"$(printf "%12.8f" $(echo $info | jq .balance))" \
"$(timeSince $lastntrztime)" \
"$(echo $info | jq .connections)"
fi
done
printf "Total: %9s %44s" "$totalntrzd" "$now";
"$(echo $info | jq .connections)" \
"$laststring"
for repo in "${repos[@]}"; do
checkRepo ${repo[0]} ${repo[1]} ${repo[2]}
if [[ ${coin[0]} != ${lastcoin[0]} ]]; then
echo
fi
fi
done
}
if [ "$sleepytime" != "false" ]
then
if [ "$sleepytime" != "false" ]; then
while true; do
outputstats
sleep $sleepytime

Loading…
Cancel
Save