7 from monitor.wrapper import plc
9 def argv_to_dict(argv):
11 NOTE: very bare-bones, no error checking, will fail easily.
25 d = argv_to_dict(sys.argv[1:])
28 if 'hostname' in d or 'H' in d:
34 print "UNKNOWN: Argument error"
38 n = api.RebootNodeWithPCU(hostname, True)
40 if "No PCUs associated with Node" in str(e):
41 print "CRITICAL: Failure: %s" % str(e)
44 print "UNKNOWN: Failure: %s" % str(e)
51 pcu_id = api.GetNodes(hostname)[0]['pcu_ids'][0]
52 pcu = api.GetPCUs({'pcu_id' : pcu_id})[0]
54 print "UNKNOWN: API Error: %s" % str(e)
58 print "%s: PCU test successful" % pcu['model']
61 print "%s: PCU test failure: %s" % (pcu['model'], n)
64 print "FAKE-CRITICAL: PCU test failed"
68 if __name__ == '__main__':
69 f = open("/tmp/checkpcu", 'a')
70 f.write("checkpcu %s %s\n" % (time.time(), " ".join(sys.argv[1:])))