diff --git a/nbr-wallets.sh b/nbr-wallets.sh index 30a8655..b9e6197 100755 --- a/nbr-wallets.sh +++ b/nbr-wallets.sh @@ -10,11 +10,11 @@ DUNITER="http://192.168.9.54:45000" DUNITER2="https://g1.duniter.org" DUNITER3="https://duniter.g1.1000i100.fr" -#indexhtml="/var/www/g1-stats/index-$day-$startTime-$id.html" indexhtml="/var/www/g1-stats/index.html" ### echo "######" +echo "$day à startTime" [[ -z $(which jq) || -z $(which bc) ]] && apt update && apt install jq bc echo "Initialisation ..." outFile="/tmp/g1-stats-$day-$startTime_$id" @@ -97,7 +97,8 @@ web() { sed -i "s/_pourcentMbrs/$pourcentMbrs/g" $indexhtml sed -i "s/_pourcentWallets/$pourcentWallets/g" $indexhtml # sed -i "s/_node/$DUNITER/g" $indexhtml - sed -i "s/_heure/$day_$startTime/g" $indexhtml + sed -i "s/_heure/$startTime/g" $indexhtml + sed -i "s/_day/$day/g" $indexhtml sed -i "s/_txInSimple/$txInSimple/g" $indexhtml sed -i "s/_txOutSimple/$txOutSimple/g" $indexhtml sed -i "s/_soldeSimple/$soldeSimple/g" $indexhtml @@ -106,6 +107,7 @@ web() { sed -i "s/_soldeMembers/$soldeMembers/g" $indexhtml sed -i "s/_poucentSoldeMembers/$poucentSoldeMembers/g" $indexhtml sed -i "s/_nonConsumedUDT/$nonConsumedUDT/g" $indexhtml + sed -i "s/_monetaryMass/$monetaryMass/g" $indexhtml chown www-data:www-data $indexhtml 2>/dev/null } @@ -138,14 +140,16 @@ solde=0 txInT=0 txOutT=0 nonConsumedUDT=0 +nonConsumedUD=0 for i in $pubkeys; do -# echo $i - txInL=$(curl -s "http://g1.data.duniter.fr/g1/movement/_search?filter_path=hits.hits._source&size=10000&q=recipient:$i&pretty") txOutL=$(curl -s "http://g1.data.duniter.fr/g1/movement/_search?filter_path=hits.hits._source&size=10000&q=issuer:$i&pretty") - [[ $1 == "mbr" ]] && nonConsumedUD=$(curl -s ${DUNITER}/ud/history/$i | jq '.history.history[].amount' | awk '{s+=$1} END {print s}') || nonConsumedUD=0 - [[ $1 == "mbr" ]] && nonConsumedUDT=$(echo -e "scale=2; ($nonConsumedUD/100)+$nonConsumedUDT" | bc) + if [[ $1 == "mbr" ]]; then + nonConsumedUD=$(curl -s ${DUNITER}/ud/history/$i | jq '.history.history[].amount' | awk '{s+=$1} END {print s}') || nonConsumedUD=0 + [[ -z $nonConsumedUD ]] && nonConsumedUD=0 + nonConsumedUDT=$(echo -e "scale=2; ($nonConsumedUD/100)+$nonConsumedUDT" | bc) + fi [[ $txInL != "{ }" ]] && txIn=$(echo "$txInL" | jq '.hits.hits[]._source.amount' | awk '{s+=$1} END {print s}') || txIn=0 [[ $txOutL != "{ }" ]] && txOut=$(echo "$txOutL" | jq '.hits.hits[]._source.amount' | awk '{s+=$1} END {print s}') || txOut=0 @@ -174,7 +178,7 @@ echo -e "\n ---\n" echo "Récupération du solde des membres..." pubkeys=${MEMBERS[@]} -getSolde mbr +getSolde txInMembers=$txInT txOutMembers=$txOutT soldeMembers=$solde @@ -183,14 +187,17 @@ echo -e "Envoyé membres:\t $txOutMembers" echo -e "Soldes membres:\t $soldeMembers" echo -e "Total DU non consumés:\t $nonConsumedUDT" +monetaryMass=$(curl -s ${DUNITER}/blockchain/current | jq .monetaryMass) +monetaryMass=$(echo -e "scale=2; ($monetaryMass/100)/1" | bc) soldeWalletMembers=$(echo "scale=2; $soldeMembers+$soldeSimple" | bc) -poucentSoldeMembers=$(echo "scale=1; $soldeMembers*100/$soldeWalletMembers/1" | bc) +poucentSoldeMembers=$(echo "scale=1; $soldeMembers*100/$monetaryMass/1" | bc) echo -e "\n ---\n" -echo -e "Solde Total:\t $soldeWalletMembers" +echo -e "Solde des membres (sans DU):\t $soldeWalletMembers" +echo -e "Masse Monétaire:\t $monetaryMass Ḡ1" [[ $1 == "web" ]] && web rm $outFile -echo "Heure de fin: $(date +'%T')" +echo "$day - Heure de fin: $(date +'%T')" diff --git a/stats.html b/stats.html index e65605d..7594693 100644 --- a/stats.html +++ b/stats.html @@ -1,28 +1,44 @@ - + + + + -

La ḡ1 en quelques chiffres

+ -heure: _heure
-noeud scanné: http://192.168.9.54:45000
+

La Ḡ1 en quelques chiffres

-
---
+
+Date: _day - _heure
+Noeud scanné: https://duniter-g1.p2p.legal
+ +
---

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

Reçus simples wallets: _txInSimple
Envoyé simples wallets: _txOutSimple
Soldes simples wallets: _soldeSimple (_poucentSoldeMembers%)
-
---
+
---

Reçus membres: _txInMembers
Envoyé membres: _txOutMembers
Soldes membres: _soldeMembers
-Total DU non consommés: _nonConsumedUDT
+Masse monétaire: _monetaryMass +
+ +
+
+| Liste de tous les wallets +| Liste des wallets membres +| Liste des simples portefeuilles | +
+ +