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.GetNodes(hostname)[0]
40 print "UNKNOWN: API failure"
44 t1 = n['last_contact']
48 #print n['boot_state'], n['run_level'], t1, t2, t2-t1
51 if n['boot_state'] == n['run_level']:
52 print "OK: bootstate matches runlevel and lastcontact is up to date"
55 print "WARNING: bootstate does not match runlevel"
58 print "CRITICAL: node last_contact is stale, assumed offline"
62 if __name__ == '__main__':
63 f = open("/tmp/checkmode", 'a')
64 f.write("checkmode %s %s\n" % (time.time(), " ".join(sys.argv[1:])))