|
|
@ -1,7 +1,7 @@ |
|
|
|
#!/bin/bash |
|
|
|
#Stats script for Komodo Notary Nodes |
|
|
|
# |
|
|
|
#Requires jq v1.5+ and bitcoin-cli, komodo-cli and chips-cli installed (e.g. symlinked to /usr/local/bin) |
|
|
|
#Requires jq v1.5+ and bitcoin-cli, komodo-cli, chips-cli and gamecredits-cli installed (e.g. symlinked to /usr/local/bin) |
|
|
|
|
|
|
|
#==Options - Only Change These== |
|
|
|
|
|
|
@ -14,10 +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 - 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 |
|
|
|
|
|
|
@ -46,6 +53,41 @@ timeSince() |
|
|
|
fi |
|
|
|
} |
|
|
|
|
|
|
|
checkRepo () { |
|
|
|
if [ -z $1 ] || [ -z $2 ] || [ -z $3 ]; then |
|
|
|
return |
|
|
|
fi |
|
|
|
|
|
|
|
prevdir=${PWD} |
|
|
|
|
|
|
|
eval cd "$2" |
|
|
|
|
|
|
|
color_red=$'\033[0;31m' |
|
|
|
color_reset=$'\033[0m' |
|
|
|
|
|
|
|
git remote update > /dev/null 2>&1 |
|
|
|
|
|
|
|
localrev=$(git rev-parse HEAD) |
|
|
|
remoterev=$(git rev-parse $3) |
|
|
|
cd $prevdir |
|
|
|
|
|
|
|
if [ $localrev != $remoterev ]; then |
|
|
|
printf "$color_red[U]$color_reset" |
|
|
|
fi |
|
|
|
|
|
|
|
case $1 in |
|
|
|
KMD) |
|
|
|
printf " " |
|
|
|
;; |
|
|
|
CHIPS) |
|
|
|
printf " " |
|
|
|
;; |
|
|
|
GAME) |
|
|
|
printf " " |
|
|
|
;; |
|
|
|
esac |
|
|
|
} |
|
|
|
|
|
|
|
#Do not change below for any reason! |
|
|
|
#The BTC and KMD address here must remain the same. Do not need to enter yours! |
|
|
|
source coinlist |
|
|
@ -58,7 +100,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' |
|
|
@ -69,31 +111,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 KMD ${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" |
|
|
@ -114,43 +157,56 @@ 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 ${coin[0]} ${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]}) |
|
|
|
secondlast=(${coinlist[-2]}) |
|
|
|
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="@ $now" |
|
|
|
fi |
|
|
|
if [[ ${coin[0]} == ${secondlast[0]} ]]; then |
|
|
|
laststring="All:$totalntrzd" |
|
|
|
fi |
|
|
|
|
|
|
|
printf "$format" "${coin[0]}$(checkRepo ${coin[0]} ${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)" |
|
|
|
"$(echo $info | jq .connections)" \ |
|
|
|
"$laststring" |
|
|
|
|
|
|
|
if [[ ${coin[0]} != ${lastcoin[0]} ]]; then |
|
|
|
echo |
|
|
|
fi |
|
|
|
fi |
|
|
|
done |
|
|
|
printf "Total: %9s %44s" "$totalntrzd" "$now"; |
|
|
|
} |
|
|
|
|
|
|
|
if [ "$sleepytime" != "false" ] |
|
|
|
then |
|
|
|
while true |
|
|
|
do |
|
|
|
if [ "$sleepytime" != "false" ]; then |
|
|
|
while true; do |
|
|
|
outputstats |
|
|
|
sleep $sleepytime |
|
|
|
done |
|
|
|