Skip to content

Instantly share code, notes, and snippets.

@velotiotech
Created June 17, 2020 05:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save velotiotech/bd3d7b23fbc880e9373537f222e7ce02 to your computer and use it in GitHub Desktop.
Save velotiotech/bd3d7b23fbc880e9373537f222e7ce02 to your computer and use it in GitHub Desktop.
Velotio - HashiCorp Consul Part 2 - MongoDB Replica Set - Check Secondary instance using shell script
#!/bin/bash
mongo_secondary=$(mongo --quiet --eval 'JSON.stringify(db.isMaster())' | jq -r .secondary 2> /dev/null)
if [[ $mongo_secondary == false ]]; then
exit 1
fi
echo "Mongo secondary healthy and reachable"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment