Skip to content

Commit

Permalink
update script
Browse files Browse the repository at this point in the history
  • Loading branch information
anmolnagpal committed Jul 28, 2020
1 parent 3f7b7af commit cff9512
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions monitor/src/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import json
import threading
import requests
import time
from requests.exceptions import HTTPError

website_url = json.loads(os.environ['Website_URL'])
Expand Down Expand Up @@ -67,18 +68,20 @@ def run_thread(site):
print("[Error:] Site %s down" %site)
write_metric(int(r), metricname, site)

def handler():
def handler(event, context):

# Change these to your actual websites. Remember, the more websites you list
# the longer the lambda function will run
websiteurls = website_url
t = [0]*len(website_url)
j = 1
for i in range(len(websiteurls)):
t[i] = threading.Thread(target=run_thread, args=(website_url[i],))
if j == 6:
time.sleep(5)
t[i].start()
j = j+1

for i in range(len(t)):
t[i].join()
print("Done!")

handler()
print("Done!")

0 comments on commit cff9512

Please sign in to comment.