Пример #1
0
def notifo_notify(user, key, ntype, host, state, service_desc, rest):
    title = '%s %s' % (ntype, host)
    msg = '%s - %s, %s' % (state, service_desc, rest)
    
    if config is not None:
        sechash = generate_hash(user, host, service_desc)
        ackurl = 'http://%s/%s' % (external_url, b64enc('/'.join([sechash, user, host,
                                                              service_desc])))
    else:
        ackurl = None
    
    nt = Notifo(user, key)
    nt.send_notification(msg=msg, label='nagios', title=title, uri=ackurl)
Пример #2
0
# Read the e-mail, find the Subject and From lines,
# and read the first several lines of the body.
body = ''
try:
	while True:
		line = raw_input()
		if line.startswith('From: '):
			sender = line[6:]
		if line.startswith('Subject: '):
			subject = line[9:]
		if line == '':
			break

	num_lines = 0
	while num_lines < config.getint('Format','lines'):
		line = raw_input()
		body += line + "\n"
		num_lines += 1
except EOFError:
	pass

msg = 'Subject: %s\nFrom: %s' % (subject, sender)
if body != '':
	msg += '\n\n' + body + '...'

if subject != '' and sender != '':
	notifo = Notifo(config.get('Login','user'), config.get('Login','secret'))
	notifo.send_notification(label=config.get('Format','label'), \
	                         title=config.get('Format','title'), msg=msg)