-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdomain.py
More file actions
34 lines (25 loc) · 1.25 KB
/
domain.py
File metadata and controls
34 lines (25 loc) · 1.25 KB
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
import os
import smtplib
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText
import datetime
hostname = ['5gautomatika.com','5genergy.ca','5genergy.org','5gindia.com','5gindia.in','drgsundaram.com','ec4energy.co.uk','ec4energy.com','enterprise-gateway.com','fifthgentech.com','itsme.org.in','payit.5genergy.ca','payit.5gindia.com','staging.5gindia.com','support.5gindia.com']
now=datetime.datetime.now()
#and then check the response...
for nw in hostname:
response = os.system("ping -c 6 " + nw)
if response != 0:
msg = MIMEMultipart()
msg['From'] = fromaddr
msg['To'] = recipients
msg['Subject'] = "DOMAIN DOWN"
body = "%r IS DOWN AT" % nw + " " + now.strftime("%Y-%m-%d %H:%M")
msg.attach(MIMEText(body, 'plain'))
server = smtplib.SMTP('smtp.gmail.com', 587)
server.starttls()
server.login(fromaddr, "Amma@1994")
text = msg.as_string()
server.sendmail(fromaddr, recipients.split(','), text)
server.quit()