You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My plan is to run the dupreport.py -r /etc/dupreport -c on a nightly basis. Only problem I see with this is I am not alerted to any errors in between the -c and when I run dupreport with the -t option. Having it run daily I would just end up ignoring the email altogether.
A way to parse the error and warning is needed. Given my limited skills I am testing the following
This very poorly done hack was attempted on the 2.0.3 issue 18 branch
On line 438 I added the following to def build_email_sql_statement
# If errors found send backup warn email!
if ('collect'in options) and ((sParts['warnings'] != '' or sParts['errors'] != '')):
send_email_backup_warn( mParts['sourceComp'], mParts['destComp'], mParts['emailDate'], mParts['emailTime'], sParts['messages'], sParts['warnings'], sParts['errors'])
Then have the following code added. I am sure you can clean this up better than me if you decide to add something like this.
def send_email_backup_warn(source, destination, lastDate, lastTime, messages, warning, error):
write_log_entry(2, 'Send_email()')
msgText=''
msgHtml='<html><head></head><body><table border={} cellpadding="{}">'.format(options['border'], options['padding'])
msgHtml = msgHtml + '<tr>' # New table row
msgText = msgText + '{}@{}\n'.format(source,destination)
msgHtml = msgHtml + '<td align="center" colspan = "11"><b>{}@{}</b></td>'.format(source,destination)
if (warning != ''):
msgText = msgText + '{}\n\n'.format(warning)
msgHtml = msgHtml + '<tr><td><align="center" colspan = "11"><i>{}</i></td>'.format(warning)
if (error != ''):
msgText = msgText + '{}\n\n'.format(error)
msgHtml = msgHtml + '<tr><td align="center" colspan = "11"><i>{}</i></td>'.format(error)
msgText = msgText + '\n'
msgHtml = msgHtml + '</tr></body><html>'
# Build email message
msg = MIMEMultipart('alternative')
msg['Subject'] = "!!! Backup Warning for {}@{} !!!".format(source, destination)
msg['From'] = options['outsender']
msg['To'] = options['outreceiver']
# Send the message via local SMTP server.
server = smtplib.SMTP('{}:{}'.format(options['outserver'], options['outport']))
write_log_entry(2, 'SMTP Server=[{}]'.format(server))
if options['outencryption'] == 'tls': # Do we need to use SSL/TLS?
server.starttls()
server.login(options['outaccount'], options['outpassword'])
server.sendmail(options['outsender'], options['outreceiver'], msg.as_string())
server.quit()
Sorry for my bad programming ability :(
Hopefully someone can test this. I didn't keep my bad backup emails from duplicati.
edit: fixed the output email to better match Handyguysoftware
The text was updated successfully, but these errors were encountered:
First, I've learned over the years that you should never apologize for your code. If it works, it's good code ;-)
Second, the -c & -t options are relics from the first bash/awk version of the program, where collecting and reporting were actually two separate programs. I stopped using them myself a couple of versions ago and was considering removing them altogether from the next version of the program. Now that I see there's a real life use case for them, I'll leave them in!
I like your idea but I'm not sure how to best implement it yet. I'm trying to lock down 2.0.4 so I don't want to make any more quick fixes to that code. I'm also starting to work on version 2.1 which will be an intensive restructuring of the code (it's getting too big and ungainly) and a rewrite of the reporting areas. Since this suggestion falls into that area, I will definitely put that on the to-do list for 2.1.
HandyGuySoftware
changed the title
Way to be warned of failers between reports
Way to be warned of failures between reports
Nov 27, 2017
My plan is to run the dupreport.py -r /etc/dupreport -c on a nightly basis. Only problem I see with this is I am not alerted to any errors in between the -c and when I run dupreport with the -t option. Having it run daily I would just end up ignoring the email altogether.
A way to parse the error and warning is needed. Given my limited skills I am testing the following
This very poorly done hack was attempted on the 2.0.3 issue 18 branch
On line 438 I added the following to def build_email_sql_statement
Then have the following code added. I am sure you can clean this up better than me if you decide to add something like this.
Sorry for my bad programming ability :(
Hopefully someone can test this. I didn't keep my bad backup emails from duplicati.
edit: fixed the output email to better match Handyguysoftware
The text was updated successfully, but these errors were encountered: