Example #1
0
    def check(self, data_node_info_list):
        zkOper = Scheduler_ZkOpers()
        started_nodes_list = zkOper.retrieve_started_nodes()

        error_record = {}
        ip = []
        for data_node_ip in started_nodes_list:
            ip.append(data_node_ip)

        error_record.setdefault("online_ip", ip)
        total_count = len(data_node_info_list)
        success_count = len(started_nodes_list)
        failed_count = total_count - success_count
        monitor_type = "node"
        monitor_key = "started"
        alarm_level = self.retrieve_alarm_level(total_count, success_count,
                                                failed_count)

        super(Check_Node_Active,
              self).write_status(total_count, success_count, failed_count,
                                 alarm_level, error_record, monitor_type,
                                 monitor_key)
        super(Check_Node_Active,
              self).write_status_to_es(total_count, success_count,
                                       failed_count, alarm_level, error_record,
                                       monitor_type, monitor_key)
Example #2
0
    def _check_cluster_status(self, zk_data_node_count):
        zkOper = Scheduler_ZkOpers()
        pre_stat = zkOper.retrieveClusterStatus()
        ''' The following logic expression means
            1. if we don't have the cluster_status node in zookeeper we will
               get pre_stat as {}, we will create the path in the following
               process.
            2. else the pre_stat is not {}, then it must have value in pre_stat
               dictionary and judge whether it is right or not.
        '''
        if pre_stat.has_key('_status') and pre_stat[
                '_status'] != 'initializing' or pre_stat == {}:
            online_node_list = zkOper.retrieve_started_nodes()
            result = {}

            online_num = len(online_node_list)
            if zk_data_node_count == online_num:
                result['_status'] = 'running'
            elif zk_data_node_count / 2 + 1 <= online_num < zk_data_node_count:
                result['_status'] = 'sub-health'
            else:
                result['_status'] = 'failed'
            zkOper.writeClusterStatus(result)