def ReadOMSAgentConf(HeartbeatIntervalSeconds, PerfCounterObject):
    txt = ''
    try:
        txt = codecs.open(conf_path, 'r', 'utf8').read().encode('ascii', 'ignore')
        LG().Log('INFO', (('Read omsagent configuration ' + conf_path) + '.'))
    except:
        LG().Log('ERROR', (('Unable to read omsagent configuration ' + conf_path) + '.'))
    heartbeat_srch_str = '<source>.*?tag heartbeat.*?run_interval ([0-9]+[a-z])\\n</source>\\n'
    heartbeat_srch = re.compile(heartbeat_srch_str, (re.M | re.S))
    m = heartbeat_srch.search(txt)
    if (m is not None):
        interval = int(m.group(1)[:(- 1)])
        if (m.group(1)[(- 1):] == 'm'):
            interval *= 60
    else:
        interval = None
    new_heartbeat = interval
    perf_src_srch_str = '\\n<source>\\n  type oms_omi.*?object_name "(.*?)".*?instance_regex "(.*?)".*?counter_name_regex "(.*?)".*?interval ([0-9]+[a-z]).*?</source>\\n'
    perf_src_srch = re.compile(perf_src_srch_str, (re.M | re.S))
    new_perfobj = []
    sources = perf_src_srch.findall(txt)
    inst = ''
    interval = 0
    for source in sources:
        s_perf = []
        if len(source[2]):
            s_perf = source[2].strip('(').strip(')').split('|')
        object_name = source[0]
        interval = int(source[3][:(- 1)])
        if (source[3][(- 1):] == 'm'):
            interval *= 60
        inst = source[1]
        inst = inst.replace('.*', '*')
        new_perfobj.append({'PerformanceCounter': s_perf, 'InstanceName': inst, 'IntervalSeconds': interval, 'AllInstances': True, 'ObjectName': object_name})
    return (new_heartbeat, new_perfobj)
def ReadOMSAgentConf(HeartbeatIntervalSeconds, PerfCounterObject):
    txt = 
    try:
        txt = codecs.open(conf_path, 'r', 'utf8').read().encode('ascii', 'ignore')
        LG().Log('INFO', (('Read omsagent configuration ' + conf_path) + '.'))
    except:
        LG().Log('ERROR', (('Unable to read omsagent configuration ' + conf_path) + '.'))
    heartbeat_srch_str = '<source>.*?tag heartbeat.*?run_interval ([0-9]+[a-z])\\n</source>\\n'
    heartbeat_srch = re.compile(heartbeat_srch_str, (re.M | re.S))
    m = heartbeat_srch.search(txt)
    if (m is not None):
        interval = int(m.group(1)[:(- 1)])
        if (m.group(1)[(- 1):] == 'm'):
            interval *= 60
    else:
        interval = None
    new_heartbeat = interval
    perf_src_srch_str = '\\n<source>\\n  type oms_omi.*?object_name "(.*?)".*?instance_regex "(.*?)".*?counter_name_regex "(.*?)".*?interval ([0-9]+[a-z]).*?</source>\\n'
    perf_src_srch = re.compile(perf_src_srch_str, (re.M | re.S))
    new_perfobj = []
    sources = perf_src_srch.findall(txt)
    inst = 
    interval = 0
    for source in sources:
        s_perf = []
        if len(source[2]):
            s_perf = source[2].strip('(').strip(')').split('|')
        object_name = source[0]
        interval = int(source[3][:(- 1)])
        if (source[3][(- 1):] == 'm'):
            interval *= 60
        inst = source[1]
        inst = inst.replace('.*', '*')
        new_perfobj.append({'PerformanceCounter': s_perf, 'InstanceName': inst, 'IntervalSeconds': interval, 'AllInstances': True, 'ObjectName': object_name})
    return (new_heartbeat, new_perfobj)