Commit 352d5de7 authored by Damian Johnson's avatar Damian Johnson
Browse files

Shorten and summarize fallback directory irc notifications

Adjusting the irc notifications per teor's request...

  https://trac.torproject.org/projects/tor/ticket/30940

In particiular notifications now begin with a count summary (like emails), and
present at most four relays. For example...

  [fallback-directories] 157/157 (100%) fallback directories have become slow or unresponsive...
  [fallback-directories] 8FA37B93397015B2BC5A525C908485260BE9F422 => ORPort is unreachable (81.7.11.96:9001)
  [fallback-directories] 36B9E7AC1E36B62A9D6F330ABEB6012BA7F0D400 => ORPort is unreachable (37.187.22.87:9001)
  [fallback-directories] 230A8B2A8BA861210D9B4BA97745AEC217A94207 => ORPort is unreachable (163.172.176.167:443)
  [fallback-directories] 823AA81E277F366505545522CEDC2F529CE4DC3F => ORPort is unreachable (192.160.102.164:9001)
  [fallback-directories] ... and 153 more
parent 9db725cb
......@@ -19,11 +19,7 @@ log = util.get_logger('fallback_directories')
NOTIFICATION_THRESHOLD = 25 # send notice if this percentage of fallbacks are unusable
TO_ADDRESSES = ['tor-consensus-health@lists.torproject.org', 'teor@torproject.org', 'nickm@torproject.org', 'gus@torproject.org']
EMAIL_SUBJECT = 'Fallback Directory Summary (%i/%i, %i%%)'
EMAIL_BODY = """\
%i/%i (%i%%) fallback directories have become slow or unresponsive...
"""
SYNOPSIS = '%i/%i (%i%%) fallback directories have become slow or unresponsive...'
downloader = stem.descriptor.remote.DescriptorDownloader(timeout = 30)
......@@ -70,14 +66,24 @@ def main():
if issue_percent >= NOTIFICATION_THRESHOLD:
log.info('Sending notification')
synopsis = SYNOPSIS % (len(issues), len(fallback_directories), issue_percent)
subject = EMAIL_SUBJECT % (len(issues), len(fallback_directories), issue_percent)
body = EMAIL_BODY % (len(issues), len(fallback_directories), issue_percent)
util.send(subject, body = body + '\n'.join([' * %s' % issue for issue in issues]), to = TO_ADDRESSES)
email_body = synopsis + '\n\n' + '\n'.join([' * %s' % issue for issue in issues])
util.send(subject, body = email_body, to = TO_ADDRESSES)
# notification for #tor-bots
body = '\n'.join(['[fallback-directories] %s' % issue for issue in issues])
irc_lines = [synopsis]
for i, issue in enumerate(issues):
if i < 4:
irc_lines.append(issue)
else:
irc_lines.append('... and %i more' % (len(issues) - i))
break
irc_body = '\n'.join(['[fallback-directories] %s' % line for line in irc_lines])
util.send('Announce or', body = body, to = ['tor-misc@commit.noreply.org'])
......
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