Skip to content

Commit

Permalink
update lambda script
Browse files Browse the repository at this point in the history
  • Loading branch information
anmolnagpal committed Jul 3, 2020
1 parent dfda753 commit 8166afd
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions monitor/src/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

website_url = json.loads(os.environ['Website_URL'])
metricname = os.environ['metricname']
timeout = int(os.environ['timeout'])

def write_metric(value, metric, site):
print(value)
Expand Down Expand Up @@ -37,7 +38,7 @@ def check_site(url, metric):
request = urllib2.Request(url)

try:
response = urllib2.urlopen(request)
response = urllib2.urlopen(request, timeout=timeout)
response.close()
except urllib2.URLError as e:
if hasattr(e, 'code'):
Expand Down Expand Up @@ -74,7 +75,7 @@ def handler(event, context):

for site in websiteurls:
r = check_site(site,metricname)
if r == 200 or r == 304 or r == 304:
if r == 200 or r == 304 or r == 400:
print("Site %s is up" %site)
write_metric(200, metricname, site)
else:
Expand Down

0 comments on commit 8166afd

Please sign in to comment.