Created
          April 1, 2019 05:25 
        
      - 
      
- 
        Save pranavcode/c70d01c4b0bede7c2033071b473dbd5a to your computer and use it in GitHub Desktop. 
    Velotio - HashiCorp Consul Part 2 - MongoDB Replica Set - Check Primary instance using shell script
  
        
  
    
      This file contains hidden or 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
    
  
  
    
  | #!/bin/bash | |
| mongo_primary=$(mongo --quiet --eval 'JSON.stringify(db.isMaster())' | jq -r .ismaster 2> /dev/null) | |
| if [[ $mongo_primary == false ]]; then | |
| exit 1 | |
| fi | |
| echo "Mongo primary healthy and reachable" | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment