This repository was archived by the owner on Jan 22, 2025. It is now read-only.
File tree 1 file changed +22
-3
lines changed
metrics/influx-enterprise
1 file changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -22,13 +22,32 @@ check_service() {
22
22
23
23
# Loop through the servers
24
24
for server in " ${servers[@]} " ; do
25
- # Check if the service is running
26
- if ssh -o StrictHostKeyChecking=no sol@" $server " sudo systemctl is-active " $service " > /dev/null; then
25
+ ssh_success=false
26
+ ssh_attempts=0
27
+ while ! $ssh_success && [ $ssh_attempts -lt 3 ]; do
28
+ # Check if the service is running
29
+ if ssh -o StrictHostKeyChecking=no sol@" $server " sudo systemctl is-active " $service " > /dev/null 2>&1 ; then
30
+ ssh_success=true
31
+ else
32
+ ssh_attempts=$(( ssh_attempts + 1 ))
33
+ sleep 5
34
+ fi
35
+ done
36
+
37
+ if $ssh_success ; then
27
38
# Service is running
28
39
message=" The $service service is running on $server ."
29
40
echo " $message "
30
41
else
31
- # Service is not running, try to restart it
42
+ # SSH connection failed after retries
43
+ message=" ERROR: Unable to establish SSH connection to $server after 3 retries."
44
+ echo " $message "
45
+ curl -H " Content-Type: application/json" -d ' {"content":"' " $message " ' , manual intervention is required."}' " $DISCORD_WEBHOOK "
46
+ continue
47
+ fi
48
+
49
+ # Service is not running, try to restart it
50
+ if ! $ssh_success ; then
32
51
message=" The $service service is not running on $server . Restarting..."
33
52
echo " $message "
34
53
curl -H " Content-Type: application/json" -d ' {"content":"' " $message " ' "}' " $DISCORD_WEBHOOK "
You can’t perform that action at this time.
0 commit comments