code: def check_member_state(self):
          
          bad_states = (0, 3, 4, 5, 6, 9)
          try:
              rs_status = self.run_command('replSetGetStatus')
              bad_members = [member for member in rs_status['members']
                             if member['state'] in bad_states]
              if bad_members:
                  return False
          except pymongo.errors.AutoReconnect:
              # catch 'No replica set primary available' Exception
              return False
          logger.debug("all members in correct state")
          return True
docs: Verify that all RS members have an acceptable state.