def extract_valid_cpu_usage_data(program_to_check_cpu_usage, poll_interval):
    '\n    This method it to extract the valid cpu usage data according to the poll_interval\n    1. Find the index for the max one for every poll interval,\n    2. Discard the data if the index is on the edge(0 o the length of program_to_check_cpu_usage -1)\n    3. If the index is closed in the neighbour interval, only keep the former one\n    4. Return all indexes\n    For example:\n    poll_interval = 10\n    7, 1, 0, 1, 0, 1, 5, 1, 1,2, 0, 1, 0, 1, 0, 6, 1, 1, 1,2\n    return [15]\n    0, 1, 0, 1, 0, 1, 0, 1, 0, 8, 7, 1, 0, 1, 0, 6, 1, 1, 1,2\n    return [9]\n    '
    valid_cpu_usage_center_index_list = []
    poll_number = (len(program_to_check_cpu_usage) // poll_interval)

    def find_max_cpu_usage(cpu_usage_list, poll_times):
        max_cpu_usage = cpu_usage_list[0]
        max_cpu_usage_index = 0
        for (i, cpu_usage) in enumerate(cpu_usage_list):
            if (cpu_usage > max_cpu_usage):
                max_cpu_usage = cpu_usage
                max_cpu_usage_index = i
        return [max_cpu_usage, (max_cpu_usage_index + (poll_times * poll_interval))]
    for i in range(0, poll_number):
        (max_cpu_usage, max_cpu_usage_index) = find_max_cpu_usage(program_to_check_cpu_usage[(poll_interval * i):(poll_interval * (i + 1))], i)
        if ((max_cpu_usage_index == 0) or (max_cpu_usage_index == (len(program_to_check_cpu_usage) - 1))):
            logging.info('The data is on the edge:{}, discard it '.format(max_cpu_usage_index))
        else:
            if (valid_cpu_usage_center_index_list and ((valid_cpu_usage_center_index_list[(- 1)] + 1) == max_cpu_usage_index)):
                continue
            valid_cpu_usage_center_index_list.append(max_cpu_usage_index)
    return valid_cpu_usage_center_index_list
This method it to extract the valid cpu usage data according to the poll_interval
1. Find the index for the max one for every poll interval,
2. Discard the data if the index is on the edge(0 o the length of program_to_check_cpu_usage -1)
3. If the index is closed in the neighbour interval, only keep the former one
4. Return all indexes
For example:
poll_interval = 10
7, 1, 0, 1, 0, 1, 5, 1, 1,2, 0, 1, 0, 1, 0, 6, 1, 1, 1,2
return [15]
0, 1, 0, 1, 0, 1, 0, 1, 0, 8, 7, 1, 0, 1, 0, 6, 1, 1, 1,2
return [9]
def extract_valid_cpu_usage_data(program_to_check_cpu_usage, poll_interval):
    '\n    This method it to extract the valid cpu usage data according to the poll_interval\n    1. Find the index for the max one for every poll interval,\n    2. Discard the data if the index is on the edge(0 o the length of program_to_check_cpu_usage -1)\n    3. If the index is closed in the neighbour interval, only keep the former one\n    4. Return all indexes\n    For example:\n    poll_interval = 10\n    7, 1, 0, 1, 0, 1, 5, 1, 1,2, 0, 1, 0, 1, 0, 6, 1, 1, 1,2\n    return [15]\n    0, 1, 0, 1, 0, 1, 0, 1, 0, 8, 7, 1, 0, 1, 0, 6, 1, 1, 1,2\n    return [9]\n    '
    valid_cpu_usage_center_index_list = []
    poll_number = (len(program_to_check_cpu_usage) // poll_interval)

    def find_max_cpu_usage(cpu_usage_list, poll_times):
        max_cpu_usage = cpu_usage_list[0]
        max_cpu_usage_index = 0
        for (i, cpu_usage) in enumerate(cpu_usage_list):
            if (cpu_usage > max_cpu_usage):
                max_cpu_usage = cpu_usage
                max_cpu_usage_index = i
        return [max_cpu_usage, (max_cpu_usage_index + (poll_times * poll_interval))]
    for i in range(0, poll_number):
        (max_cpu_usage, max_cpu_usage_index) = find_max_cpu_usage(program_to_check_cpu_usage[(poll_interval * i):(poll_interval * (i + 1))], i)
        if ((max_cpu_usage_index == 0) or (max_cpu_usage_index == (len(program_to_check_cpu_usage) - 1))):
            logging.info('The data is on the edge:{}, discard it '.format(max_cpu_usage_index))
        else:
            if (valid_cpu_usage_center_index_list and ((valid_cpu_usage_center_index_list[(- 1)] + 1) == max_cpu_usage_index)):
                continue
            valid_cpu_usage_center_index_list.append(max_cpu_usage_index)
    return valid_cpu_usage_center_index_list