From 33fc492f32badd7bd92976a1e8d0efd3053ca96e Mon Sep 17 00:00:00 2001 From: root Date: Wed, 30 Oct 2019 14:02:43 +0100 Subject: [PATCH] Multiple web generator test to understand different number of block depends on g1 node --- nbr-wallets.sh | 56 +++++++++++++++++++++++++++++++++----------------- stats.html | 15 +++++++++++--- 2 files changed, 49 insertions(+), 22 deletions(-) diff --git a/nbr-wallets.sh b/nbr-wallets.sh index 5d14963..620850e 100755 --- a/nbr-wallets.sh +++ b/nbr-wallets.sh @@ -1,20 +1,30 @@ #!/bin/bash +startTime=$(date +'%T') +day=$(date +'%d-%m-%y') +id=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1) +de=$(cat /dev/urandom | tr -dc '0-9' | fold -w 1 | head -n 1) ### Variable ### -DUNITER="https://duniter-g1.p2p.legal" -indexhtml="index.html" + +if [ $de -le 3 ]; then + DUNITER="http://192.168.9.54:45000" +elif [ $de -le 6 ]; then + DUNITER="https://g1.duniter.org" +else + DUNITER="https://duniter.g1.1000i100.fr" +fi + +indexhtml="/var/www/g1-stats/index-$day-$startTime-$id.html" ### +echo "######" echo "Initialisation ..." -id=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1) -outFile="/tmp/g1-stats_$id" +outFile="/tmp/g1-stats-$day-$startTime_$id" TXBLOCKS=($(curl -s ${DUNITER}/blockchain/with/tx | jq '.result.blocks[]' | awk '{printf $1" "}')) MEMBERS=($(curl -s ${DUNITER}/wot/members | jq '.results[].pubkey' | tr -d '"')) nbrMembers=${#MEMBERS[@]} lastBloc=${TXBLOCKS[-1]} -startTime=$(date +'%T') - for i in ${TXBLOCKS[*]}; do [[ -z ${TXBLOCKS[$i]} ]] && break @@ -23,11 +33,14 @@ for i in ${TXBLOCKS[*]}; do wallets+=$(echo -e "$WALLETS \n" | sed 's/ /\\n/g') progress=$(echo "scale=1; $bloc*100/$lastBloc/1" | bc) + sleep 1 - clear - echo "Heure de début: $startTime" - echo - echo "Scan en cours: $progress% - $bloc/$lastBloc" + if [[ $1 != "web" ]]; then + clear + echo "Heure de début: $startTime" + echo + echo "Scan en cours: $progress% - $bloc/$lastBloc" + fi ((iter++)) @@ -41,11 +54,13 @@ for i in ${MEMBERS[*]}; do progress=$(echo "scale=0; $iter*100/$nbrMembers/1" | bc) if [[ $progress =~ ^(0|10|20|30|40|50|60|70|80|90|99)$ ]]; then [[ $progress == 99 ]] && progress=100 - clear - echo "Heure de début: $startTime" - echo - echo "Scan en cours: 100% - $bloc/$lastBloc" - echo "Ajouts des comptes membres ... $progress%" + if [[ $1 != "web" ]]; then + clear + echo "Heure de début: $startTime" + echo + echo "Scan en cours: 100% - $bloc/$lastBloc" + echo "Ajouts des comptes membres ... $progress%" + fi fi if [[ -z $(grep "$i" $outFile) ]]; then @@ -61,12 +76,14 @@ pourcentMbrs=$(echo "scale=1; $nbrMembers*100/$nbrTotalWallets/1" | bc) pourcentWallets=$(echo "scale=1; $nbrSimpleWallets*100/$nbrTotalWallets/1" | bc) web() { - cp stats.html $indexhtml + cp /opt/g1-stats/stats.html $indexhtml sed -i "s/_nbrTotalWallets/$nbrTotalWallets/g" $indexhtml sed -i "s/_nbrSimpleWallets/$nbrSimpleWallets/g" $indexhtml - sed -i "s/_nbrMembers/$nbrMembers/g" $indexhtml + sed -i "s/_nbrMembers/$nbrMembers/g" $indexhtml sed -i "s/_pourcentMbrs/$pourcentMbrs/g" $indexhtml - sed -i "s/_pourcentWallets/$pourcentWallets/g" $indexhtml + sed -i "s/_pourcentWallets/$pourcentWallets/g" $indexhtml + sed -i "s/_node/"$DUNITER"/g" $indexhtml + sed -i "s/_heure/$startTime/g" $indexhtml chown www-data:www-data $indexhtml 2>/dev/null } @@ -74,10 +91,11 @@ web() { [[ $1 == "web" ]] && web echo -e "\n ---" +echo "Noeud: $DUNITER" echo "Nombre total de wallet: $nbrTotalWallets" echo "Nombre de membres: $nbrMembers (${pourcentMbrs}%)" echo "Nombre de simple portefeuille: $nbrSimpleWallets (${pourcentWallets}%)" -echo "---" +echo " ---" rm $outFile echo "Heure de fin: $(date +'%T')" diff --git a/stats.html b/stats.html index 1a13165..f9c04a5 100644 --- a/stats.html +++ b/stats.html @@ -1,7 +1,16 @@ -Nombre total de wallet: _nbrTotalWallets -Nombre de membres: _nbrMembers _pourcentMbrs% -Nombre de simple portefeuille: _nbrSimpleWallets _pourcentWallets% + + +

La ḡ1 en quelques statistiques

+ +Nombre total de wallet: _nbrTotalWallets
+Nombre de membres: _nbrMembers (_pourcentMbrs%)
+Nombre de simple portefeuille: _nbrSimpleWallets (_pourcentWallets%)
+ +

debug

+ +heure: _heure
+noeud scanné: _node