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