Commit ae678f82 authored by kpetersn's avatar kpetersn
Browse files

Improved the up/down detection logic. Max up detection delay is the polling...

Improved the up/down detection logic. Max up detection delay is the polling period.  Max down detection delay is the polling period plus the heartbeat period.
parent 03441d6d
......@@ -15,10 +15,10 @@ import os
osx_command = "/Users/kpetersn/Applications/terminal-notifier.app/Contents/MacOS/terminal-notifier"
osx_url = "http://bcda.xray.aps.anl.gov/cgi-bin/ioc_alive.cgi?eng=Peterson"
### Stuff to customize
### Stuff to customize ###
engineer = "Peterson"
# period should match cron job period
period = 120
period = 60
def notifyConsole(ioc, state, time_str):
print "[%s] %s is %s" % (time_str, ioc, state)
......@@ -30,9 +30,10 @@ def notifyOSX(ioc, state, time_str):
# set notification function
notify = notifyOSX
#!notify = notifyConsole
###
##########################
alive_url = "http://bcda.xray.aps.anl.gov/cgi-bin/alivexml.cgi"
hb_period = 10
ioc_list = {}
# Get the xml file
......@@ -100,16 +101,15 @@ for ioc in root.iter('IOC'):
#!print "engineer =", engineer
#!print
if boot_timer <= period:
# ioc just booted
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'
elif ping_timer > period:
if ping_timer <= (2 * period):
# ioc went down since last poll
ioc_list[name] = 'DOWN'
else:
# ioc has been down for a while
pass
else:
# ioc's state is old, no notification necessary
pass
iocs = ioc_list.keys()
iocs.sort()
......
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