Skip to content

Commit

Permalink
Issue #92: Update monitoring with notitication throttling
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanpadams authored and aywaldron committed Dec 4, 2018
1 parent ab6dc11 commit f9066bf
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions ait/gui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,9 @@ def telem_handler(session):

log.info('Starting telemetry limit monitoring')
try:
limit_trip_repeat = 0
prev_v = None
prev_defn = None
while True:
if len(session.telemetry) > 0:
p = session.telemetry.popleft()
Expand All @@ -407,11 +410,28 @@ def telem_handler(session):
if defn.error(v):
msg = 'Field {} error out of limit with value {}'.format(field, v)
log.error(msg)
notify.trigger_notification('limit-error', msg)

if limit_trip_repeat < 30 and v == prev_v and defn == prev_defn:
limit_trip_repeat += 1
else:
limit_trip_repeat = 0
notify.trigger_notification('limit-error', msg)

prev_v = v
prev_defn = defn

elif defn.warn(v):
msg = 'Field {} warning out of limit with value {}'.format(field, v)
log.warn(msg)
notify.trigger_notification('limit-warn', msg)

if limit_trip_repeat < 30 and v == prev_v and defn == prev_defn:
limit_trip_repeat += 1
else:
limit_trip_repeat = 0
notify.trigger_notification('limit-warn', msg)

prev_v = v
prev_defn = defn

gevent.sleep(0)
finally:
Expand Down

0 comments on commit f9066bf

Please sign in to comment.