-
Notifications
You must be signed in to change notification settings - Fork 0
/
checkNplus1.py
28 lines (26 loc) · 985 Bytes
/
checkNplus1.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
#!/usr/bin/env python3
import os, smtplib, ssl
hostname = "192.168.60.5"
response = os.system("ping -c 1 " + hostname)
if response == 0:
message = "Subject: NPLUS1 Server " + hostname + " ist erreichbar!"
port = 587
password = "ICT_81ct"
sender_email = "[email protected]"
receiver_email = "[email protected]"
context = ssl.SSLContext(ssl.PROTOCOL_TLS)
connection = smtplib.SMTP("82.195.237.188", port)
connection.starttls(context=context)
connection.login("[email protected]", password)
connection.sendmail(sender_email, receiver_email, message)
else:
message = "Subject: NPLUS1 Server " + hostname + " ist nicht erreichbar!"
port = 587
password = "ICT_81ct"
sender_email = "[email protected]"
receiver_email = "[email protected]"
context = ssl.SSLContext(ssl.PROTOCOL_TLS)
connection = smtplib.SMTP("82.195.237.188", port)
connection.starttls(context=context)
connection.login("[email protected]", password)
connection.sendmail(sender_email, receiver_email, message)