Add history
This commit is contained in:
parent
da76528f96
commit
82ae843307
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
startTime=$(date +'%T')
|
startTime=$(date +'%H:%M')
|
||||||
day=$(date +'%d-%m-%y')
|
day=$(date +'%d-%m-%y')
|
||||||
id=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
|
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)
|
de=$(cat /dev/urandom | tr -dc '0-9' | fold -w 1 | head -n 1)
|
||||||
|
@ -14,7 +14,7 @@ indexhtml="/var/www/g1-stats/index.html"
|
||||||
###
|
###
|
||||||
|
|
||||||
echo "######"
|
echo "######"
|
||||||
echo "$day à startTime"
|
echo "$day à $startTime"
|
||||||
[[ -z $(which jq) || -z $(which bc) ]] && apt update && apt install jq bc
|
[[ -z $(which jq) || -z $(which bc) ]] && apt update && apt install jq bc
|
||||||
echo "Initialisation ..."
|
echo "Initialisation ..."
|
||||||
outFile="/tmp/g1-stats-$day-$startTime_$id"
|
outFile="/tmp/g1-stats-$day-$startTime_$id"
|
||||||
|
@ -26,23 +26,29 @@ unset 'TXBLOCKS[${#TXBLOCKS[@]}-1]'
|
||||||
MEMBERS=($(curl -s ${DUNITER}/wot/members | jq '.results[].pubkey' | tr -d '"'))
|
MEMBERS=($(curl -s ${DUNITER}/wot/members | jq '.results[].pubkey' | tr -d '"'))
|
||||||
nbrMembers=${#MEMBERS[@]}
|
nbrMembers=${#MEMBERS[@]}
|
||||||
lastBloc=${TXBLOCKS[-1]}
|
lastBloc=${TXBLOCKS[-1]}
|
||||||
#nbrBlocs=${#TXBLOCKS[@]}
|
isWeb=$1
|
||||||
|
|
||||||
|
echo "Heure de début: $startTime"
|
||||||
loopWalletUp() {
|
loopWalletUp() {
|
||||||
for i in ${TXBLOCKS[*]}; do
|
for i in ${TXBLOCKS[*]}; do
|
||||||
|
|
||||||
[[ -z ${TXBLOCKS[$i]} ]] && break
|
[[ -z ${TXBLOCKS[$i]} ]] && break
|
||||||
sleep 0.1
|
sleep 0.1
|
||||||
WALLETS=$(curl -s ${DUNITER2}/blockchain/block/${TXBLOCKS[$i]} | jq '.transactions[].outputs[]' | tr -d '"' | awk -F '(' '{ print $2 }' | tr -d ')' || exit)
|
WALLETS0=$(curl -s ${DUNITER}/blockchain/block/${TXBLOCKS[$i]})
|
||||||
bloc=${TXBLOCKS[$i]}
|
until WALLETS=$(echo $WALLETS0 | jq '.transactions[].outputs[]'); do
|
||||||
[[ $bloc == "153777" ]] && echo "en plein debug ... .." && sleep 10
|
echo -e "iter $iter \n$WALLETS0"
|
||||||
wallets+=$(echo -e "$WALLETS \n" | sed 's/ /\\n/g')
|
sleep 2
|
||||||
|
WALLETS0=$(curl -s ${DUNITER}/blockchain/block/${TXBLOCKS[$i]})
|
||||||
|
done
|
||||||
|
[[ -z "$WALLETS" ]] && echo "Erreur: $RET" && exit 1
|
||||||
|
WALLETS=$(echo "$WALLETS" | tr -d '"' | awk -F '(' '{ print $2 }' | tr -d ')')
|
||||||
|
|
||||||
|
bloc=${TXBLOCKS[$i]}
|
||||||
|
wallets+=$(echo -e "$WALLETS \n" | sed 's/ /\\n/g')
|
||||||
|
|
||||||
progress=$(echo "scale=1; $bloc*100/$lastBloc/1" | bc)
|
progress=$(echo "scale=1; $bloc*100/$lastBloc/1" | bc)
|
||||||
|
|
||||||
|
|
||||||
if [[ $1 != "web" ]]; then
|
if [[ $isWeb != "web" ]]; then
|
||||||
clear
|
clear
|
||||||
echo "Heure de début: $startTime"
|
echo "Heure de début: $startTime"
|
||||||
echo
|
echo
|
||||||
|
@ -56,8 +62,6 @@ loopWalletUp() {
|
||||||
loopWalletUp
|
loopWalletUp
|
||||||
echo -e "$(echo -e "$wallets" | sort -u)" > $outFile
|
echo -e "$(echo -e "$wallets" | sort -u)" > $outFile
|
||||||
|
|
||||||
#cat /var/www/g1-stats/wallets-g1.txt > $outFile
|
|
||||||
|
|
||||||
loopMembers() {
|
loopMembers() {
|
||||||
iter=0
|
iter=0
|
||||||
for i in ${MEMBERS[*]}; do
|
for i in ${MEMBERS[*]}; do
|
||||||
|
@ -65,7 +69,7 @@ for i in ${MEMBERS[*]}; do
|
||||||
progress=$(echo "scale=0; $iter*100/$nbrMembers/1" | bc)
|
progress=$(echo "scale=0; $iter*100/$nbrMembers/1" | bc)
|
||||||
if [[ $progress =~ ^(0|10|20|30|40|50|60|70|80|90|99)$ ]]; then
|
if [[ $progress =~ ^(0|10|20|30|40|50|60|70|80|90|99)$ ]]; then
|
||||||
[[ $progress == 99 ]] && progress=100
|
[[ $progress == 99 ]] && progress=100
|
||||||
if [[ $1 != "web" ]]; then
|
if [[ $isWeb != "web" ]]; then
|
||||||
clear
|
clear
|
||||||
echo "Heure de début: $startTime"
|
echo "Heure de début: $startTime"
|
||||||
echo
|
echo
|
||||||
|
@ -105,10 +109,20 @@ web() {
|
||||||
sed -i "s/_txInMembers/$txInMembers/g" $indexhtml
|
sed -i "s/_txInMembers/$txInMembers/g" $indexhtml
|
||||||
sed -i "s/_txOutMembers/$txOutMembers/g" $indexhtml
|
sed -i "s/_txOutMembers/$txOutMembers/g" $indexhtml
|
||||||
sed -i "s/_soldeMembers/$soldeMembers/g" $indexhtml
|
sed -i "s/_soldeMembers/$soldeMembers/g" $indexhtml
|
||||||
sed -i "s/_poucentSoldeMembers/$poucentSoldeMembers/g" $indexhtml
|
sed -i "s/_pourcentSimpleWallet/$pourcentSimpleWallet/g" $indexhtml
|
||||||
sed -i "s/_nonConsumedUDT/$nonConsumedUDT/g" $indexhtml
|
sed -i "s/_nonConsumedUDT/$nonConsumedUDT/g" $indexhtml
|
||||||
sed -i "s/_monetaryMass/$monetaryMass/g" $indexhtml
|
sed -i "s/_monetaryMass/$monetaryMass/g" $indexhtml
|
||||||
chown www-data:www-data $indexhtml 2>/dev/null
|
chown www-data:www-data $indexhtml 2>/dev/null
|
||||||
|
|
||||||
|
cat "$outFile" | grep . > /var/www/g1-stats/wallets-g1.txt
|
||||||
|
echo -e "${MEMBERS[@]}" | sed 's/ /\n/g' > /var/www/g1-stats/wallets-g1-membres.txt
|
||||||
|
echo -e "$simpleWallets" > /var/www/g1-stats/wallets-g1-simple.txt
|
||||||
|
|
||||||
|
if [[ "$startTime" == "00:00" ]]; then
|
||||||
|
cp $indexhtml /var/www/g1-stats/history/index_$day.html
|
||||||
|
sed -i "s/style.css/..\/style.css/g" /var/www/g1-stats/history/index_$day.html
|
||||||
|
chown -R www-data:www-data /var/www/g1-stats
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
echo -e "\n ---\n"
|
echo -e "\n ---\n"
|
||||||
|
@ -120,10 +134,6 @@ echo -e "\n ---\n"
|
||||||
|
|
||||||
echo "Extraction wallets membres / Simples portefeuille"
|
echo "Extraction wallets membres / Simples portefeuille"
|
||||||
|
|
||||||
cat "$outFile" | grep . > /var/www/g1-stats/wallets-g1.txt
|
|
||||||
|
|
||||||
echo -e "${MEMBERS[@]}" | sed 's/ /\n/g' > /var/www/g1-stats/wallets-g1-membres.txt
|
|
||||||
|
|
||||||
simpleWallets=$(cat $outFile)
|
simpleWallets=$(cat $outFile)
|
||||||
|
|
||||||
echo "Isolation des simples portefeuilles..."
|
echo "Isolation des simples portefeuilles..."
|
||||||
|
@ -131,7 +141,9 @@ for i in ${MEMBERS[@]}; do
|
||||||
simpleWallets=$(echo "$simpleWallets" | grep -v "$i")
|
simpleWallets=$(echo "$simpleWallets" | grep -v "$i")
|
||||||
done
|
done
|
||||||
|
|
||||||
echo -e "$simpleWallets" > /var/www/g1-stats/wallets-g1-simple.txt
|
#cat "$outFile" | grep . > /var/www/g1-stats/wallets-g1.txt
|
||||||
|
#echo -e "${MEMBERS[@]}" | sed 's/ /\n/g' > /var/www/g1-stats/wallets-g1-membres.txt
|
||||||
|
#echo -e "$simpleWallets" > /var/www/g1-stats/wallets-g1-simple.txt
|
||||||
|
|
||||||
echo -e "\n ---\n"
|
echo -e "\n ---\n"
|
||||||
|
|
||||||
|
@ -142,8 +154,14 @@ txOutT=0
|
||||||
nonConsumedUDT=0
|
nonConsumedUDT=0
|
||||||
nonConsumedUD=0
|
nonConsumedUD=0
|
||||||
for i in $pubkeys; do
|
for i in $pubkeys; do
|
||||||
txInL=$(curl -s "http://g1.data.duniter.fr/g1/movement/_search?filter_path=hits.hits._source&size=10000&q=recipient:$i&pretty")
|
until txInL=$(curl -s "http://g1.data.duniter.fr/g1/movement/_search?filter_path=hits.hits._source&size=10000&q=recipient:$i&pretty"); do
|
||||||
txOutL=$(curl -s "http://g1.data.duniter.fr/g1/movement/_search?filter_path=hits.hits._source&size=10000&q=issuer:$i&pretty")
|
echo "Erreur: $i"
|
||||||
|
sleep 2
|
||||||
|
done
|
||||||
|
until txOutL=$(curl -s "http://g1.data.duniter.fr/g1/movement/_search?filter_path=hits.hits._source&size=10000&q=issuer:$i&pretty"); do
|
||||||
|
echo "Erreur: $i"
|
||||||
|
sleep 2
|
||||||
|
done
|
||||||
|
|
||||||
if [[ $1 == "mbr" ]]; then
|
if [[ $1 == "mbr" ]]; then
|
||||||
nonConsumedUD=$(curl -s ${DUNITER}/ud/history/$i | jq '.history.history[].amount' | awk '{s+=$1} END {print s}') || nonConsumedUD=0
|
nonConsumedUD=$(curl -s ${DUNITER}/ud/history/$i | jq '.history.history[].amount' | awk '{s+=$1} END {print s}') || nonConsumedUD=0
|
||||||
|
@ -156,7 +174,7 @@ for i in $pubkeys; do
|
||||||
|
|
||||||
solde=$(echo -e "scale=2; (($txIn-$txOut+$nonConsumedUD)/100)+$solde" | bc)
|
solde=$(echo -e "scale=2; (($txIn-$txOut+$nonConsumedUD)/100)+$solde" | bc)
|
||||||
|
|
||||||
txInT=$(echo -e "scale=2; ($txIn+$nonConsumedUD/100)+$txInT" | bc)
|
txInT=$(echo -e "scale=2; (($txIn+$nonConsumedUD)/100)+$txInT" | bc)
|
||||||
txOutT=$(echo -e "scale=2; ($txOut/100)+$txOutT" | bc)
|
txOutT=$(echo -e "scale=2; ($txOut/100)+$txOutT" | bc)
|
||||||
|
|
||||||
done
|
done
|
||||||
|
@ -166,9 +184,10 @@ echo "Récupération du solde des simples wallets..."
|
||||||
|
|
||||||
pubkeys=$simpleWallets
|
pubkeys=$simpleWallets
|
||||||
getSolde
|
getSolde
|
||||||
txInSimple=$txInT
|
txInSimple=$(echo $txInT | tr . , | sed ':a;s/\B[0-9]\{3\}\>/.&/;ta')
|
||||||
txOutSimple=$txOutT
|
txOutSimple=$(echo $txOutT | tr . , | sed ':a;s/\B[0-9]\{3\}\>/.&/;ta')
|
||||||
soldeSimple=$solde
|
soldeSimpleBrut=$(echo $solde)
|
||||||
|
soldeSimple=$(echo $soldeSimpleBrut | tr . , | sed ':a;s/\B[0-9]\{3\}\>/.&/;ta')
|
||||||
echo -e "Reçus simples wallets:\t $txInSimple"
|
echo -e "Reçus simples wallets:\t $txInSimple"
|
||||||
echo -e "Envoyé simples wallets:\t $txOutSimple"
|
echo -e "Envoyé simples wallets:\t $txOutSimple"
|
||||||
echo -e "Soldes simples wallets:\t $soldeSimple"
|
echo -e "Soldes simples wallets:\t $soldeSimple"
|
||||||
|
@ -179,25 +198,27 @@ echo "Récupération du solde des membres..."
|
||||||
|
|
||||||
pubkeys=${MEMBERS[@]}
|
pubkeys=${MEMBERS[@]}
|
||||||
getSolde
|
getSolde
|
||||||
txInMembers=$txInT
|
txInMembers=$(echo $txInT | tr . , | sed ':a;s/\B[0-9]\{3\}\>/.&/;ta')
|
||||||
txOutMembers=$txOutT
|
txOutMembers=$(echo $txOutT | tr . , | sed ':a;s/\B[0-9]\{3\}\>/.&/;ta')
|
||||||
soldeMembers=$solde
|
soldeMembersBrut=$(echo $solde)
|
||||||
|
soldeMembers=$(echo $soldeMembersBrut | tr . , | sed ':a;s/\B[0-9]\{3\}\>/.&/;ta')
|
||||||
echo -e "Reçus membres:\t $txInMembers"
|
echo -e "Reçus membres:\t $txInMembers"
|
||||||
echo -e "Envoyé membres:\t $txOutMembers"
|
echo -e "Envoyé membres:\t $txOutMembers"
|
||||||
echo -e "Soldes membres:\t $soldeMembers"
|
echo -e "Soldes membres:\t $soldeMembers"
|
||||||
echo -e "Total DU non consumés:\t $nonConsumedUDT"
|
echo -e "Total DU non consumés:\t $nonConsumedUDT"
|
||||||
|
|
||||||
monetaryMass=$(curl -s ${DUNITER}/blockchain/current | jq .monetaryMass)
|
monetaryMass=$(curl -s ${DUNITER}/blockchain/current | jq .monetaryMass)
|
||||||
monetaryMass=$(echo -e "scale=2; ($monetaryMass/100)/1" | bc)
|
monetaryMassBrut=$(echo -e "scale=2; ($monetaryMass/100)/1" | bc)
|
||||||
soldeWalletMembers=$(echo "scale=2; $soldeMembers+$soldeSimple" | bc)
|
monetaryMass=$(echo "$monetaryMassBrut" | tr . , | sed ':a;s/\B[0-9]\{3\}\>/.&/;ta')
|
||||||
poucentSoldeMembers=$(echo "scale=1; $soldeMembers*100/$monetaryMass/1" | bc)
|
soldeWalletMembers=$(echo "scale=2; $soldeMembersBrut+$soldeSimpleBrut" | bc | tr . , | sed ':a;s/\B[0-9]\{3\}\>/.&/;ta')
|
||||||
|
pourcentSimpleWallet=$(echo "scale=1; $soldeSimpleBrut*100/$monetaryMassBrut/1" | bc)
|
||||||
|
|
||||||
echo -e "\n ---\n"
|
echo -e "\n ---\n"
|
||||||
echo -e "Solde des membres (sans DU):\t $soldeWalletMembers"
|
echo -e "Solde des membres (sans DU):\t $soldeWalletMembers"
|
||||||
echo -e "Masse Monétaire:\t $monetaryMass Ḡ1"
|
echo -e "Masse Monétaire:\t $monetaryMass Ḡ1"
|
||||||
|
|
||||||
|
[[ $isWeb == "web" ]] && web
|
||||||
[[ $1 == "web" ]] && web
|
|
||||||
|
|
||||||
rm $outFile
|
rm $outFile
|
||||||
echo "$day - Heure de fin: $(date +'%T')"
|
day=$(date +'%d-%m-%y')
|
||||||
|
echo "$day - Heure de fin: $(date +'%H:%M')"
|
||||||
|
|
44
stats.html
44
stats.html
|
@ -9,34 +9,34 @@
|
||||||
<center><h1>La Ḡ1 en quelques chiffres</h1></center>
|
<center><h1>La Ḡ1 en quelques chiffres</h1></center>
|
||||||
|
|
||||||
<div id=mainbloc>
|
<div id=mainbloc>
|
||||||
Date: <b>_day - _heure</b> <br>
|
<pre>
|
||||||
Noeud scanné: <b>https://duniter-g1.p2p.legal</b> <br>
|
Date: <b>_day - _heure</b>
|
||||||
|
Noeud scanné: <b>https://duniter-g1.p2p.legal</b>
|
||||||
<br>---<br><br>
|
---
|
||||||
|
Nombre total de wallet: <b>_nbrTotalWallets</b>
|
||||||
Nombre total de wallet: <b>_nbrTotalWallets</b> <br>
|
Nombre de membres: <b>_nbrMembers</b> (_pourcentMbrs%)
|
||||||
Nombre de membres: <b>_nbrMembers</b> (_pourcentMbrs%) <br>
|
Nombre de simple portefeuille: <b>_nbrSimpleWallets</b> (_pourcentWallets%)
|
||||||
Nombre de simple portefeuille: <b>_nbrSimpleWallets</b> (_pourcentWallets%) <br>
|
---
|
||||||
|
Reçus simples wallets: <b>_txInSimple Ḡ1</b>
|
||||||
<br>---<br><br>
|
Envoyé simples wallets: <b>_txOutSimple Ḡ1</b>
|
||||||
|
Soldes simples wallets: <b>_soldeSimple Ḡ1</b> (_pourcentSimpleWallet%)
|
||||||
Reçus simples wallets: <b>_txInSimple</b><br>
|
---
|
||||||
Envoyé simples wallets: <b>_txOutSimple</b><br>
|
Reçus membres: <b>_txInMembers Ḡ1</b>
|
||||||
Soldes simples wallets: <b>_soldeSimple</b> (_poucentSoldeMembers%)<br>
|
Envoyé membres: <b>_txOutMembers Ḡ1</b>
|
||||||
|
Soldes membres: <b>_soldeMembers Ḡ1</b>
|
||||||
<br>---<br><br>
|
---
|
||||||
|
Masse monétaire: <b>_monetaryMass Ḡ1</b>
|
||||||
Reçus membres: <b>_txInMembers</b><br>
|
</pre>
|
||||||
Envoyé membres: <b>_txOutMembers</b><br>
|
|
||||||
Soldes membres: <b>_soldeMembers</b><br>
|
|
||||||
Masse monétaire: <b>_monetaryMass</b>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<br>
|
|
||||||
<center>
|
<center>
|
||||||
| <a href="/wallets-g1.txt">Liste de tous les wallets</a>
|
| <a href="/wallets-g1.txt">Liste de tous les wallets</a>
|
||||||
| <a href="/wallets-g1-membres.txt">Liste des wallets membres</a>
|
| <a href="/wallets-g1-membres.txt">Liste des wallets membres</a>
|
||||||
| <a href="/wallets-g1-simple.txt">Liste des simples portefeuilles</a> |
|
| <a href="/wallets-g1-simple.txt">Liste des simples portefeuilles</a> |
|
||||||
|
|
||||||
|
<br><br>
|
||||||
|
Ces données sont mises à jours toutes les 3 heures.<br>
|
||||||
|
<a href="/history/">Consulter l'historique</a>
|
||||||
</center>
|
</center>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
Loading…
Reference in New Issue