-
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathweb.py
46 lines (32 loc) · 994 Bytes
/
web.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
"""
author: @endormi
Automated website monitoring for exceptions
if there is an exception it sends an email and plays a sound (remember to turn down your volume)
"""
import requests
from playsound import playsound
import smtplib
url = ''
PORT = 587
Your_Email = 'example@company.com'
"""
Get your password from:
https://myaccount.google.com/apppasswords
"""
Your_Password = 'password'
req = requests.get(url, timeout=1)
req.raise_for_status()
while True:
if req.status_code != 200:
with smtplib.SMTP('smtp.gmail.com', PORT) as send__mail:
send__mail.starttls()
send__mail.login(Your_Email, Your_Password)
sub = 'Your site is down!'
body = 'Restart the server and make sure it is running.'
message = f'Subject: {sub} \n\n {body}'
send__mail.sendmail(Your_Email, Your_Email, message)
print("Email sent!")
playsound('volume_warning.wav')
break
else:
continue