Exemplo n.º 1
0
def build_msg(args, *headers):
    msg = Message()
    msg.header = dict()
    msg.body = str()

    timestamp, service, hostname, testname, status, nagioshost = headers

    msg.header.update({'execution_time': timestamp})
    msg.header.update({'service_flavour': service})
    msg.header.update({'node_name': hostname})
    msg.header.update({'test_name': testname})
    msg.header.update({'status': status})

    for bs in ['details', 'vo', 'site', 'roc', 'urlhistory', 'urlhelp']:
        code = "msg.body += '%s: ' + args.%s + '\\n' if args.%s else ''" % (
            bs, bs, bs)
        exec(code)

    msg.text = True
    return msg
def build_msg(args, *headers):
    msg = Message()
    msg.header = dict()
    msg.body = str()

    timestamp, service, hostname, metric, status, nagioshost = headers

    msg.header.update({'timestamp': timestamp})
    msg.header.update({'service': service})
    msg.header.update({'hostname': hostname})
    msg.header.update({'metric': metric})
    msg.header.update({'status': status})
    msg.header.update({'monitoring_host': nagioshost})

    for bs in [
            'summary', 'message', 'vofqan', 'voname', 'roc', 'actual_data',
            'site'
    ]:
        code = "msg.body += '%s: ' + args.%s + '\\n' if args.%s else ''" % (
            bs, bs, bs)
        exec(code)

    msg.text = True
    return msg