NAUbackup / VmBackup

XenServer simple backup script
228 stars 61 forks source link

Error unable to send email notifications #32

Closed kudude703 closed 6 years ago

kudude703 commented 7 years ago

Hello,

I'm unable to receive email notifications, i receive the following error:

2016-11-22-(01:58:58) - ERROR EXCEPTION - socket.gaierror 2016-11-22-(01:58:58) - ERROR NOTE: see VmBackup output for details Traceback (most recent call last): File "/opt/isight/backup/VmBackup.py", line 1361, in ? main(session) File "/opt/isight/backup/VmBackup.py", line 447, in main send_email(MAIL_TO_ADDR, 'Success VmBackup.py', STATUS_LOG) File "/opt/isight/backup/VmBackup.py", line 789, in send_email s = smtplib.SMTP(MAIL_SMTP_SERVER) File "/usr/lib/python2.4/smtplib.py", line 258, in init addr = socket.gethostbyname(socket.gethostname()) socket.gaierror: (-2, 'Name or service not known')

DNS resolution works fine. Im using a hostname in my MAIL_SMTP_SERVER. I have Xen version 6.5.

Help please.

Thanks.

NAUbackup commented 7 years ago

How about checking your SMTP server (are you using the FQDN?) and your "from" and "to" addresses?

This is the only report we have received of this nature. Did you try running your configuration file using the "preview" option added on to see if any syntax errors show up?

kudude703 commented 7 years ago

Yes, my SMTP server is FQDN and not IP. "FROM" and "TO" are FQDN as well. I actually have this backup script on multiple Xen clusters. It seems to work on some and doesn't work on others, i get the same error. Are there mandatory RPMs that need to be installed?

kudude703 commented 7 years ago

And yes the I'ved used the preview option and it succeeded with no errors.

NAUbackup commented 7 years ago

There should be no other RPMs required, AFAIK. DNS on XenServer can be funky at times. Note that the email address used must be recognized from each server as being valid as far as the SMTP mail server is concerned. Therefore, make sure whatever email address is used can be confirmed by the mail server to be valid. I've run into this issue before and it's easy to miss. You're also right about port 465 being used sometimes (don't you love "standards"?!). Please try substituting this code in the obvious place where you see the call to smtplib.SMTP in the script and see if that works for you:

### optional use of SMTP user authentication via TLS ### If so, comment out the next line of code and uncomment/configure ### the next block of code. Note that different SMTP servers will require ### different username options, such as the plain username, the ### domain\username, etc. The "From" entry used must be a valid and ### recognized account. Some SMTP servers might use port 465. s = smtplib.SMTP(MAIL_SMTP_SERVER) #### start block #username = 'MyUsername' #password = 'MyPassword' #s = smtplib.SMTP(MAIL_SMTP_SERVER, 587) #s.ehlo() #s.starttls() #s.login(username, password) #### end block

kudude703 commented 7 years ago

Thanks for the update but I think I figured it out. My master pool node in my cluster was not set to the FQDN and was configured with the short name. I configured /etc/sysconfig/network with the FQDN and in XenCenter. I also ran 'hostname ' to set the hostname and that seemed to have fixed it.

Thanks again for the help!