

def check_process_exists_and_amqp_connected(name):
    processes = filter((lambda p: check_process_name(name, p)), psutil.process_iter())
    if (not processes):
        critical(('%s is not running' % name))
    for p in processes:
        try:
            connections = p.get_connections(kind='inet')
        except psutil.NoSuchProcess:
            continue
        found_amqp = (len(list(itertools.takewhile((lambda c: ((len(p.remote_address) <= 1) or (c.remote_address[1] != AMQP_PORT))), connections))) != len(connections))
        if found_amqp:
            ok(('%s is working.' % name))
    critical(('%s is not connected to AMQP' % name))

dataset/ETHPy150Open openstack/monitoring-for-openstack/oschecks/utils.py check_process_exists_and_amqp_connected/VarMisuse@103/134 `c`->`p`