Last active
March 16, 2022 16:49
-
-
Save tlesh989/f06478c6c17580b476fc30eccb20df73 to your computer and use it in GitHub Desktop.
script to test connectivity to all nodes in a mongodb cluster
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
readarray -t mongo_cluster <<< "$(dig +short srv _mongodb._tcp.example.com | awk '{print $4}')" | |
function ping_cluster() { | |
a=("$@") | |
for i in "${a[@]}" | |
do | |
nc -w 3 -z -v "$i" 27017 | |
done | |
} | |
ping_cluster "${mongo_cluster[@]}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment