human
Complete this python program:
def collectInnodbStatus(db):
assistant
#Here is the Python code you requested.

    """Collects and prints InnoDB stats about the given DB instance.
    """
    ts = now()
    def printmetric(metric, value, tags=''):
        print ('mysql.%s    %d    %s    schema=%s%s' % (metric, ts, value, db.dbname, tags))
    innodb_status = db.query('SHOW    ENGINE    INNODB    STATUS')[0][2]
    m = re.search('^(\\d{6}\\s+\\d{1,2}:\\d\\d:\\d\\d)    INNODB    MONITOR    OUTPUT$', innodb_status, re.M)
    if m:
        ts = int(time.mktime(time.strptime(m.group(1), '%y%m%d    %H:%M:%S')))
    line = None
    def match(regexp):
        return re.match(regexp, line)
    for line in innodb_status.split('\n'):
        m = match('OS    WAIT    ARRAY    INFO:    reservation    count    (\\d+),    signal    count    (\\d+)')
        if m:
            printmetric('innodb.oswait_array.reservation_count', m.group(1))
            printmetric('innodb.oswait_array.signal_count', m.group(2))
            continue
        m = match('Mutex    spin    waits    (\\d+),    rounds    (\\d+),    OS    waits    (\\d+)')
        if m:
            printmetric('innodb.locks.spin_waits', m.group(1), '    type=mutex')
            printmetric('innodb.locks.rounds', m.group(2), '    type=mutex')
            printmetric('innodb.locks.os_waits', m.group(3), '    type=mutex')
            continue
        m = match('RW-shared    spins    (\\d+),    OS    waits    (\\d+);    RW-excl    spins    (\\d+),    OS    waits    (\\d+)')
        if m:
            printmetric('innodb.locks.spin_waits', m.group(1), '    type=rw-shared')
            printmetric('innodb.locks.os_waits', m.group(2), '    type=rw-shared')
            printmetric('innodb.locks.spin_waits', m.group(3), '    type=rw-exclusive')
            printmetric('innodb.locks.os_waits', m.group(4), '    type=rw-exclusive')
            continue
        m = match('RW-shared    spins    (\\d+),    rounds    (\\d+),    OS    waits    (\\d+)')
        if m:
            printmetric('locks.spin_waits', m.group(1), '    type=rw-shared')
            printmetric('locks.rounds', m.group(2), '    type=rw-shared')
            printmetric('locks.os_waits', m.group(3), '...