You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#!/bin/bash# check_sync.sh
CURRENT_BLOCK=$(cat ~/.ethereum/metadata.json | jq '.blockNumber')
CURRENT_TIME=$(cat ~/.ethereum/metadata.json | jq '.timestamp')
NOW=$(date +%s)
DIFF=$((NOW - CURRENT_TIME))echo"Hauteur actuelle: $CURRENT_BLOCK"echo"Dernière mise à jour: il y a $DIFF secondes"if [ $DIFF-lt 30 ];thenecho"✓ Le nœud est synchronisé"exit 0
elseecho"✗ Le nœud est en retard de $DIFF secondes"exit 1
fi
3. Envoyer une alerte si le nœud ne se synchronise plus
#!/bin/bash# alert_sync.sh
METADATA_FILE=~/.ethereum/metadata.json
MAX_DELAY=300 # 5 minuteswhiletrue;doif [ !-f"$METADATA_FILE" ];thenecho"⚠️ Fichier metadata.json introuvable"# Envoyer une alerte (email, Slack, etc.)
sleep 60
continuefi
TIMESTAMP=$(cat $METADATA_FILE| jq '.timestamp')
NOW=$(date +%s)
DIFF=$((NOW - TIMESTAMP))if [ $DIFF-gt$MAX_DELAY ];thenecho"🚨 ALERTE: Le nœud n'a pas synchronisé depuis $DIFF secondes"# Envoyer une alerteelseecho"✓ Nœud OK (dernier bloc il y a $DIFF secondes)"fi
sleep 60
done
Intégration avec des outils de monitoring
1. Prometheus exporter simple
#!/bin/bash# ethereum_exporter.sh
cat <<EOF > /var/lib/prometheus/node_exporter/ethereum.prom# HELP ethereum_block_height Hauteur actuelle de la blockchain# TYPE ethereum_block_height gaugeethereum_block_height $(cat ~/.ethereum/metadata.json | jq '.blockNumber')# HELP ethereum_block_transactions Nombre de transactions dans le dernier bloc# TYPE ethereum_block_transactions gaugeethereum_block_transactions $(cat ~/.ethereum/metadata.json | jq '.txCount')# HELP ethereum_block_gas_used Gas utilisé dans le dernier bloc# TYPE ethereum_block_gas_used gaugeethereum_block_gas_used $(cat ~/.ethereum/metadata.json | jq '.gasUsed')# HELP ethereum_block_timestamp Timestamp du dernier bloc# TYPE ethereum_block_timestamp gaugeethereum_block_timestamp $(cat ~/.ethereum/metadata.json | jq '.timestamp')EOF