コード例 #1
0
def confirm_connections_work(conf, db_connections):
    """Call this to confirm that all connections are still alive before using them.
    Will recreate any closed connections."""
    confirmed_connections = []
    for db_connection in db_connections:
        if db_connection.closed:
            db_name = get_db_name_from_connection(db_connection)
            LOG.warn("database connection is closed to db '{}', reconnecting", db_name)
            confirmed_connections.append(connect_to_single_db_with_conf(conf, db_name))
        else:
            confirmed_connections.append(db_connection)
    return confirmed_connections
コード例 #2
0
def confirm_connections_work(conf, db_connections):
    """Call this to confirm that all connections are still alive before using them.
    Will recreate any closed connections."""
    confirmed_connections = []
    for db_connection in db_connections:
        if db_connection.closed:
            db_name = get_db_name_from_connection(db_connection)
            LOG.warn("database connection is closed to db '{}', reconnecting",
                     db_name)
            confirmed_connections.append(
                connect_to_single_db_with_conf(conf, db_name))
        else:
            confirmed_connections.append(db_connection)
    return confirmed_connections
コード例 #3
0
def get_all_metrics_scheduled(db_connections, conf):
    """Get all the metrics in scheduled manner, not calling all the functions every time.
    First gets the global stats with first available database connection,
    and then gets the rest per database.
    """
    db_functions, global_db_functions, data_dir_functions = get_all_stats_functions_from_conf(conf)
    data_dir = figure_out_postgres_data_dir(db_connections[0], conf)

    all_metrics = _call_all_db_functions(db_connections[0], global_db_functions, schedule=True)
    all_metrics.extend(_call_all_db_functions(data_dir, data_dir_functions, schedule=True))
    for db_connection in db_connections:
        db_name = get_db_name_from_connection(db_connection)
        all_metrics.extend(_call_all_db_functions(db_connection, db_functions,
                                                  schedule=True, db_name=db_name))
    return all_metrics
コード例 #4
0
def get_all_metrics_scheduled(db_connections, conf):
    """Get all the metrics in scheduled manner, not calling all the functions every time.
    First gets the global stats with first available database connection,
    and then gets the rest per database.
    """
    db_functions, global_db_functions = get_all_stats_functions_from_conf(conf)
    data_dir = figure_out_postgres_data_dir(db_connections[0], conf)

    all_metrics = _call_all_db_functions(global_db_functions,
                                         (data_dir, db_connections[0]),
                                         schedule=True)
    for db_connection in db_connections:
        db_name = get_db_name_from_connection(db_connection)
        all_metrics.extend(
            _call_all_db_functions(db_functions, (data_dir, db_connection),
                                   schedule=True,
                                   db_name=db_name))
    return all_metrics