diff --git a/api/nodes.go b/api/nodes.go index 18cc68cfe36..8ae8cd6dc38 100644 --- a/api/nodes.go +++ b/api/nodes.go @@ -169,6 +169,7 @@ type NodeListStub struct { Datacenter string Name string NodeClass string + Version string Drain bool Status string StatusDescription string diff --git a/command/node_status.go b/command/node_status.go index 67983533c92..5a3e127cebe 100644 --- a/command/node_status.go +++ b/command/node_status.go @@ -57,7 +57,7 @@ Node Status Options: -self Query the status of the local node. - -stats + -stats Display detailed resource usage statistics. -allocs @@ -148,35 +148,40 @@ func (c *NodeStatusCommand) Run(args []string) int { // Format the nodes list out := make([]string, len(nodes)+1) + + out[0] = "ID|DC|Name|Class|" + + if c.verbose { + out[0] += "Version|" + } + + out[0] += "Drain|Status" + if c.list_allocs { - out[0] = "ID|DC|Name|Class|Drain|Status|Running Allocs" - } else { - out[0] = "ID|DC|Name|Class|Drain|Status" + out[0] += "|Running Allocs" } for i, node := range nodes { + out[i+1] = fmt.Sprintf("%s|%s|%s|%s", + limit(node.ID, c.length), + node.Datacenter, + node.Name, + node.NodeClass) + if c.verbose { + out[i+1] += fmt.Sprintf("|%s", + node.Version) + } + out[i+1] += fmt.Sprintf("|%v|%s", + node.Drain, + node.Status) if c.list_allocs { numAllocs, err := getRunningAllocs(client, node.ID) if err != nil { c.Ui.Error(fmt.Sprintf("Error querying node allocations: %s", err)) return 1 } - out[i+1] = fmt.Sprintf("%s|%s|%s|%s|%v|%s|%v", - limit(node.ID, c.length), - node.Datacenter, - node.Name, - node.NodeClass, - node.Drain, - node.Status, + out[i+1] += fmt.Sprintf("|%v", len(numAllocs)) - } else { - out[i+1] = fmt.Sprintf("%s|%s|%s|%s|%v|%s", - limit(node.ID, c.length), - node.Datacenter, - node.Name, - node.NodeClass, - node.Drain, - node.Status) } } diff --git a/nomad/structs/structs.go b/nomad/structs/structs.go index 372d1688440..9ad8bc3485d 100644 --- a/nomad/structs/structs.go +++ b/nomad/structs/structs.go @@ -1057,6 +1057,7 @@ func (n *Node) Stub() *NodeListStub { Datacenter: n.Datacenter, Name: n.Name, NodeClass: n.NodeClass, + Version: n.Attributes["nomad.version"], Drain: n.Drain, Status: n.Status, StatusDescription: n.StatusDescription, @@ -1072,6 +1073,7 @@ type NodeListStub struct { Datacenter string Name string NodeClass string + Version string Drain bool Status string StatusDescription string