@@ -11,6 +11,10 @@ function send_slack_message() {
1111 $SLACK_WEBHOOK_URL
1212}
1313
14+ # Flags to avoid sending multiple alerts
15+ no_new_batches_alert=false
16+ no_verified_batches_alert=false
17+
1418while :
1519do
1620 last_block=$( cast block --rpc-url $RPC_URL -f number)
2125 new_batch_logs=$( cast logs --rpc-url $RPC_URL --from-block $from_block --address $CONTRACT_ADDRESS $NEW_BATCH_TOPIC )
2226 if [ -z " $new_batch_logs " ]; then
2327 printf " No new batches logs found\n"
24- send_slack_message " 🚨 ALERT: No new batches in Service Manager since block $from_block "
28+ if [ " $no_new_batches_alert " = false ]; then
29+ send_slack_message " 🚨 ALERT: No new batches in Service Manager since block $from_block "
30+ fi
31+ no_new_batches_alert=true
32+ else
33+ printf " New batches logs found\n"
34+ if [ " $no_new_batches_alert " = true ]; then
35+ send_slack_message " 🟩 INFO: Batches creation resumed in Service Manager since block $from_block "
36+ fi
37+ no_new_batches_alert=false
2538 fi
2639
2740 verified_batch_logs=$( cast logs --rpc-url $RPC_URL --from-block $from_block --address $CONTRACT_ADDRESS $VERIFIED_BATCH_TOPIC )
2841 if [ -z " $verified_batch_logs " ]; then
2942 printf " No verified batches logs found\n"
30- send_slack_message " 🚨 ALERT: No new verified batches in Service Manager since block $from_block "
43+ if [ " $no_verified_batches_alert " = false ]; then
44+ send_slack_message " 🚨 ALERT: No verified batches in Service Manager since block $from_block "
45+ fi
46+ no_verified_batches_alert=true
47+ else
48+ printf " Verified batches logs found\n"
49+ if [ " $no_verified_batches_alert " = true ]; then
50+ send_slack_message " 🟩 INFO: Batches verification resumed in Service Manager since block $from_block "
51+ fi
52+ no_verified_batches_alert=false
3153 fi
3254
3355 sleep 300
0 commit comments