Beispiel #1
0
def activity(server=None, node=None):
    redis = get_redis()
    start = request.args.get('start', 0)
    end = request.args.get('end', 99)
    if not server and not node:
        history_key = make_key("_all", "history")
    else:
        history_key = make_key(server, node, "log")
    max_entry = redis.llen(history_key)

    entries_raw = redis.lrange(history_key, start, end)
    entries = map(json.loads, entries_raw)
    nodes = {}
    for server_name, _ in iterate_servers():
        server_entries = filter(lambda x: x['server'] == server_name, entries)
        server_node_refs = set(map(lambda x: x['node'], server_entries))
        server_nodes = dict((node, json.loads(redis.get(make_key(server_name, "nodes", node))))
                            for node in server_node_refs)
        nodes[server_name] = server_nodes
    return {
        "entries": entries,
        "nodes": nodes,
        "start": start,
        "end": end,
        "max_entry": max_entry
    }
Beispiel #2
0
def activity(server=None, node=None):
    redis = get_redis()
    start = request.args.get('start', 0)
    end = request.args.get('end', 99)
    if not server and not node:
        history_key = make_key("_all", "history")
    else:
        history_key = make_key(server, node, "log")
    max_entry = redis.llen(history_key)

    entries_raw = redis.lrange(history_key, start, end)
    entries = map(json.loads, entries_raw)
    nodes = {}
    for server_name, _ in iterate_servers():
        server_entries = filter(lambda x: x['server'] == server_name, entries)
        server_node_refs = set(map(lambda x: x['node'], server_entries))
        server_nodes = dict(
            (node, json.loads(redis.get(make_key(server_name, "nodes", node))))
            for node in server_node_refs)
        nodes[server_name] = server_nodes
    return {
        "entries": entries,
        "nodes": nodes,
        "start": start,
        "end": end,
        "max_entry": max_entry
    }
Beispiel #3
0
def assemble_history():
    redis = get_redis()
    # Do a refresh of all our node information
    for server_name, server_location in iterate_servers():
        collect_type_for_server(server_name, server_location, "nodes")
        server_history = get_history_for_server(server_name, server_location)
        history_key = make_key(server_name, "history")
        replace_list(history_key, server_history)

    entries = []
    for server_name, _ in iterate_servers():
        server_history_key = make_key(server_name, "history")
        server_entries_raw = redis.lrange(server_history_key, 0, -1)
        server_entries = map(json.loads, server_entries_raw)
        entries.extend(server_entries)

    time_getter = lambda x: x["entry"]["timestamp"]
    entries = sorted_by_time_element(entries, time_getter)
    replace_list(make_key("_all", "history"), entries)
Beispiel #4
0
def assemble_history():
    redis = get_redis()
    # Do a refresh of all our node information
    for server_name, server_location in iterate_servers():
        collect_type_for_server(server_name, server_location, "nodes")
        server_history = get_history_for_server(server_name, server_location)
        history_key = make_key(server_name, "history")
        replace_list(history_key, server_history)

    entries = []
    for server_name, _ in iterate_servers():
        server_history_key = make_key(server_name, "history")
        server_entries_raw = redis.lrange(server_history_key, 0, -1)
        server_entries = map(json.loads, server_entries_raw)
        entries.extend(server_entries)

    time_getter = lambda x: x["entry"]["timestamp"]
    entries = sorted_by_time_element(entries, time_getter)
    replace_list(make_key("_all", "history"), entries)
Beispiel #5
0
def collection_view(collection, server=None, item=None):
    redis = get_redis()
    items = {}
    for server_name, _ in iterate_servers():
        server_item_refs = json.loads(redis.get(make_key(server_name, collection)))
        server_item_names = map(lambda x: x['name'], server_item_refs)
        server_items = dict((server_item, json.loads(redis.get(make_key(server_name, collection, server_item))))
                            for server_item in server_item_names)
        items[server_name] = server_items

    result = {
        "items": items,
        "collection": collection
    }
    if server and item:
        result.update({"server": server, "selected": item})
    return result
Beispiel #6
0
def collection_view(collection, server=None, item=None):
    redis = get_redis()
    items = {}
    for server_name, _ in iterate_servers():
        server_item_refs = json.loads(
            redis.get(make_key(server_name, collection)))
        server_item_names = map(lambda x: x['name'], server_item_refs)
        server_items = dict(
            (server_item,
             json.loads(
                 redis.get(make_key(server_name, collection, server_item))))
            for server_item in server_item_names)
        items[server_name] = server_items

    result = {"items": items, "collection": collection}
    if server and item:
        result.update({"server": server, "selected": item})
    return result
Beispiel #7
0
def collect_all():
    for server_name, server_location in iterate_servers():
        collect_all_for_server(server_name, server_location)
Beispiel #8
0
def collect_all():
    for server_name, server_location in iterate_servers():
        collect_all_for_server(server_name, server_location)