Skip to content

Add Watchdog verbose logging#4299

Merged
andryyy merged 3 commits intostagingfrom
watchdog-verbose
Oct 29, 2021
Merged

Add Watchdog verbose logging#4299
andryyy merged 3 commits intostagingfrom
watchdog-verbose

Conversation

@MAGICCC
Copy link
Copy Markdown
Member

@MAGICCC MAGICCC commented Oct 26, 2021

Adding the possibility to see verbose logs while sending mails via Watchdog
May fix #4298 + #4197

PS: Needs a new watchdog image then
PPS: Needs more testing - only tested it quickly. @andryyy maybe you have some time for this

@MAGICCC MAGICCC requested a review from andryyy October 26, 2021 23:16
@MAGICCC MAGICCC changed the title [WIP] Add Watchdog verbose loggin Add Watchdog verbose loggin Oct 26, 2021
--ipv4
#--server="${RCPT_MX}"
log_msg "Sent notification email to ${rcpt}"
if [[ $? -eq 1 ]]; then # exit code 1 is fine
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good in my test, but why? Did you find an issue regarding this? Is it normal?

Copy link
Copy Markdown
Member Author

@MAGICCC MAGICCC Oct 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it. I found mludvig/smtp-cli#17 and seems exitcode is 1 when everything is fine...

@andryyy
Copy link
Copy Markdown
Contributor

andryyy commented Oct 27, 2021

Nice. :) Let me know when you can merge. I will build the image then first.

@MAGICCC
Copy link
Copy Markdown
Member Author

MAGICCC commented Oct 27, 2021

I just tested a bit and looks fine on my side, but I noticed when you set a mail with a bad domain (no mx record), then no mail will be sent.
Maybe we can reuse this:

RCPT_DOMAIN=$(echo ${rcpt} | awk -F @ {'print $NF'})
# Latest smtp-cli looks up mx via dns
#RCPT_MX=$(dig +short ${RCPT_DOMAIN} mx | sort -n | awk '{print $2; exit}')
#if [[ -z ${RCPT_MX} ]]; then
# log_msg "Cannot determine MX for ${rcpt}, skipping email notification..."
# return 1
#fi

like this:

RCPT_DOMAIN=$(echo ${rcpt} | awk -F @ {'print $NF'})
CHECK_FOR_VALID_MX=$(dig +short ${RCPT_DOMAIN} mx | sort -n | awk '{print $2; exit}')
if [[ -z ${CHECK_FOR_VALID_MX} ]]; then
  log_msg "Cannot determine MX for ${rcpt}, skipping email notification..."
  return 1
fi

@MAGICCC MAGICCC changed the title Add Watchdog verbose loggin Add Watchdog verbose logging Oct 27, 2021
@andryyy
Copy link
Copy Markdown
Contributor

andryyy commented Oct 28, 2021

CHECK_FOR_VALID_MX=$(dig +short ${RCPT_DOMAIN} mx) would be enough. :)

Can you adjust the PR?

@MAGICCC MAGICCC marked this pull request as ready for review October 29, 2021 04:13
@andryyy
Copy link
Copy Markdown
Contributor

andryyy commented Oct 29, 2021

Thank youuu

@andryyy
Copy link
Copy Markdown
Contributor

andryyy commented Oct 29, 2021

We should probably add the variable information to the docs.

@andryyy andryyy merged commit 6bf70cf into staging Oct 29, 2021
@andryyy andryyy deleted the watchdog-verbose branch October 29, 2021 04:48
@dragoangel
Copy link
Copy Markdown
Collaborator

Wow, nice :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants