зеркало из https://github.com/mozilla/stoneridge.git
Add dns check process
This lets us make sure we won't run tests if the DNS failed to update. This will be much better than having giant spikes in the graphs when things go wonky. Also, this will email me, so I won't have to check the graphs every day to see if something broke on the DNS side of things.
This commit is contained in:
Родитель
a24ddaf4b4
Коммит
c20913a119
|
@ -0,0 +1,53 @@
|
|||
#!/usr/bin/env python
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public License,
|
||||
# v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
# obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
import logging
|
||||
import socket
|
||||
import sys
|
||||
|
||||
import stoneridge
|
||||
|
||||
|
||||
def send_email():
|
||||
myos = stoneridge.get_config('machine', 'os')
|
||||
netconfig = stoneridge.get_config('run', 'netconfig')
|
||||
srid = stoneridge.get_config('run', 'srid')
|
||||
|
||||
to = 'hurley@mozilla.com'
|
||||
subject = 'DNS Update Failed'
|
||||
msg = '''The DNS Update failed for the following run:
|
||||
OS: %s
|
||||
Netconfig: %s
|
||||
SRID: %s
|
||||
''' % (myos, netconfig, srid)
|
||||
|
||||
stoneridge.sendmail(to, subject, msg)
|
||||
|
||||
|
||||
@stoneridge.main
|
||||
def main():
|
||||
parser = stoneridge.ArgumentParser()
|
||||
parser.parse_args()
|
||||
|
||||
logging.debug('Checking dns for example.com')
|
||||
try:
|
||||
ip = socket.gethostbyname('example.com')
|
||||
except:
|
||||
logging.exception('Error retrieving IP')
|
||||
send_email()
|
||||
sys.exit(1)
|
||||
|
||||
logging.debug('ip = %s' % (ip,))
|
||||
|
||||
bits = ip.split('.')
|
||||
if bits[0] != '172':
|
||||
logging.error('IP is not in 172/8')
|
||||
send_email()
|
||||
sys.exit(1)
|
||||
|
||||
if not (16 <= int(bits[1]) <= 31):
|
||||
logging.error('IP is not in 172.16/12')
|
||||
send_email()
|
||||
sys.exit(1)
|
|
@ -192,6 +192,8 @@ class StoneRidgeWorker(stoneridge.QueueListener):
|
|||
|
||||
self.run_process('dnsupdater')
|
||||
|
||||
self.run_process('dnscheck')
|
||||
|
||||
self.need_dns_reset = True
|
||||
|
||||
self.run_process('runner')
|
||||
|
|
Загрузка…
Ссылка в новой задаче