예제 #1
0
def submit_errors(error_msg):
    """ submit_errors is used for sending out notifications 
    of errors.
    We can put in a variety of things here. For now, we have
    email submission and a quick syslog sent over to verify that
    we made it into here.
    """

    # If there's no error messages, just get out of here
    if not error_msg:
        util.write_log('nothing to submit')
        return True

    myhost = util.get_differ_hostname()

    # email out the message
    if DIFFER_EMAIL_ERRORS:
        subject = 'Differ ERRORS: %s' % myhost
        util.mail_it(RCPT_TO, MAIL_FROM, subject, error_msg, '*****@*****.**')

    # send to the syslog on DIFFERLOGHOST the fact that we sent out an error
    # helpful for perhaps getting a quick look at how many servers
    # were sending out errors
    human_time = time.strftime('%Y%m%d %H:%M', time.localtime())
    try:
        syslog_msg = '%s errors submitted at %s' % (myhost, human_time)
        c = syslog_client.syslog_client((DIFFERLOGHOST, 514))
        c.log(syslog_msg, facility='local4', priority='info')
    except:
        pass
예제 #2
0
 def differ_db_inject(self):
     self.differ_db.add_differ_error(self.file_name, 
                                     self.product, 
                                     self.location, 
                                     self.method, 
                                     self.error_msg, 
                                     self.exception,
                                     int(time.time()), 
                                     util.get_differ_hostname().strip())