'Parses mpstat output of the following two forms:
02:10:17     0    0.00    0.00    0.00    0.00    0.00    0.00           0.00  100.00   1012.87
02:10:13 PM    0    0.00    0.00    0.00    0.00    0.00    0.00         0.00  100.00   1019.00'

def process_mpstat(self, mpstat_out, sample_count, loud=True):

    mpstat_keys = ['time', 'CPU', 'user', 'nice', 'sys', 'iowait', 'irq', 'soft', 'steal', 'idle', 'intr/s']
    if loud:
        print mpstat_out
    mpstat_out = mpstat_out.replace('AM', '')
    mpstat_out = mpstat_out.replace('PM', '')
    regex = re.compile('(\\S+)')
    stats = []
    for line in mpstat_out.splitlines()[3:]:
        match = regex.findall(line)
        if (match and (match[0] != 'Average:') and (match[1] == 'all')):
            stats.append(dict(zip(mpstat_keys, match)))
    if (sample_count >= 5):
        stats = stats[1:(-1)]
    cpu_stats = {}
    for key in ['user', 'nice', 'sys', 'iowait', 'irq', 'soft', 'steal', 'idle', 'intr/s']:
        x = [float(row[key]) for row in stats]
        if len(x):
            count = len(x)
        else:
            print 'net_utils.network_utils.process_mpstat:    count    is    0!!!\n'
            count = 1
        cpu_stats[key] = (sum(x) / count)
    return cpu_stats
