Beispiel #1
0
def sendalert(alerts, attachments=[], is_all_fail=False):
    email = Email()

    emails = ONE_FAIL_NOTIFICATIONS['emails']
    if is_all_fail:
        emails = ALL_FAIL_NOTIFICATIONS['emails']

    p = subprocess.Popen(['hostname'], stdout=subprocess.PIPE)
    hostname = p.stdout.read()

    report = StringIO()
    for x in alerts:
        print x
        report.writelines([x, '\r\n\r\n'])
    body = report.getvalue()
    report.close()

    subject = '[WARN] At least one tested failed - %s - %s' % (hostname,
                                                               time.ctime())
    if is_all_fail:
        subject = '[SERVE] All TEST FAILED for a service - %s - %s' % (
            hostname, time.ctime())

    email.sender = 'Gagein <*****@*****.**>'
    retries = 3
    while retries > 0:
        try:
            email.send(emails, subject, body, '', attachments)
            retries = 0
        except Exception, ex:
            retries = retries - 1
            print '... Retry due to exception: ', ex
Beispiel #2
0
def sendalert(alerts, attachments=[], is_all_fail=False):
    email = Email()

    emails = ONE_FAIL_NOTIFICATIONS['emails']
    if is_all_fail:
        emails = ALL_FAIL_NOTIFICATIONS['emails']

    p = subprocess.Popen(['hostname'], stdout=subprocess.PIPE)
    hostname = p.stdout.read()

    report = StringIO()
    for x in alerts:
        print x
        report.writelines([x, '\r\n\r\n']);
    body = report.getvalue()
    report.close()

    subject = '[WARN] At least one tested failed - %s - %s' % (hostname, time.ctime())
    if is_all_fail:
        subject = '[SERVE] All TEST FAILED for a service - %s - %s' % (hostname, time.ctime())

    email.sender = 'Gagein <*****@*****.**>'
    retries = 3
    while retries > 0:
        try:
            email.send(emails, subject, body, '', attachments)
            retries = 0
        except Exception, ex:
            retries = retries - 1
            print '... Retry due to exception: ', ex
def sendalert(alerts, hostname, attachments=[]):
	email = Email()

	report = StringIO()
	report.writelines(['\t\t Server Performance Alert [%s]\r\n' % hostname, '\r\n\r\n'])
	for x in alerts[1:]:
		print x
		report.writelines([x, '\r\n\r\n']);	
	body = report.getvalue()
	report.close()

	subject = 'Server Performance Alert [%s] [%s] - %s' % (alerts[0], hostname, time.ctime())	
	
	email.sender = 'Gagein <*****@*****.**>'
	email.send(emails, subject, body, '', attachments)
Beispiel #4
0
def sendalert(alerts, hostname, attachments=[]):
    email = Email()

    report = StringIO()
    report.writelines(
        ['\t\t Server Performance Alert [%s]\r\n' % hostname, '\r\n\r\n'])
    for x in alerts[1:]:
        print x
        report.writelines([x, '\r\n\r\n'])
    body = report.getvalue()
    report.close()

    subject = 'Server Performance Alert [%s] [%s] - %s' % (alerts[0], hostname,
                                                           time.ctime())

    email.sender = 'Gagein <*****@*****.**>'
    email.send(emails, subject, body, '', attachments)