Commit a211965d authored by kpetersn's avatar kpetersn
Browse files

Modified an.py to use new XML elements (status and duration) rather than the old timers

parent de58b952
......@@ -120,10 +120,10 @@ for ioc in root.iter('IOC'):
#print ET.tostring(ioc)
for elem in ioc:
if elem.tag == 'ping_timer':
ping_timer = int(elem.text)
if elem.tag == 'boot_timer':
boot_timer = int(elem.text)
if elem.tag == 'status':
status = elem.text.upper()
if elem.tag == 'duration':
duration = int(elem.text)
if elem.tag == 'env':
if elem.attrib['name'] == 'ENGINEER':
if elem.text == engineer:
......@@ -137,14 +137,23 @@ for ioc in root.iter('IOC'):
#!print "engineer =", engineer
#!print
if ( ping_timer > hb_period ) and ( ping_timer <= (hb_period + period) ):
# ioc went down since last poll
ioc_list[name] = 'DOWN'
elif boot_timer <= period:
# ioc booted since last poll
ioc_list[name] = 'UP'
if status == "UP":
if duration <= period:
#!print status, "-- UP expected"
ioc_list[name] = 'UP'
else:
#!print status, "-- (UP for too long)"
pass
elif status == "DOWN":
if duration > period and duration <= (2 * period):
#!print status, "-- DOWN expected"
ioc_list[name] = 'DOWN'
else:
#!print status, "-- (DOWN for too long)"
pass
else:
# ioc's state is old, no notification necessary
# Don't send notification
#!print status, "-- OTHER STATE"
pass
iocs = ioc_list.keys()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment