haproxysessionmon/core.py
def create_monitors(config, loop):
    """Creates the HAProxy server monitors from the given configuration object."""
    backends = dict()
    monitors = dict()

    for backend_id, backend_config in config['backends'].items():
        logger.debug("Creating backend {} ({})".format(backend_id, backend_config['type']))
        if backend_config['type'] == CONFIG_BACKEND_TYPE_GELF:
            backends[backend_id] = GraylogBackend(
                (backend_config['host'], backend_config['port']),
                loop,
                facility=backend_config['facility']
            )
        elif backend_config['type'] == CONFIG_BACKEND_TYPE_LOGFILE:
            backends[backend_id] = LogfileBackend(
                backend_config['filename']
            )
        else:
            logger.warning("Backend currently not supported, skipping: {}".format(backend_config['type']))

    for monitor_id, server_config in config['servers'].items():
        logger.debug("Creating monitor for server at {}".format(server_config['endpoint']))
        monitors[monitor_id] = HAProxyServerMonitor(
            monitor_id,
            server_config['endpoint'],
            backends=[backends[b] for b in server_config['backends']],
            auth_creds=(server_config['username'], server_config['password']) if 'username' in server_config else None,
            update_interval=server_config['update-interval']
        )

    return monitors
Creates the HAProxy server monitors from the given configuration object.
Creates the HAProxy server monitors from the given configuration object.
Creates the HAProxy server monitors from the given configuration object .
def create_monitors(config, loop):
    backends = dict()
    monitors = dict()
    for backend_id, backend_config in config['backends'].items():
        logger.debug("Creating backend {} ({})".format(backend_id, backend_config['type']))
        if backend_config['type'] == CONFIG_BACKEND_TYPE_GELF:
            backends[backend_id] = GraylogBackend(
                (backend_config['host'], backend_config['port']),
                loop,
                facility=backend_config['facility']
            )
        elif backend_config['type'] == CONFIG_BACKEND_TYPE_LOGFILE:
            backends[backend_id] = LogfileBackend(
                backend_config['filename']
            )
        else:
            logger.warning("Backend currently not supported, skipping: {}".format(backend_config['type']))
    for monitor_id, server_config in config['servers'].items():
        logger.debug("Creating monitor for server at {}".format(server_config['endpoint']))
        monitors[monitor_id] = HAProxyServerMonitor(
            monitor_id,
            server_config['endpoint'],
            backends=[backends[b] for b in server_config['backends']],
            auth_creds=(server_config['username'], server_config['password']) if 'username' in server_config else None,
            update_interval=server_config['update-interval']
        )
    return monitors
def create_monitors ( config , loop ) : backends = dict ( ) monitors = dict ( ) for backend_id , backend_config in config [ 'backends' ] . items ( ) : logger . debug ( "Creating backend {} ({})" . format ( backend_id , backend_config [ 'type' ] ) ) if backend_config [ 'type' ] == CONFIG_BACKEND_TYPE_GELF : backends [ backend_id ] = GraylogBackend ( ( backend_config [ 'host' ] , backend_config [ 'port' ] ) , loop , facility = backend_config [ 'facility' ] ) elif backend_config [ 'type' ] == CONFIG_BACKEND_TYPE_LOGFILE : backends [ backend_id ] = LogfileBackend ( backend_config [ 'filename' ] ) else : logger . warning ( "Backend currently not supported, skipping: {}" . format ( backend_config [ 'type' ] ) ) for monitor_id , server_config in config [ 'servers' ] . items ( ) : logger . debug ( "Creating monitor for server at {}" . format ( server_config [ 'endpoint' ] ) ) monitors [ monitor_id ] = HAProxyServerMonitor ( monitor_id , server_config [ 'endpoint' ] , backends = [ backends [ b ] for b in server_config [ 'backends' ] ] , auth_creds = ( server_config [ 'username' ] , server_config [ 'password' ] ) if 'username' in server_config else None , update_interval = server_config [ 'update-interval' ] ) return monitors
Creates the HAProxy server monitors from the given configuration object.
Creates the HAProxy server monitors from the given configuration object .
"""Creates the HAProxy server monitors from the given configuration object."""
config
loop