Beispiel #1
0
def status(nodes):

    util.output("%-10s %-10s %-10s %-13s %-6s %-6s %-20s " %
                ("Name", "Type", "Host", "Status", "Pid", "Peers", "Started"))

    all = isRunning(nodes)
    running = []

    cmds1 = []
    cmds2 = []
    for (node, isrunning) in all:
        if isrunning:
            running += [node]
            cmds1 += [(node, "cat-file", ["%s/.startup" % node.cwd()])]
            cmds2 += [(node, "cat-file", ["%s/.status" % node.cwd()])]

    startups = execute.runHelperParallel(cmds1)
    statuses = execute.runHelperParallel(cmds2)

    startups = dict([(n.tag, success and util.fmttime(output[0]) or "???")
                     for (n, success, output) in startups])
    statuses = dict([(n.tag, success and output[0].split()[0].lower() or "???")
                     for (n, success, output) in statuses])

    peers = {}
    nodes = [n for n in running if statuses[n.tag] == "running"]
    for (node, success, args) in _queryPeerStatus(nodes):
        if success:
            peers[node.tag] = []
            for f in args[0].split():
                (key, val) = f.split("=")
                if key == "peer" and val != "":
                    peers[node.tag] += [val]
        else:
            peers[node.tag] = None

    for (node, isrunning) in all:

        util.output("%-10s " % node.tag, nl=False)
        util.output("%-10s %-10s " % (node.type, node.host), nl=False)

        if isrunning:
            util.output("%-13s " % statuses[node.tag], nl=False)

        elif node.hasCrashed():
            util.output("%-13s " % "crashed", nl=False)
        else:
            util.output("%-13s " % "stopped", nl=False)

        if isrunning:
            util.output("%-6s " % node.getPID(), nl=False)

            if node.tag in peers and peers[node.tag] != None:
                util.output("%-6d " % len(peers[node.tag]), nl=False)
            else:
                util.output("%-6s " % "???", nl=False)

            util.output("%-8s  " % startups[node.tag], nl=False)

        util.output()
Beispiel #2
0
def status(nodes):

    util.output("%-10s %-10s %-10s %-13s %-6s %-6s %-20s " % ("Name",  "Type", "Host", "Status", "Pid", "Peers", "Started"))

    all = isRunning(nodes)
    running = []

    cmds1 = []
    cmds2 = []
    for (node, isrunning) in all:
        if isrunning:
            running += [node]
            cmds1 += [(node, "cat-file", ["%s/.startup" % node.cwd()])]
            cmds2 += [(node, "cat-file", ["%s/.status" % node.cwd()])]

    startups = execute.runHelperParallel(cmds1)
    statuses = execute.runHelperParallel(cmds2)

    startups = dict([(n.name, success and util.fmttime(output[0]) or "???") for (n, success, output) in startups])
    statuses = dict([(n.name, success and output[0].split()[0].lower() or "???") for (n, success, output) in statuses])

    peers = {}
    nodes = [n for n in running if statuses[n.name] == "running"]
    for (node, success, args) in _queryPeerStatus(nodes):
        if success:
            peers[node.name] = []
            for f in args[0].split():
                keyval = f.split("=")
                if len(keyval) > 1:
                    (key, val) = keyval
                    if key == "peer" and val != "":
                        peers[node.name] += [val]
        else:
            peers[node.name] = None

    for (node, isrunning) in all:

        util.output("%-10s " % node.name, nl=False)
        util.output("%-10s %-10s " % (node.type, node.host), nl=False)

        if isrunning:
            util.output("%-13s " % statuses[node.name], nl=False)

        elif node.hasCrashed():
            util.output("%-13s " % "crashed", nl=False)
        else:
            util.output("%-13s " % "stopped", nl=False)

        if isrunning:
            util.output("%-6s " % node.getPID(), nl=False)

            if node.name in peers and peers[node.name] != None:
                util.output("%-6d " % len(peers[node.name]), nl=False)
            else:
                util.output("%-6s " % "???", nl=False)

            util.output("%-8s  " % startups[node.name], nl=False)

        util.output()
Beispiel #3
0
def status(nodes):
    typewidth = 7
    hostwidth = 16
    if config.Config.standalone == "1":
        # In standalone mode, the "type" column needs more width
        typewidth = 10
        hostwidth = 13

    util.output(
        "%-12s %-*s %-*s %-9s %-6s %-6s %s"
        % ("Name", typewidth, "Type", hostwidth, "Host", "Status", "Pid", "Peers", "Started")
    )

    all = isRunning(nodes)
    running = []

    cmds1 = []
    cmds2 = []
    for (node, isrunning) in all:
        if isrunning:
            running += [node]
            cmds1 += [(node, "cat-file", ["%s/.startup" % node.cwd()])]
            cmds2 += [(node, "cat-file", ["%s/.status" % node.cwd()])]

    startups = execute.runHelperParallel(cmds1)
    statuses = execute.runHelperParallel(cmds2)

    startups = dict([(n.name, success and util.fmttime(output[0]) or "???") for (n, success, output) in startups])
    statuses = dict([(n.name, success and output[0].split()[0].lower() or "???") for (n, success, output) in statuses])

    peers = {}
    nodes = [n for n in running if statuses[n.name] == "running"]
    for (node, success, args) in _queryPeerStatus(nodes):
        if success:
            peers[node.name] = []
            for f in args[0].split():
                keyval = f.split("=")
                if len(keyval) > 1:
                    (key, val) = keyval
                    if key == "peer" and val != "":
                        peers[node.name] += [val]
        else:
            peers[node.name] = None

    for (node, isrunning) in all:

        util.output("%-12s " % node.name, nl=False)
        util.output("%-*s %-*s " % (typewidth, node.type, hostwidth, node.host), nl=False)

        if isrunning:
            util.output("%-9s " % statuses[node.name], nl=False)

        elif node.hasCrashed():
            util.output("%-9s " % "crashed", nl=False)
        else:
            util.output("%-9s " % "stopped", nl=False)

        if isrunning:
            util.output("%-6s " % node.getPID(), nl=False)

            if node.name in peers and peers[node.name] != None:
                util.output("%-6d " % len(peers[node.name]), nl=False)
            else:
                util.output("%-6s " % "???", nl=False)

            util.output("%s" % startups[node.name], nl=False)

        util.output()

    # Return True if all nodes are running
    return len(nodes) == len(all)