email_notification¶
email_notification.main¶
-
email_notification.main.checkhealth_send_email(server_logfile, email_logfile, healthcheck_url, config)[source]¶ Check the health and send the log file as error message if server is down
- Args:
- server_logfile:
str - path of file where log of server is stored
- email_logfile:
str - path of file where log of this email is stored
- healthcheck_url:
str - url for health checkhealth
- config:
dict dict of config file
{ "TO":"example@gmail.com", "FROM":"example@gmail.com", "SMTP_SERVER":"smtp.gmail.com", # for gmail "PORT":"587", "PASSWORD": "password" }
- server_logfile:
- Return:
- send email if server is down and email is not already send
-
email_notification.main.healthcheck(url)[source]¶ check the health of server
- Args:
- url:
str - url of healthcheck endpoint
- url:
- Return:
- if live True else False
-
email_notification.main.send_email(error_msd, filename, config)[source]¶ send email with error message from log file
- Args:
- error_msg:
list - Error message, each sentence as list
- filename:
str - filename of log file
- config:
dict dict of config file
{ "TO":"example@gmail.com", "FROM":"example@gmail.com", "SMTP_SERVER":"smtp.gmail.com", # for gmail "PORT":"587", "PASSWORD": "password" }
- error_msg:
- Return:
- True if success else log error message
- Raise:
socket.errorif error while sending message.