Created
May 23, 2018 11:16
-
-
Save an0th3rhuman/28c9ce64b8a6bfd5ac48bde00963589b to your computer and use it in GitHub Desktop.
This will check if the server is up.. or else it will mail stating server is down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import smtplib | |
import pyping | |
error_msg = "Server is down!" | |
Server_ping = pyping.ping('google.com') | |
if Server_ping.ret_code == 0: | |
print("Server is up!") | |
else: | |
mail=smtplib.SMTP('smtp.gmail.com',587) | |
mail.ehlo() | |
mail.starttls() | |
mail.login('','') | |
mail.sendmail('[email protected]','[email protected]',error_msg) | |
mail.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment