We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 440331f commit 85d01b7Copy full SHA for 85d01b7
1 file changed
site_monitor.py
@@ -0,0 +1,27 @@
1
+import requests, time, smtplib
2
+from datetime import datetime
3
+
4
+SITES = [
5
+ "https://www.google.com",
6
+ "https://github.com",
7
+]
8
+CHECK_INTERVAL = 60
9
10
+def check(url):
11
+ try:
12
+ r = requests.get(url, timeout=10)
13
+ return r.status_code < 400
14
+ except Exception:
15
+ return False
16
17
+def monitor():
18
+ print(f"Monitoring {len(SITES)} sites every {CHECK_INTERVAL}s...")
19
+ while True:
20
+ for url in SITES:
21
+ status = "UP" if check(url) else "DOWN"
22
+ ts = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
23
+ print(f"[{ts}] {url}: {status}")
24
+ time.sleep(CHECK_INTERVAL)
25
26
+if __name__ == "__main__":
27
+ monitor()
0 commit comments