File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ SLACK_WEBHOOK_URL = <YOUR_SLACK_WEBHOOK_URL>
2+
3+ # Variables for contract_alerts.sh
4+ RPC_URL = <YOUR_RPC_URL>
5+ CONTRACT_ADDRESS = <YOUR_CONTRACT_ADDRESS>
6+ NEW_BATCH_TOPIC = <YOUR_NEW_BATCH_TOPIC>
7+ VERIFIED_BATCH_TOPIC = <YOUR_VERIFIED_BATCH_TOPIC>
8+
9+ # Variables for process_errors_alerts.sh
10+ SERVICE = <YOUR_SERVICE>
11+ EXPRESSION = <GREP_EXPRESSION>
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ # Load env file from $1 path
4+ source $1
5+
6+ # Function to send slack message
7+ # @param message
8+ function send_slack_message() {
9+ curl -X POST -H ' Content-type: application/json' \
10+ --data " {\" text\" :\" $1 \" }" \
11+ $SLACK_WEBHOOK_URL
12+ }
13+
14+ while :
15+ do
16+ last_block=$( cast block --rpc-url $RPC_URL -f number)
17+ printf " Last block: %s\n" $last_block
18+
19+ from_block=$(( $last_block - 10 ))
20+
21+ new_batch_logs=$( cast logs --rpc-url $RPC_URL --from-block $from_block --address $CONTRACT_ADDRESS $NEW_BATCH_TOPIC )
22+ if [ -z " $new_batch_logs " ]; then
23+ printf " No new batches logs found\n"
24+ send_slack_message " 🚨 ALERT: No new batches in Service Manager since block $from_block "
25+ fi
26+
27+ verified_batch_logs=$( cast logs --rpc-url $RPC_URL --from-block $from_block --address $CONTRACT_ADDRESS $VERIFIED_BATCH_TOPIC )
28+ if [ -z " $verified_batch_logs " ]; then
29+ printf " No verified batches logs found\n"
30+ send_slack_message " 🚨 ALERT: No new verified batches in Service Manager since block $from_block "
31+ fi
32+
33+ sleep 100
34+ done
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ source $1
4+
5+ journalctl -feu " $SERVICE " -n 0 | while read LINE; do
6+ (echo " $LINE " | grep -e " $EXPRESSION " ) && curl -X POST --silent --data-urlencode \
7+ " payload={\" text\" : \" $( echo $LINE | sed " s/\" /'/g" ) \" }" " $SLACK_WEBHOOK_URL " ;
8+ done
You can’t perform that action at this time.
0 commit comments