From cff9512d311516e7f79465ce4552eec673ca2636 Mon Sep 17 00:00:00 2001 From: Anmol Nagpal Date: Tue, 28 Jul 2020 17:22:06 +0530 Subject: [PATCH] update script --- monitor/src/index.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/monitor/src/index.py b/monitor/src/index.py index 317679c..33923f4 100644 --- a/monitor/src/index.py +++ b/monitor/src/index.py @@ -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']) @@ -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() \ No newline at end of file + print("Done!") \ No newline at end of file