-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Expand file tree
/
Copy pathtest2.sh
More file actions
executable file
·31 lines (27 loc) · 756 Bytes
/
test2.sh
File metadata and controls
executable file
·31 lines (27 loc) · 756 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
servers=("server1" "server2" "server3")
for server in "${servers[@]}"; do
check_resource_utilization "$server"
done
while ! aws ec2 describe-instance-status --instance-ids i-1234567890abcdef0 | grep -q "running"; do
echo "Waiting for the EC2 instance to be running..."
sleep 10
done
while true; do
if tail -n 1 /var/log/app.log | grep -q "ERROR"; then
send_alert "Error detected in the log."
fi
sleep 5
done
while true; do
replication_lag=$(mysql -e "SHOW SLAVE STATUS\G" | grep "Seconds_Behind_Master" | awk '{print $2}')
if [ "$replication_lag" -gt 60 ]; then
trigger_data_sync
fi
sleep 60
done
while true; do
if ! check_service_health; then
restart_service
fi
sleep 30
done