(conn)
return rows
Return metrics about each `server`.
Return metrics about each `server`.
Return metrics about each server .
def get_server_metrics(conn):
    # type: (rethinkdb.net.Connection) -> List[tuple]
    """
    Return metrics about each `server`.
    """
    # For servers, stats['id'] has the form ['server', '<SERVER_ID>']
    is_server_stats_row = r.row['id'].nth(0) == 'server'
    server_id = r.row['id'].nth(1)

    server_statuses = list(SERVER_STATUS.run(conn))
    joined_server_stats = STATS.filter(is_server_stats_row).eq_join(server_id, SERVER_CONFIG).run(conn)

    rows = []  # type: List[tuple]
    for document in joined_server_stats:
        server_stats = document['left']
        server = document['right']
        # Join stats and statuses in Python.
        server_status = next(status for status in server_statuses if status['name'] == server['name'])

        row = (
            server['name'],
            server['tags'],
            server_stats['query_engine']['client_connections'],
            server_stats['query_engine']['clients_active'],
            server_stats['query_engine']['queries_per_sec'],
            server_stats['query_engine']['queries_total'],
            server_stats['query_engine']['read_docs_per_sec'],
            server_stats['query_engine']['read_docs_total'],
            server_stats['query_engine']['written_docs_per_sec'],
            server_stats['query_engine']['written_docs_total'],
            to_time_elapsed(server_status['network']['time_connected']),
            len(server_status['network']['connected_to']),
            to_time_elapsed(server_status['process']['time_started']),
        )
        rows.append(row)

    return rows
def get_server_metrics ( conn ) : # type: (rethinkdb.net.Connection) -> List[tuple] # For servers, stats['id'] has the form ['server', '<SERVER_ID>'] is_server_stats_row = r . row [ 'id' ] . nth ( 0 ) == 'server' server_id = r . row [ 'id' ] . nth ( 1 ) server_statuses = list ( SERVER_STATUS . run ( conn ) ) joined_server_stats = STATS . filter ( is_server_stats_row ) . eq_join ( server_id , SERVER_CONFIG ) . run ( conn ) rows = [ ] # type: List[tuple] for document in joined_server_stats : server_stats = document [ 'left' ] server = document [ 'right' ] # Join stats and statuses in Python. server_status = next ( status for status in server_statuses if status [ 'name' ] == server [ 'name' ] ) row = ( server [ 'name' ] , server [ 'tags' ] , server_stats [ 'query_engine' ] [ 'client_connections' ] , server_stats [ 'query_engine' ] [ 'clients_active' ] , server_stats [ 'query_engine' ] [ 'queries_per_sec' ] , server_stats [ 'query_engine' ] [ 'queries_total' ] , server_stats [ 'query_engine' ] [ 'read_docs_per_sec' ] , server_stats [ 'query_engine' ] [ 'read_docs_total' ] , server_stats [ 'query_engine' ] [ 'written_docs_per_sec' ] , server_stats [ 'query_engine' ] [ 'written_docs_total' ] , to_time_elapsed ( server_status [ 'network' ] [ 'time_connected' ] ) , len ( server_status [ 'network' ] [ 'connected_to' ] ) , to_time_elapsed ( server_status [ 'process' ] [ 'time_started' ] ) , ) rows . append ( row ) return rows