Skip to content

Commit

Permalink
Merge pull request #145 from thalesgroup-cert/test
Browse files Browse the repository at this point in the history
Correct bug email ticket_id
  • Loading branch information
Felix83000 authored Jul 26, 2024
2 parents b6d4a93 + 29d4ed6 commit b077289
Show file tree
Hide file tree
Showing 2 changed files with 514 additions and 352 deletions.
9 changes: 4 additions & 5 deletions Watcher/Watcher/site_monitoring/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ def create_alert(alert, site, new_ip, new_ip_second, score):
time.sleep(random.uniform(1, 3))

# Send an email for the alert
send_email(alert_data['type'] + " on " + site.domain_name, site.rtir, new_alert.pk)
send_email(alert_data['type'] + " on " + site.domain_name, site.ticket_id, new_alert.pk)

# Manage MX records for mail changes
if 'Mail' in alert_data['type']:
Expand Down Expand Up @@ -417,13 +417,13 @@ def create_alert(alert, site, new_ip, new_ip_second, score):
mail_A_record_ip=site.mail_A_record_ip,
mail_A_record_ip_second=site.mail_A_record_ip_second)

def send_email(message, rtir, alert_id):
def send_email(message, ticket_id, alert_id):
"""
Send Email alert.
:param alert_id: Alert ID.
:param message: Subject email end message.
:param rtir: Identification number of RTIR.
:param ticket_id: Identification number for the case managment software.
:return:
"""
emails_to = list()
Expand All @@ -433,12 +433,11 @@ def send_email(message, rtir, alert_id):

# If there is at least one subscriber
if len(emails_to) > 0:
# RTIR Ticket
try:
msg = MIMEMultipart()
msg['From'] = settings.EMAIL_FROM
msg['To'] = ','.join(emails_to)
msg['Subject'] = "[" + settings.EMAIL_SUBJECT_TAG_SITE_MONITORING + " #" + str(rtir) + "] " + message
msg['Subject'] = "[" + settings.EMAIL_SUBJECT_TAG_SITE_MONITORING + " #" + str(ticket_id) + "] " + message
body = message
body += u"""\
Alert ID: """ + str(alert_id)
Expand Down
Loading

0 comments on commit b077289

Please sign in to comment.