for line in mdadm_lines:
        if 'check' in line:
            mdraid_check = line.split()[3][:-1]
        elif 'sync' in line:
            mdraid_sync = line.split()[3][:-1]
        elif 'recover' in line:
            mdraid_recover = line.split()[3][:-1]

    # Before return, close the client
    client.close()

    return mdraid_healthy, mdraid_recover, mdraid_check, mdraid_sync

###############################################################################

parser = schecks.get_parser()

if __name__ == '__main__':
    # Ok first job : parse args
    opts, args = parser.parse_args()
    
    # Ok now got an object that link to our destination
    client = schecks.get_client(opts)
    
    # Scrape /proc/mdstat and get result and perf data
    healthy, recover, scrub, sync = get_raid_status(client)
    # Format perf data
    perf = "|Recover={0}%;0%;100% Scrub={1}%;0%;100% Sync={2}%;0%;100%".format(recover, scrub, sync)

    if not float(recover) == 100:
        print("WARNING: RAID is recovering " + perf)
Beispiel #2
0
        # By pass the firt line, we already know about it
        _, _, device, nb_reads, _, nb_sec_read, _, nb_writes, _, nb_sec_write, _, _, io_time, _ = tuple(
            [e for e in line.split(' ') if e])

        if not device in stats:
            stats[device] = []
        stats[device].append((int(nb_reads), int(nb_sec_read), int(nb_writes),
                              int(nb_sec_write), int(io_time)))

    # Before return, close the client
    client.close()

    return diff, stats


parser = schecks.get_parser()

if __name__ == '__main__':
    # Ok first job : parse args
    opts, args = parser.parse_args()

    # Ok now got an object that link to our destination
    client = schecks.get_client(opts)

    # Do the job
    diff, stats = get_disks_stats(client)

    # Maybe we failed at getting data
    if not stats:
        print "Error : cannot fetch disk stats values from host"
        sys.exit(2)