Skip to content

Commit

Permalink
remove inactive hosts (solana-labs#31521)
Browse files Browse the repository at this point in the history
  • Loading branch information
joedenis01 authored May 6, 2023
1 parent 77a56b0 commit f42955c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 22 deletions.
34 changes: 13 additions & 21 deletions metrics/influx-enterprise/status.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,24 @@ check_service() {

# Loop through the servers
for server in "${servers[@]}"; do
ssh_success=false
ssh_attempts=0
while ! $ssh_success && [ $ssh_attempts -lt 3 ]; do
local service_not_running=true
local retries=3
for _ in $(seq 1 $retries); do
# Check if the service is running
if ssh -o StrictHostKeyChecking=no sol@"$server" sudo systemctl is-active "$service" >/dev/null 2>&1; then
ssh_success=true
if ssh -o StrictHostKeyChecking=no sol@"$server" sudo systemctl is-active "$service" >/dev/null; then
# Service is running
message="The $service service is running on $server."
echo "$message"
service_not_running=false
break
else
ssh_attempts=$((ssh_attempts + 1))
sleep 5
# Service is not running, wait for 10 seconds and check again
sleep 10
fi
done

if $ssh_success; then
# Service is running
message="The $service service is running on $server."
echo "$message"
else
# SSH connection failed after retries
message="ERROR: Unable to establish SSH connection to $server after 3 retries."
echo "$message"
curl -H "Content-Type: application/json" -d '{"content":"'"$message"', manual intervention is required."}' "$DISCORD_WEBHOOK"
continue
fi

# Service is not running, try to restart it
if ! $ssh_success; then
if $service_not_running; then
# Service is not running, send alert and try to restart it
message="The $service service is not running on $server. Restarting..."
echo "$message"
curl -H "Content-Type: application/json" -d '{"content":"'"$message"'"}' "$DISCORD_WEBHOOK"
Expand Down
2 changes: 1 addition & 1 deletion metrics/metrics-main/prometheus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ scrape_configs:
scrape_interval: 15s
scrape_timeout: 14s
static_configs:
- targets: ['dev-server-us-da11:9100','dev-server-us-ny5:9100','dev-server-us-sv15:9100','dev-server-eu-am6:9100','dev-server-asia-sg1:9100','dev-server-us-da11-2:9100','dev-server-us-da11-3:9100','dev-server-us-da11-4:9100','dev-server-us-da11-5:9100','dev-server-asia-hk2:9100','dev-server-asia-sg1-2:9100','dev-server-asia-ty11:9100','dev-server-eu-am6-2:9100','dev-server-asia-sg1-2:9100','dev-server-us-sv15-2:9100','dev-server-us-da11-6:9100','dev-server-us-da11-7:9100','dev-server-eu-ld7-1:9100','dev-server-us-da11-8:9100','dev-server-eu-ld7-2:9100']
- targets: ['dev-server-us-da11:9100','dev-server-us-ny5:9100','dev-server-us-sv15:9100','dev-server-eu-am6:9100','dev-server-asia-sg1:9100','dev-server-us-da11-2:9100','dev-server-us-da11-3:9100','dev-server-us-da11-4:9100','dev-server-us-da11-5:9100','dev-server-asia-hk2:9100','dev-server-asia-sg1-2:9100','dev-server-eu-am6-2:9100','dev-server-asia-sg1-2:9100','dev-server-us-sv15-2:9100','dev-server-us-da11-6:9100','dev-server-us-da11-7:9100','dev-server-eu-ld7-1:9100','dev-server-us-da11-8:9100','dev-server-eu-ld7-2:9100']

- job_name: 'Development'
scrape_interval: 15s
Expand Down

0 comments on commit f42955c

Please sign in to comment.