Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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