#!/local/bin/python2.3 #!/usr/bin/env python import sys, os import metaparse # Sole command line argument is the fileset to work on, or empty to # look at the default one. def process(args): if args: fset="-s %s" % args[0] else: fset="" fp = os.popen("/usr/sbin/metastat %s" % fset, "r") t = fp.read() pr = metaparse.parse(t) damaged = [] limping = [] for m in pr: if m.all_okay(): pass elif m.is_running(): damaged.append(m) else: limping.append(m) for m in damaged: print "degraded:", m.dev, " ".join([x.dev for x in m.broken_subs()]) for m in limping: print "errored:", m.dev, " ".join([x.dev for x in m.broken_subs()]) #if damaged: # print "partially-degraded:", " ".join([x.dev for x in damaged]) #if limping: # print "barely-operating:", " ".join([x.dev for x in limping]) if __name__ == "__main__": process(sys.argv[1:])