(self, members, replset_name)
Report all the members' state changes in the replica set.
        This method only runs on the primary.
Report all the members' state changes in the replica set.
        This method only runs on the primary.
Report all the members state changes in the replica set . This method only runs on the primary .
def _report_replica_set_states(self, members, replset_name):
        """
        Report all the members' state changes in the replica set.
        This method only runs on the primary.
        """

        for member in members:
            # The id field cannot be changed for a given replica set member.
            member_id = member['_id']
            status_id = member['state']
            old_state = self.check.last_states_by_server.get(member_id)
            if not old_state:
                # First time the agent sees this replica set member.
                continue

            if old_state == status_id:
                continue
            previous_short_state_str = get_state_name(old_state)
            short_state_str = get_state_name(status_id)
            long_state_str = get_long_state_name(status_id)
            node_hostname = member['name']

            msg_title = "{} is {} for {}".format(node_hostname, short_state_str, replset_name)
            msg = (
                "MongoDB {node} (_id: {id}, {uri}) just reported as {status} ({status_short}) "
                "for {replset_name}; it was {old_state} before.".format(
                    node=node_hostname,
                    id=member_id,
                    uri=self.check._config.clean_server_name,
                    status=long_state_str,
                    status_short=short_state_str,
                    replset_name=replset_name,
                    old_state=previous_short_state_str,
                )
            )

            event_payload = {
                'timestamp': int(time.time()),
                'source_type_name': SOURCE_TYPE_NAME,
                'msg_title': msg_title,
                'msg_text': msg,
                'host': node_hostname,
                'tags': [
                    'action:mongo_replset_member_status_change',
                    'member_status:' + short_state_str,
                    'previous_member_status:' + previous_short_state_str,
                    'replset:' + replset_name,
                ],
            }
            if node_hostname == 'localhost':
                # Do not submit events with a 'localhost' hostname.
                event_payload['host'] = self.hostname
            self.check.event(event_payload)
def _report_replica_set_states ( self , members , replset_name ) : for member in members : # The id field cannot be changed for a given replica set member. member_id = member [ '_id' ] status_id = member [ 'state' ] old_state = self . check . last_states_by_server . get ( member_id ) if not old_state : # First time the agent sees this replica set member. continue if old_state == status_id : continue previous_short_state_str = get_state_name ( old_state ) short_state_str = get_state_name ( status_id ) long_state_str = get_long_state_name ( status_id ) node_hostname = member [ 'name' ] msg_title = "{} is {} for {}" . format ( node_hostname , short_state_str , replset_name ) msg = ( "MongoDB {node} (_id: {id}, {uri}) just reported as {status} ({status_short}) " "for {replset_name}; it was {old_state} before." . format ( node = node_hostname , id = member_id , uri = self . check . _config . clean_server_name , status = long_state_str , status_short = short_state_str , replset_name = replset_name , old_state = previous_short_state_str , ) ) event_payload = { 'timestamp' : int ( time . time ( ) ) , 'source_type_name' : SOURCE_TYPE_NAME , 'msg_title' : msg_title , 'msg_text' : msg , 'host' : node_hostname , 'tags' : [ 'action:mongo_replset_member_status_change' , 'member_status:' + short_state_str , 'previous_member_status:' + previous_short_state_str , 'replset:' + replset_name , ] , } if node_hostname == 'localhost' : # Do not submit events with a 'localhost' hostname. event_payload [ 'host' ] = self . hostname self . check . event ( event_payload )