- d = argv_to_dict(sys.argv[1:])
-
- api = plc.api
- if 'hostname' in d or 'H' in d:
- try:
- hostname = d['host']
- except:
- hostname = d['H']
- else:
- print "UNKNOWN: argument error"
- sys.exit(3)
-
- try:
- n = api.GetNodes(hostname)[0]
- except:
- print "UNKNOWN: API failure"
- sys.exit(3)
-
- t1 = 0
- t2 = time.time()
-
- if False:
- print "FAKE-OK: PCU test successful"
- sys.exit(0)
- elif False:
- print "FAKE-WARNING: PCU configuration incomplete"
- sys.exit(1)
- else:
- print "FAKE-CRITICAL: PCU test failed"
- sys.exit(2)
+ d = argv_to_dict(sys.argv[1:])
+
+ api = plc.api
+ if 'hostname' in d or 'H' in d:
+ try:
+ hostname = d['host']
+ except:
+ hostname = d['H']
+ else:
+ print "UNKNOWN: Argument error"
+ sys.exit(3)
+
+ try:
+ n = api.RebootNodeWithPCU(hostname, True)
+ except Exception, e:
+ if "No PCUs associated with Node" in str(e):
+ print "CRITICAL: Failure: %s" % str(e)
+ sys.exit(2)
+ else:
+ print "UNKNOWN: Failure: %s" % str(e)
+ sys.exit(3)
+
+ t1 = 0
+ t2 = time.time()
+
+ if n == 0:
+ print "OK: PCU test successful"
+ sys.exit(0)
+ elif n != 0:
+ print "WARNING: PCU configuration incomplete: %s" % n
+ sys.exit(1)
+ else:
+ print "FAKE-CRITICAL: PCU test failed"
+ sys.exit(2)