'Parse the output from the \'stat\' 4letter word command'

def _parse_stat(self, data):

    result = {}
    if (not data):
        return result
    h = StringIO(data)
    version = h.readline()
    if version:
        result['zk_version'] = version[(version.index(':') + 1):].strip()
    while h.readline().strip():
        pass
    for line in h.readlines():
        m = re.match('Latency    min/avg/max:    (\\d+)/(\\d+)/(\\d+)', line)
        if (m is not None):
            result['zk_min_latency'] = int(m.group(1))
            result['zk_avg_latency'] = int(m.group(2))
            result['zk_max_latency'] = int(m.group(3))
            continue
        m = re.match('Received:    (\\d+)', line)
        if (m is not None):
            result['zk_packets_received'] = int(m.group(1))
            continue
        m = re.match('Sent:    (\\d+)', line)
        if (m is not None):
            result['zk_packets_sent'] = int(m.group(1))
            continue
        m = re.match('Outstanding:    (\\d+)', line)
        if (m is not None):
            result['zk_outstanding_requests'] = int(m.group(1))
            continue
        m = re.match('Mode:    (.*)', line)
        if (m is not None):
            result['zk_server_state'] = m.group(1)
            continue
        m = re.match('Node    count:    (\\d+)', line)
        if (m is not None):
            result['zk_znode_count'] = int(m.group(1))
            continue
    return result
