2015-09-12 20:55:51 +00:00
|
|
|
package command
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2015-10-21 01:00:00 +00:00
|
|
|
"sort"
|
2016-05-22 09:04:27 +00:00
|
|
|
"strconv"
|
2015-09-12 20:55:51 +00:00
|
|
|
"strings"
|
2016-05-22 09:36:12 +00:00
|
|
|
"time"
|
2016-03-21 00:30:33 +00:00
|
|
|
|
2016-05-22 09:04:27 +00:00
|
|
|
"github.com/dustin/go-humanize"
|
|
|
|
|
2016-03-21 00:30:33 +00:00
|
|
|
"github.com/hashicorp/nomad/api"
|
2015-09-12 20:55:51 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type NodeStatusCommand struct {
|
2015-09-14 20:13:52 +00:00
|
|
|
Meta
|
2015-09-12 20:55:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *NodeStatusCommand) Help() string {
|
|
|
|
helpText := `
|
2016-01-27 20:00:31 +00:00
|
|
|
Usage: nomad node-status [options] <node>
|
2015-09-12 20:55:51 +00:00
|
|
|
|
2015-09-13 18:39:49 +00:00
|
|
|
Display status information about a given node. The list of nodes
|
|
|
|
returned includes only nodes which jobs may be scheduled to, and
|
2015-09-12 20:55:51 +00:00
|
|
|
includes status and other high-level information.
|
|
|
|
|
|
|
|
If a node ID is passed, information for that specific node will
|
|
|
|
be displayed. If no node ID's are passed, then a short-hand
|
2016-03-29 19:36:24 +00:00
|
|
|
list of all nodes will be displayed. The -self flag is useful to
|
|
|
|
quickly access the status of the local node.
|
2015-09-12 20:55:51 +00:00
|
|
|
|
2015-09-14 20:13:52 +00:00
|
|
|
General Options:
|
2015-09-12 20:55:51 +00:00
|
|
|
|
2015-09-15 18:20:08 +00:00
|
|
|
` + generalOptionsUsage() + `
|
|
|
|
|
|
|
|
Node Status Options:
|
|
|
|
|
|
|
|
-short
|
|
|
|
Display short output. Used only when a single node is being
|
|
|
|
queried, and drops verbose output about node allocations.
|
2016-01-14 20:57:43 +00:00
|
|
|
|
2016-01-15 22:32:38 +00:00
|
|
|
-verbose
|
|
|
|
Display full information.
|
2016-03-03 19:46:24 +00:00
|
|
|
|
2016-03-29 19:36:24 +00:00
|
|
|
-self
|
|
|
|
Query the status of the local node.
|
|
|
|
|
2016-03-03 19:46:24 +00:00
|
|
|
-allocs
|
|
|
|
Display a count of running allocations for each node.
|
2015-09-15 18:20:08 +00:00
|
|
|
`
|
2015-09-12 20:55:51 +00:00
|
|
|
return strings.TrimSpace(helpText)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *NodeStatusCommand) Synopsis() string {
|
2015-09-13 18:39:49 +00:00
|
|
|
return "Display status information about nodes"
|
2015-09-12 20:55:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *NodeStatusCommand) Run(args []string) int {
|
2016-05-26 08:21:39 +00:00
|
|
|
var short, verbose, list_allocs, self bool
|
2016-05-22 09:36:12 +00:00
|
|
|
var hostStats *api.HostStats
|
2015-09-15 18:20:08 +00:00
|
|
|
|
2015-09-14 20:13:52 +00:00
|
|
|
flags := c.Meta.FlagSet("node-status", FlagSetClient)
|
2015-09-12 20:55:51 +00:00
|
|
|
flags.Usage = func() { c.Ui.Output(c.Help()) }
|
2015-09-15 18:20:08 +00:00
|
|
|
flags.BoolVar(&short, "short", false, "")
|
2016-01-15 22:32:38 +00:00
|
|
|
flags.BoolVar(&verbose, "verbose", false, "")
|
2016-03-03 19:09:07 +00:00
|
|
|
flags.BoolVar(&list_allocs, "allocs", false, "")
|
2016-03-29 19:36:24 +00:00
|
|
|
flags.BoolVar(&self, "self", false, "")
|
2015-09-15 18:20:08 +00:00
|
|
|
|
2015-09-12 20:55:51 +00:00
|
|
|
if err := flags.Parse(args); err != nil {
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check that we got either a single node or none
|
2015-09-14 20:13:52 +00:00
|
|
|
args = flags.Args()
|
|
|
|
if len(args) > 1 {
|
2015-09-12 20:55:51 +00:00
|
|
|
c.Ui.Error(c.Help())
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
2016-01-14 20:57:43 +00:00
|
|
|
// Truncate the id unless full length is requested
|
2016-01-15 22:32:38 +00:00
|
|
|
length := shortId
|
|
|
|
if verbose {
|
|
|
|
length = fullId
|
2016-01-14 20:57:43 +00:00
|
|
|
}
|
|
|
|
|
2015-09-12 20:55:51 +00:00
|
|
|
// Get the HTTP client
|
2015-09-14 20:13:52 +00:00
|
|
|
client, err := c.Meta.Client()
|
2015-09-12 20:55:51 +00:00
|
|
|
if err != nil {
|
2015-09-14 20:13:52 +00:00
|
|
|
c.Ui.Error(fmt.Sprintf("Error initializing client: %s", err))
|
2015-09-12 20:55:51 +00:00
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
// Use list mode if no node name was provided
|
2016-03-29 19:36:24 +00:00
|
|
|
if len(args) == 0 && !self {
|
2015-09-12 20:55:51 +00:00
|
|
|
// Query the node info
|
|
|
|
nodes, _, err := client.Nodes().List(nil)
|
|
|
|
if err != nil {
|
2015-09-14 20:13:52 +00:00
|
|
|
c.Ui.Error(fmt.Sprintf("Error querying node status: %s", err))
|
2015-09-12 20:55:51 +00:00
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return nothing if no nodes found
|
|
|
|
if len(nodes) == 0 {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
// Format the nodes list
|
|
|
|
out := make([]string, len(nodes)+1)
|
2016-03-03 19:09:07 +00:00
|
|
|
if list_allocs {
|
|
|
|
out[0] = "ID|DC|Name|Class|Drain|Status|Running Allocs"
|
|
|
|
} else {
|
|
|
|
out[0] = "ID|DC|Name|Class|Drain|Status"
|
|
|
|
}
|
2015-09-12 20:55:51 +00:00
|
|
|
for i, node := range nodes {
|
2016-03-03 19:09:07 +00:00
|
|
|
if list_allocs {
|
2016-03-05 03:14:57 +00:00
|
|
|
numAllocs, err := getRunningAllocs(client, node.ID)
|
2016-03-03 19:09:07 +00:00
|
|
|
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, length),
|
|
|
|
node.Datacenter,
|
|
|
|
node.Name,
|
|
|
|
node.NodeClass,
|
|
|
|
node.Drain,
|
|
|
|
node.Status,
|
2016-03-05 03:14:57 +00:00
|
|
|
len(numAllocs))
|
2016-03-03 19:09:07 +00:00
|
|
|
} else {
|
|
|
|
out[i+1] = fmt.Sprintf("%s|%s|%s|%s|%v|%s",
|
|
|
|
limit(node.ID, length),
|
|
|
|
node.Datacenter,
|
|
|
|
node.Name,
|
|
|
|
node.NodeClass,
|
|
|
|
node.Drain,
|
|
|
|
node.Status)
|
2016-03-03 17:19:56 +00:00
|
|
|
}
|
2015-09-12 20:55:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Dump the output
|
2015-09-15 23:44:38 +00:00
|
|
|
c.Ui.Output(formatList(out))
|
2015-09-12 20:55:51 +00:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
// Query the specific node
|
2016-04-11 22:20:49 +00:00
|
|
|
nodeID := ""
|
2016-03-29 19:36:24 +00:00
|
|
|
if !self {
|
|
|
|
nodeID = args[0]
|
2016-04-11 22:20:49 +00:00
|
|
|
} else {
|
|
|
|
var err error
|
|
|
|
if nodeID, err = getLocalNodeID(client); err != nil {
|
|
|
|
c.Ui.Error(err.Error())
|
|
|
|
return 1
|
|
|
|
}
|
2016-03-29 19:36:24 +00:00
|
|
|
}
|
2016-03-17 23:48:45 +00:00
|
|
|
if len(nodeID) == 1 {
|
|
|
|
c.Ui.Error(fmt.Sprintf("Identifier must contain at least two characters."))
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
if len(nodeID)%2 == 1 {
|
|
|
|
// Identifiers must be of even length, so we strip off the last byte
|
|
|
|
// to provide a consistent user experience.
|
|
|
|
nodeID = nodeID[:len(nodeID)-1]
|
|
|
|
}
|
2016-01-21 19:53:05 +00:00
|
|
|
|
2016-03-17 23:48:45 +00:00
|
|
|
nodes, _, err := client.Nodes().PrefixList(nodeID)
|
|
|
|
if err != nil {
|
|
|
|
c.Ui.Error(fmt.Sprintf("Error querying node info: %s", err))
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
// Return error if no nodes are found
|
|
|
|
if len(nodes) == 0 {
|
|
|
|
c.Ui.Error(fmt.Sprintf("No node(s) with prefix %q found", nodeID))
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
if len(nodes) > 1 {
|
|
|
|
// Format the nodes list that matches the prefix so that the user
|
|
|
|
// can create a more specific request
|
|
|
|
out := make([]string, len(nodes)+1)
|
|
|
|
out[0] = "ID|DC|Name|Class|Drain|Status"
|
|
|
|
for i, node := range nodes {
|
|
|
|
out[i+1] = fmt.Sprintf("%s|%s|%s|%s|%v|%s",
|
|
|
|
limit(node.ID, length),
|
|
|
|
node.Datacenter,
|
|
|
|
node.Name,
|
|
|
|
node.NodeClass,
|
|
|
|
node.Drain,
|
|
|
|
node.Status)
|
2015-12-22 22:44:33 +00:00
|
|
|
}
|
2016-03-17 23:48:45 +00:00
|
|
|
// Dump the output
|
|
|
|
c.Ui.Output(fmt.Sprintf("Prefix matched multiple nodes\n\n%s", formatList(out)))
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
// Prefix lookup matched a single node
|
|
|
|
node, _, err := client.Nodes().Info(nodes[0].ID, nil)
|
|
|
|
if err != nil {
|
|
|
|
c.Ui.Error(fmt.Sprintf("Error querying node info: %s", err))
|
|
|
|
return 1
|
2015-09-12 20:55:51 +00:00
|
|
|
}
|
|
|
|
|
2016-05-26 08:21:39 +00:00
|
|
|
if hostStats, err = client.Nodes().Stats(node.ID, nil); err != nil {
|
|
|
|
c.Ui.Error(fmt.Sprintf("error fetching node resource utilization stats: %v", err))
|
2016-05-22 09:36:12 +00:00
|
|
|
}
|
|
|
|
|
2015-09-12 20:55:51 +00:00
|
|
|
// Format the output
|
2015-09-15 18:20:08 +00:00
|
|
|
basic := []string{
|
2016-01-27 18:42:10 +00:00
|
|
|
fmt.Sprintf("ID|%s", limit(node.ID, length)),
|
2015-09-15 23:51:17 +00:00
|
|
|
fmt.Sprintf("Name|%s", node.Name),
|
|
|
|
fmt.Sprintf("Class|%s", node.NodeClass),
|
2016-03-03 19:09:07 +00:00
|
|
|
fmt.Sprintf("DC|%s", node.Datacenter),
|
2015-09-15 23:51:17 +00:00
|
|
|
fmt.Sprintf("Drain|%v", node.Drain),
|
|
|
|
fmt.Sprintf("Status|%s", node.Status),
|
2015-09-12 20:55:51 +00:00
|
|
|
}
|
2016-05-26 08:21:39 +00:00
|
|
|
if hostStats != nil {
|
2016-05-22 09:36:12 +00:00
|
|
|
uptime := time.Duration(hostStats.Uptime * uint64(time.Second))
|
|
|
|
basic = append(basic, fmt.Sprintf("Uptime|%s", uptime.String()))
|
|
|
|
}
|
Print resource usage w/ alloc-status + node-status
When alloc-status is called, in it's long form only, print the resource
utilization for that single allocation.
When node-status is called, in it's long form only, print the TOTAL
resource utilization that is occurring on that single node.
Nomad Alloc Status:
```
% nomad alloc-status 195d3bf2
ID = 195d3bf2
Eval ID = c917e3ee
Name = example.cache[1]
Node ID = 1b2520a7
Job ID = example
Client Status = running
Evaluated Nodes = 1
Filtered Nodes = 0
Exhausted Nodes = 0
Allocation Time = 17.73µs
Failures = 0
==> Task "redis" is "running"
Recent Events:
Time Type Description
04/03/16 21:20:45 EST Started Task started by client
04/03/16 21:20:42 EST Received Task received by client
==> Status
Allocation "195d3bf2" status "running" (0/1 nodes filtered)
* Score "1b2520a7-6714-e78d-a8f7-68467dda6db7.binpack" = 1.209464
* Score "1b2520a7-6714-e78d-a8f7-68467dda6db7.job-anti-affinity" = -10.000000
==> Resources
CPU MemoryMB DiskMB IOPS
500 256 300 0
```
Nomad Node Status:
```
% nomad node-status 57b3a55a
ID = 57b3a55a
Name = biscuits
Class = <none>
DC = dc1
Drain = false
Status = ready
Attributes = arch:amd64, cpu.frequency:3753.458875, cpu.modelname:Intel(R) Core(TM) i7-4770K CPU @ 3.50GHz, cpu.numcores:8, cpu.totalcompute:30027.671000, driver.docker:1, driver.docker.version:1.10.2, driver.exec:1, driver.raw_exec:1, hostname:biscuits, kernel.name:linux, kernel.version:4.4.0-9-generic, memory.totalbytes:25208934400, os.name:ubuntu, os.version:16.04, unique.cgroup.mountpoint:/sys/fs/cgroup, unique.network.ip-address:127.0.0.1, unique.storage.bytesfree:219781419008, unique.storage.bytestotal:246059892736, unique.storage.volume:/dev/sdb3
==> Allocations
ID Eval ID Job ID Task Group Desired Status Client Status
2c236883 aa11aca8 example cache run running
32f6e3d6 aa11aca8 example cache run running
==> Resource Utilization
CPU MemoryMB DiskMB IOPS
1000 512 600 0
```
2016-03-05 02:29:39 +00:00
|
|
|
c.Ui.Output(formatKV(basic))
|
2016-03-21 00:30:33 +00:00
|
|
|
|
2015-09-15 18:20:08 +00:00
|
|
|
if !short {
|
Print resource usage w/ alloc-status + node-status
When alloc-status is called, in it's long form only, print the resource
utilization for that single allocation.
When node-status is called, in it's long form only, print the TOTAL
resource utilization that is occurring on that single node.
Nomad Alloc Status:
```
% nomad alloc-status 195d3bf2
ID = 195d3bf2
Eval ID = c917e3ee
Name = example.cache[1]
Node ID = 1b2520a7
Job ID = example
Client Status = running
Evaluated Nodes = 1
Filtered Nodes = 0
Exhausted Nodes = 0
Allocation Time = 17.73µs
Failures = 0
==> Task "redis" is "running"
Recent Events:
Time Type Description
04/03/16 21:20:45 EST Started Task started by client
04/03/16 21:20:42 EST Received Task received by client
==> Status
Allocation "195d3bf2" status "running" (0/1 nodes filtered)
* Score "1b2520a7-6714-e78d-a8f7-68467dda6db7.binpack" = 1.209464
* Score "1b2520a7-6714-e78d-a8f7-68467dda6db7.job-anti-affinity" = -10.000000
==> Resources
CPU MemoryMB DiskMB IOPS
500 256 300 0
```
Nomad Node Status:
```
% nomad node-status 57b3a55a
ID = 57b3a55a
Name = biscuits
Class = <none>
DC = dc1
Drain = false
Status = ready
Attributes = arch:amd64, cpu.frequency:3753.458875, cpu.modelname:Intel(R) Core(TM) i7-4770K CPU @ 3.50GHz, cpu.numcores:8, cpu.totalcompute:30027.671000, driver.docker:1, driver.docker.version:1.10.2, driver.exec:1, driver.raw_exec:1, hostname:biscuits, kernel.name:linux, kernel.version:4.4.0-9-generic, memory.totalbytes:25208934400, os.name:ubuntu, os.version:16.04, unique.cgroup.mountpoint:/sys/fs/cgroup, unique.network.ip-address:127.0.0.1, unique.storage.bytesfree:219781419008, unique.storage.bytestotal:246059892736, unique.storage.volume:/dev/sdb3
==> Allocations
ID Eval ID Job ID Task Group Desired Status Client Status
2c236883 aa11aca8 example cache run running
32f6e3d6 aa11aca8 example cache run running
==> Resource Utilization
CPU MemoryMB DiskMB IOPS
1000 512 600 0
```
2016-03-05 02:29:39 +00:00
|
|
|
resources, err := getResources(client, node)
|
|
|
|
if err != nil {
|
|
|
|
c.Ui.Error(fmt.Sprintf("Error querying node resources: %s", err))
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
c.Ui.Output("\n==> Resource Utilization")
|
|
|
|
c.Ui.Output(formatList(resources))
|
2016-05-26 08:21:39 +00:00
|
|
|
if hostStats != nil {
|
2016-05-22 09:36:12 +00:00
|
|
|
c.Ui.Output("\n===> Node CPU Stats")
|
|
|
|
c.printCpuStats(hostStats)
|
|
|
|
c.Ui.Output("\n===> Node Memory Stats")
|
|
|
|
c.printMemoryStats(hostStats)
|
2016-05-22 10:46:49 +00:00
|
|
|
c.Ui.Output("\n===> Node Disk Stats")
|
|
|
|
c.printDiskStats(hostStats)
|
2016-05-22 09:04:27 +00:00
|
|
|
}
|
2016-03-21 00:30:33 +00:00
|
|
|
|
|
|
|
allocs, err := getAllocs(client, node, length)
|
|
|
|
if err != nil {
|
|
|
|
c.Ui.Error(fmt.Sprintf("Error querying node allocations: %s", err))
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(allocs) > 1 {
|
|
|
|
c.Ui.Output("\n==> Allocations")
|
|
|
|
c.Ui.Output(formatList(allocs))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if verbose {
|
|
|
|
// Print the attributes
|
|
|
|
keys := make([]string, len(node.Attributes))
|
|
|
|
for k := range node.Attributes {
|
|
|
|
keys = append(keys, k)
|
|
|
|
}
|
|
|
|
sort.Strings(keys)
|
|
|
|
|
|
|
|
var attributes []string
|
|
|
|
for _, k := range keys {
|
|
|
|
if k != "" {
|
|
|
|
attributes = append(attributes, fmt.Sprintf("%s|%s", k, node.Attributes[k]))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
c.Ui.Output("\n==> Attributes")
|
|
|
|
c.Ui.Output(formatKV(attributes))
|
2015-09-15 18:20:08 +00:00
|
|
|
}
|
2016-03-21 00:30:33 +00:00
|
|
|
|
2015-09-12 20:55:51 +00:00
|
|
|
return 0
|
|
|
|
}
|
2016-03-03 19:09:07 +00:00
|
|
|
|
2016-05-22 09:04:27 +00:00
|
|
|
func (c *NodeStatusCommand) printCpuStats(hostStats *api.HostStats) {
|
|
|
|
for _, cpuStat := range hostStats.CPU {
|
|
|
|
cpuStatsAttr := make([]string, 4)
|
|
|
|
cpuStatsAttr[0] = fmt.Sprintf("CPU|%v", cpuStat.CPU)
|
|
|
|
cpuStatsAttr[1] = fmt.Sprintf("User|%v", formatFloat64(cpuStat.User))
|
|
|
|
cpuStatsAttr[2] = fmt.Sprintf("System|%v", formatFloat64(cpuStat.System))
|
|
|
|
cpuStatsAttr[3] = fmt.Sprintf("Idle|%v", formatFloat64(cpuStat.Idle))
|
|
|
|
c.Ui.Output(formatKV(cpuStatsAttr))
|
|
|
|
c.Ui.Output("")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *NodeStatusCommand) printMemoryStats(hostStats *api.HostStats) {
|
|
|
|
memoryStat := hostStats.Memory
|
|
|
|
memStatsAttr := make([]string, 4)
|
|
|
|
memStatsAttr[0] = fmt.Sprintf("Total|%v", humanize.Bytes(memoryStat.Total))
|
|
|
|
memStatsAttr[1] = fmt.Sprintf("Available|%v", humanize.Bytes(memoryStat.Available))
|
|
|
|
memStatsAttr[2] = fmt.Sprintf("Used|%v", humanize.Bytes(memoryStat.Used))
|
|
|
|
memStatsAttr[3] = fmt.Sprintf("Free|%v", humanize.Bytes(memoryStat.Free))
|
|
|
|
c.Ui.Output(formatKV(memStatsAttr))
|
|
|
|
}
|
|
|
|
|
2016-05-22 10:46:49 +00:00
|
|
|
func (c *NodeStatusCommand) printDiskStats(hostStats *api.HostStats) {
|
|
|
|
for _, diskStat := range hostStats.DiskStats {
|
|
|
|
diskStatsAttr := make([]string, 7)
|
|
|
|
diskStatsAttr[0] = fmt.Sprintf("Device|%s", diskStat.Device)
|
|
|
|
diskStatsAttr[1] = fmt.Sprintf("MountPoint|%s", diskStat.Mountpoint)
|
|
|
|
diskStatsAttr[2] = fmt.Sprintf("Size|%s", humanize.Bytes(diskStat.Size))
|
|
|
|
diskStatsAttr[3] = fmt.Sprintf("Used|%s", humanize.Bytes(diskStat.Used))
|
|
|
|
diskStatsAttr[4] = fmt.Sprintf("Available|%s", humanize.Bytes(diskStat.Available))
|
|
|
|
diskStatsAttr[5] = fmt.Sprintf("Used Percent|%s", formatFloat64(diskStat.UsedPercent))
|
|
|
|
diskStatsAttr[6] = fmt.Sprintf("Inodes Percent|%s", formatFloat64(diskStat.InodesUsedPercent))
|
|
|
|
c.Ui.Output(formatKV(diskStatsAttr))
|
|
|
|
c.Ui.Output("")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Print resource usage w/ alloc-status + node-status
When alloc-status is called, in it's long form only, print the resource
utilization for that single allocation.
When node-status is called, in it's long form only, print the TOTAL
resource utilization that is occurring on that single node.
Nomad Alloc Status:
```
% nomad alloc-status 195d3bf2
ID = 195d3bf2
Eval ID = c917e3ee
Name = example.cache[1]
Node ID = 1b2520a7
Job ID = example
Client Status = running
Evaluated Nodes = 1
Filtered Nodes = 0
Exhausted Nodes = 0
Allocation Time = 17.73µs
Failures = 0
==> Task "redis" is "running"
Recent Events:
Time Type Description
04/03/16 21:20:45 EST Started Task started by client
04/03/16 21:20:42 EST Received Task received by client
==> Status
Allocation "195d3bf2" status "running" (0/1 nodes filtered)
* Score "1b2520a7-6714-e78d-a8f7-68467dda6db7.binpack" = 1.209464
* Score "1b2520a7-6714-e78d-a8f7-68467dda6db7.job-anti-affinity" = -10.000000
==> Resources
CPU MemoryMB DiskMB IOPS
500 256 300 0
```
Nomad Node Status:
```
% nomad node-status 57b3a55a
ID = 57b3a55a
Name = biscuits
Class = <none>
DC = dc1
Drain = false
Status = ready
Attributes = arch:amd64, cpu.frequency:3753.458875, cpu.modelname:Intel(R) Core(TM) i7-4770K CPU @ 3.50GHz, cpu.numcores:8, cpu.totalcompute:30027.671000, driver.docker:1, driver.docker.version:1.10.2, driver.exec:1, driver.raw_exec:1, hostname:biscuits, kernel.name:linux, kernel.version:4.4.0-9-generic, memory.totalbytes:25208934400, os.name:ubuntu, os.version:16.04, unique.cgroup.mountpoint:/sys/fs/cgroup, unique.network.ip-address:127.0.0.1, unique.storage.bytesfree:219781419008, unique.storage.bytestotal:246059892736, unique.storage.volume:/dev/sdb3
==> Allocations
ID Eval ID Job ID Task Group Desired Status Client Status
2c236883 aa11aca8 example cache run running
32f6e3d6 aa11aca8 example cache run running
==> Resource Utilization
CPU MemoryMB DiskMB IOPS
1000 512 600 0
```
2016-03-05 02:29:39 +00:00
|
|
|
// getRunningAllocs returns a slice of allocation id's running on the node
|
2016-03-05 03:14:57 +00:00
|
|
|
func getRunningAllocs(client *api.Client, nodeID string) ([]*api.Allocation, error) {
|
Print resource usage w/ alloc-status + node-status
When alloc-status is called, in it's long form only, print the resource
utilization for that single allocation.
When node-status is called, in it's long form only, print the TOTAL
resource utilization that is occurring on that single node.
Nomad Alloc Status:
```
% nomad alloc-status 195d3bf2
ID = 195d3bf2
Eval ID = c917e3ee
Name = example.cache[1]
Node ID = 1b2520a7
Job ID = example
Client Status = running
Evaluated Nodes = 1
Filtered Nodes = 0
Exhausted Nodes = 0
Allocation Time = 17.73µs
Failures = 0
==> Task "redis" is "running"
Recent Events:
Time Type Description
04/03/16 21:20:45 EST Started Task started by client
04/03/16 21:20:42 EST Received Task received by client
==> Status
Allocation "195d3bf2" status "running" (0/1 nodes filtered)
* Score "1b2520a7-6714-e78d-a8f7-68467dda6db7.binpack" = 1.209464
* Score "1b2520a7-6714-e78d-a8f7-68467dda6db7.job-anti-affinity" = -10.000000
==> Resources
CPU MemoryMB DiskMB IOPS
500 256 300 0
```
Nomad Node Status:
```
% nomad node-status 57b3a55a
ID = 57b3a55a
Name = biscuits
Class = <none>
DC = dc1
Drain = false
Status = ready
Attributes = arch:amd64, cpu.frequency:3753.458875, cpu.modelname:Intel(R) Core(TM) i7-4770K CPU @ 3.50GHz, cpu.numcores:8, cpu.totalcompute:30027.671000, driver.docker:1, driver.docker.version:1.10.2, driver.exec:1, driver.raw_exec:1, hostname:biscuits, kernel.name:linux, kernel.version:4.4.0-9-generic, memory.totalbytes:25208934400, os.name:ubuntu, os.version:16.04, unique.cgroup.mountpoint:/sys/fs/cgroup, unique.network.ip-address:127.0.0.1, unique.storage.bytesfree:219781419008, unique.storage.bytestotal:246059892736, unique.storage.volume:/dev/sdb3
==> Allocations
ID Eval ID Job ID Task Group Desired Status Client Status
2c236883 aa11aca8 example cache run running
32f6e3d6 aa11aca8 example cache run running
==> Resource Utilization
CPU MemoryMB DiskMB IOPS
1000 512 600 0
```
2016-03-05 02:29:39 +00:00
|
|
|
var allocs []*api.Allocation
|
|
|
|
|
|
|
|
// Query the node allocations
|
2016-03-05 03:14:57 +00:00
|
|
|
nodeAllocs, _, err := client.Nodes().Allocations(nodeID, nil)
|
Print resource usage w/ alloc-status + node-status
When alloc-status is called, in it's long form only, print the resource
utilization for that single allocation.
When node-status is called, in it's long form only, print the TOTAL
resource utilization that is occurring on that single node.
Nomad Alloc Status:
```
% nomad alloc-status 195d3bf2
ID = 195d3bf2
Eval ID = c917e3ee
Name = example.cache[1]
Node ID = 1b2520a7
Job ID = example
Client Status = running
Evaluated Nodes = 1
Filtered Nodes = 0
Exhausted Nodes = 0
Allocation Time = 17.73µs
Failures = 0
==> Task "redis" is "running"
Recent Events:
Time Type Description
04/03/16 21:20:45 EST Started Task started by client
04/03/16 21:20:42 EST Received Task received by client
==> Status
Allocation "195d3bf2" status "running" (0/1 nodes filtered)
* Score "1b2520a7-6714-e78d-a8f7-68467dda6db7.binpack" = 1.209464
* Score "1b2520a7-6714-e78d-a8f7-68467dda6db7.job-anti-affinity" = -10.000000
==> Resources
CPU MemoryMB DiskMB IOPS
500 256 300 0
```
Nomad Node Status:
```
% nomad node-status 57b3a55a
ID = 57b3a55a
Name = biscuits
Class = <none>
DC = dc1
Drain = false
Status = ready
Attributes = arch:amd64, cpu.frequency:3753.458875, cpu.modelname:Intel(R) Core(TM) i7-4770K CPU @ 3.50GHz, cpu.numcores:8, cpu.totalcompute:30027.671000, driver.docker:1, driver.docker.version:1.10.2, driver.exec:1, driver.raw_exec:1, hostname:biscuits, kernel.name:linux, kernel.version:4.4.0-9-generic, memory.totalbytes:25208934400, os.name:ubuntu, os.version:16.04, unique.cgroup.mountpoint:/sys/fs/cgroup, unique.network.ip-address:127.0.0.1, unique.storage.bytesfree:219781419008, unique.storage.bytestotal:246059892736, unique.storage.volume:/dev/sdb3
==> Allocations
ID Eval ID Job ID Task Group Desired Status Client Status
2c236883 aa11aca8 example cache run running
32f6e3d6 aa11aca8 example cache run running
==> Resource Utilization
CPU MemoryMB DiskMB IOPS
1000 512 600 0
```
2016-03-05 02:29:39 +00:00
|
|
|
// Filter list to only running allocations
|
|
|
|
for _, alloc := range nodeAllocs {
|
|
|
|
if alloc.ClientStatus == "running" {
|
|
|
|
allocs = append(allocs, alloc)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return allocs, err
|
|
|
|
}
|
|
|
|
|
|
|
|
// getAllocs returns information about every running allocation on the node
|
|
|
|
func getAllocs(client *api.Client, node *api.Node, length int) ([]string, error) {
|
|
|
|
var allocs []string
|
|
|
|
// Query the node allocations
|
|
|
|
nodeAllocs, _, err := client.Nodes().Allocations(node.ID, nil)
|
|
|
|
// Format the allocations
|
|
|
|
allocs = make([]string, len(nodeAllocs)+1)
|
|
|
|
allocs[0] = "ID|Eval ID|Job ID|Task Group|Desired Status|Client Status"
|
|
|
|
for i, alloc := range nodeAllocs {
|
|
|
|
allocs[i+1] = fmt.Sprintf("%s|%s|%s|%s|%s|%s",
|
|
|
|
limit(alloc.ID, length),
|
|
|
|
limit(alloc.EvalID, length),
|
|
|
|
alloc.JobID,
|
|
|
|
alloc.TaskGroup,
|
|
|
|
alloc.DesiredStatus,
|
|
|
|
alloc.ClientStatus)
|
|
|
|
}
|
|
|
|
return allocs, err
|
|
|
|
}
|
|
|
|
|
2016-03-21 00:30:33 +00:00
|
|
|
// getResources returns the resource usage of the node.
|
Print resource usage w/ alloc-status + node-status
When alloc-status is called, in it's long form only, print the resource
utilization for that single allocation.
When node-status is called, in it's long form only, print the TOTAL
resource utilization that is occurring on that single node.
Nomad Alloc Status:
```
% nomad alloc-status 195d3bf2
ID = 195d3bf2
Eval ID = c917e3ee
Name = example.cache[1]
Node ID = 1b2520a7
Job ID = example
Client Status = running
Evaluated Nodes = 1
Filtered Nodes = 0
Exhausted Nodes = 0
Allocation Time = 17.73µs
Failures = 0
==> Task "redis" is "running"
Recent Events:
Time Type Description
04/03/16 21:20:45 EST Started Task started by client
04/03/16 21:20:42 EST Received Task received by client
==> Status
Allocation "195d3bf2" status "running" (0/1 nodes filtered)
* Score "1b2520a7-6714-e78d-a8f7-68467dda6db7.binpack" = 1.209464
* Score "1b2520a7-6714-e78d-a8f7-68467dda6db7.job-anti-affinity" = -10.000000
==> Resources
CPU MemoryMB DiskMB IOPS
500 256 300 0
```
Nomad Node Status:
```
% nomad node-status 57b3a55a
ID = 57b3a55a
Name = biscuits
Class = <none>
DC = dc1
Drain = false
Status = ready
Attributes = arch:amd64, cpu.frequency:3753.458875, cpu.modelname:Intel(R) Core(TM) i7-4770K CPU @ 3.50GHz, cpu.numcores:8, cpu.totalcompute:30027.671000, driver.docker:1, driver.docker.version:1.10.2, driver.exec:1, driver.raw_exec:1, hostname:biscuits, kernel.name:linux, kernel.version:4.4.0-9-generic, memory.totalbytes:25208934400, os.name:ubuntu, os.version:16.04, unique.cgroup.mountpoint:/sys/fs/cgroup, unique.network.ip-address:127.0.0.1, unique.storage.bytesfree:219781419008, unique.storage.bytestotal:246059892736, unique.storage.volume:/dev/sdb3
==> Allocations
ID Eval ID Job ID Task Group Desired Status Client Status
2c236883 aa11aca8 example cache run running
32f6e3d6 aa11aca8 example cache run running
==> Resource Utilization
CPU MemoryMB DiskMB IOPS
1000 512 600 0
```
2016-03-05 02:29:39 +00:00
|
|
|
func getResources(client *api.Client, node *api.Node) ([]string, error) {
|
|
|
|
var resources []string
|
|
|
|
var cpu, mem, disk, iops int
|
2016-03-21 00:30:33 +00:00
|
|
|
var totalCpu, totalMem, totalDisk, totalIops int
|
|
|
|
|
|
|
|
// Compute the total
|
|
|
|
r := node.Resources
|
|
|
|
res := node.Reserved
|
2016-03-22 23:25:25 +00:00
|
|
|
if res == nil {
|
|
|
|
res = &api.Resources{}
|
|
|
|
}
|
2016-03-21 00:30:33 +00:00
|
|
|
totalCpu = r.CPU - res.CPU
|
|
|
|
totalMem = r.MemoryMB - res.MemoryMB
|
|
|
|
totalDisk = r.DiskMB - res.DiskMB
|
|
|
|
totalIops = r.IOPS - res.IOPS
|
Print resource usage w/ alloc-status + node-status
When alloc-status is called, in it's long form only, print the resource
utilization for that single allocation.
When node-status is called, in it's long form only, print the TOTAL
resource utilization that is occurring on that single node.
Nomad Alloc Status:
```
% nomad alloc-status 195d3bf2
ID = 195d3bf2
Eval ID = c917e3ee
Name = example.cache[1]
Node ID = 1b2520a7
Job ID = example
Client Status = running
Evaluated Nodes = 1
Filtered Nodes = 0
Exhausted Nodes = 0
Allocation Time = 17.73µs
Failures = 0
==> Task "redis" is "running"
Recent Events:
Time Type Description
04/03/16 21:20:45 EST Started Task started by client
04/03/16 21:20:42 EST Received Task received by client
==> Status
Allocation "195d3bf2" status "running" (0/1 nodes filtered)
* Score "1b2520a7-6714-e78d-a8f7-68467dda6db7.binpack" = 1.209464
* Score "1b2520a7-6714-e78d-a8f7-68467dda6db7.job-anti-affinity" = -10.000000
==> Resources
CPU MemoryMB DiskMB IOPS
500 256 300 0
```
Nomad Node Status:
```
% nomad node-status 57b3a55a
ID = 57b3a55a
Name = biscuits
Class = <none>
DC = dc1
Drain = false
Status = ready
Attributes = arch:amd64, cpu.frequency:3753.458875, cpu.modelname:Intel(R) Core(TM) i7-4770K CPU @ 3.50GHz, cpu.numcores:8, cpu.totalcompute:30027.671000, driver.docker:1, driver.docker.version:1.10.2, driver.exec:1, driver.raw_exec:1, hostname:biscuits, kernel.name:linux, kernel.version:4.4.0-9-generic, memory.totalbytes:25208934400, os.name:ubuntu, os.version:16.04, unique.cgroup.mountpoint:/sys/fs/cgroup, unique.network.ip-address:127.0.0.1, unique.storage.bytesfree:219781419008, unique.storage.bytestotal:246059892736, unique.storage.volume:/dev/sdb3
==> Allocations
ID Eval ID Job ID Task Group Desired Status Client Status
2c236883 aa11aca8 example cache run running
32f6e3d6 aa11aca8 example cache run running
==> Resource Utilization
CPU MemoryMB DiskMB IOPS
1000 512 600 0
```
2016-03-05 02:29:39 +00:00
|
|
|
|
|
|
|
// Get list of running allocations on the node
|
2016-03-05 03:14:57 +00:00
|
|
|
runningAllocs, err := getRunningAllocs(client, node.ID)
|
Print resource usage w/ alloc-status + node-status
When alloc-status is called, in it's long form only, print the resource
utilization for that single allocation.
When node-status is called, in it's long form only, print the TOTAL
resource utilization that is occurring on that single node.
Nomad Alloc Status:
```
% nomad alloc-status 195d3bf2
ID = 195d3bf2
Eval ID = c917e3ee
Name = example.cache[1]
Node ID = 1b2520a7
Job ID = example
Client Status = running
Evaluated Nodes = 1
Filtered Nodes = 0
Exhausted Nodes = 0
Allocation Time = 17.73µs
Failures = 0
==> Task "redis" is "running"
Recent Events:
Time Type Description
04/03/16 21:20:45 EST Started Task started by client
04/03/16 21:20:42 EST Received Task received by client
==> Status
Allocation "195d3bf2" status "running" (0/1 nodes filtered)
* Score "1b2520a7-6714-e78d-a8f7-68467dda6db7.binpack" = 1.209464
* Score "1b2520a7-6714-e78d-a8f7-68467dda6db7.job-anti-affinity" = -10.000000
==> Resources
CPU MemoryMB DiskMB IOPS
500 256 300 0
```
Nomad Node Status:
```
% nomad node-status 57b3a55a
ID = 57b3a55a
Name = biscuits
Class = <none>
DC = dc1
Drain = false
Status = ready
Attributes = arch:amd64, cpu.frequency:3753.458875, cpu.modelname:Intel(R) Core(TM) i7-4770K CPU @ 3.50GHz, cpu.numcores:8, cpu.totalcompute:30027.671000, driver.docker:1, driver.docker.version:1.10.2, driver.exec:1, driver.raw_exec:1, hostname:biscuits, kernel.name:linux, kernel.version:4.4.0-9-generic, memory.totalbytes:25208934400, os.name:ubuntu, os.version:16.04, unique.cgroup.mountpoint:/sys/fs/cgroup, unique.network.ip-address:127.0.0.1, unique.storage.bytesfree:219781419008, unique.storage.bytestotal:246059892736, unique.storage.volume:/dev/sdb3
==> Allocations
ID Eval ID Job ID Task Group Desired Status Client Status
2c236883 aa11aca8 example cache run running
32f6e3d6 aa11aca8 example cache run running
==> Resource Utilization
CPU MemoryMB DiskMB IOPS
1000 512 600 0
```
2016-03-05 02:29:39 +00:00
|
|
|
|
|
|
|
// Get Resources
|
|
|
|
for _, alloc := range runningAllocs {
|
|
|
|
cpu += alloc.Resources.CPU
|
|
|
|
mem += alloc.Resources.MemoryMB
|
|
|
|
disk += alloc.Resources.DiskMB
|
|
|
|
iops += alloc.Resources.IOPS
|
|
|
|
}
|
|
|
|
|
|
|
|
resources = make([]string, 2)
|
2016-03-05 03:14:57 +00:00
|
|
|
resources[0] = "CPU|Memory MB|Disk MB|IOPS"
|
2016-03-21 00:30:33 +00:00
|
|
|
resources[1] = fmt.Sprintf("%v/%v|%v/%v|%v/%v|%v/%v",
|
Print resource usage w/ alloc-status + node-status
When alloc-status is called, in it's long form only, print the resource
utilization for that single allocation.
When node-status is called, in it's long form only, print the TOTAL
resource utilization that is occurring on that single node.
Nomad Alloc Status:
```
% nomad alloc-status 195d3bf2
ID = 195d3bf2
Eval ID = c917e3ee
Name = example.cache[1]
Node ID = 1b2520a7
Job ID = example
Client Status = running
Evaluated Nodes = 1
Filtered Nodes = 0
Exhausted Nodes = 0
Allocation Time = 17.73µs
Failures = 0
==> Task "redis" is "running"
Recent Events:
Time Type Description
04/03/16 21:20:45 EST Started Task started by client
04/03/16 21:20:42 EST Received Task received by client
==> Status
Allocation "195d3bf2" status "running" (0/1 nodes filtered)
* Score "1b2520a7-6714-e78d-a8f7-68467dda6db7.binpack" = 1.209464
* Score "1b2520a7-6714-e78d-a8f7-68467dda6db7.job-anti-affinity" = -10.000000
==> Resources
CPU MemoryMB DiskMB IOPS
500 256 300 0
```
Nomad Node Status:
```
% nomad node-status 57b3a55a
ID = 57b3a55a
Name = biscuits
Class = <none>
DC = dc1
Drain = false
Status = ready
Attributes = arch:amd64, cpu.frequency:3753.458875, cpu.modelname:Intel(R) Core(TM) i7-4770K CPU @ 3.50GHz, cpu.numcores:8, cpu.totalcompute:30027.671000, driver.docker:1, driver.docker.version:1.10.2, driver.exec:1, driver.raw_exec:1, hostname:biscuits, kernel.name:linux, kernel.version:4.4.0-9-generic, memory.totalbytes:25208934400, os.name:ubuntu, os.version:16.04, unique.cgroup.mountpoint:/sys/fs/cgroup, unique.network.ip-address:127.0.0.1, unique.storage.bytesfree:219781419008, unique.storage.bytestotal:246059892736, unique.storage.volume:/dev/sdb3
==> Allocations
ID Eval ID Job ID Task Group Desired Status Client Status
2c236883 aa11aca8 example cache run running
32f6e3d6 aa11aca8 example cache run running
==> Resource Utilization
CPU MemoryMB DiskMB IOPS
1000 512 600 0
```
2016-03-05 02:29:39 +00:00
|
|
|
cpu,
|
2016-03-21 00:30:33 +00:00
|
|
|
totalCpu,
|
Print resource usage w/ alloc-status + node-status
When alloc-status is called, in it's long form only, print the resource
utilization for that single allocation.
When node-status is called, in it's long form only, print the TOTAL
resource utilization that is occurring on that single node.
Nomad Alloc Status:
```
% nomad alloc-status 195d3bf2
ID = 195d3bf2
Eval ID = c917e3ee
Name = example.cache[1]
Node ID = 1b2520a7
Job ID = example
Client Status = running
Evaluated Nodes = 1
Filtered Nodes = 0
Exhausted Nodes = 0
Allocation Time = 17.73µs
Failures = 0
==> Task "redis" is "running"
Recent Events:
Time Type Description
04/03/16 21:20:45 EST Started Task started by client
04/03/16 21:20:42 EST Received Task received by client
==> Status
Allocation "195d3bf2" status "running" (0/1 nodes filtered)
* Score "1b2520a7-6714-e78d-a8f7-68467dda6db7.binpack" = 1.209464
* Score "1b2520a7-6714-e78d-a8f7-68467dda6db7.job-anti-affinity" = -10.000000
==> Resources
CPU MemoryMB DiskMB IOPS
500 256 300 0
```
Nomad Node Status:
```
% nomad node-status 57b3a55a
ID = 57b3a55a
Name = biscuits
Class = <none>
DC = dc1
Drain = false
Status = ready
Attributes = arch:amd64, cpu.frequency:3753.458875, cpu.modelname:Intel(R) Core(TM) i7-4770K CPU @ 3.50GHz, cpu.numcores:8, cpu.totalcompute:30027.671000, driver.docker:1, driver.docker.version:1.10.2, driver.exec:1, driver.raw_exec:1, hostname:biscuits, kernel.name:linux, kernel.version:4.4.0-9-generic, memory.totalbytes:25208934400, os.name:ubuntu, os.version:16.04, unique.cgroup.mountpoint:/sys/fs/cgroup, unique.network.ip-address:127.0.0.1, unique.storage.bytesfree:219781419008, unique.storage.bytestotal:246059892736, unique.storage.volume:/dev/sdb3
==> Allocations
ID Eval ID Job ID Task Group Desired Status Client Status
2c236883 aa11aca8 example cache run running
32f6e3d6 aa11aca8 example cache run running
==> Resource Utilization
CPU MemoryMB DiskMB IOPS
1000 512 600 0
```
2016-03-05 02:29:39 +00:00
|
|
|
mem,
|
2016-03-21 00:30:33 +00:00
|
|
|
totalMem,
|
Print resource usage w/ alloc-status + node-status
When alloc-status is called, in it's long form only, print the resource
utilization for that single allocation.
When node-status is called, in it's long form only, print the TOTAL
resource utilization that is occurring on that single node.
Nomad Alloc Status:
```
% nomad alloc-status 195d3bf2
ID = 195d3bf2
Eval ID = c917e3ee
Name = example.cache[1]
Node ID = 1b2520a7
Job ID = example
Client Status = running
Evaluated Nodes = 1
Filtered Nodes = 0
Exhausted Nodes = 0
Allocation Time = 17.73µs
Failures = 0
==> Task "redis" is "running"
Recent Events:
Time Type Description
04/03/16 21:20:45 EST Started Task started by client
04/03/16 21:20:42 EST Received Task received by client
==> Status
Allocation "195d3bf2" status "running" (0/1 nodes filtered)
* Score "1b2520a7-6714-e78d-a8f7-68467dda6db7.binpack" = 1.209464
* Score "1b2520a7-6714-e78d-a8f7-68467dda6db7.job-anti-affinity" = -10.000000
==> Resources
CPU MemoryMB DiskMB IOPS
500 256 300 0
```
Nomad Node Status:
```
% nomad node-status 57b3a55a
ID = 57b3a55a
Name = biscuits
Class = <none>
DC = dc1
Drain = false
Status = ready
Attributes = arch:amd64, cpu.frequency:3753.458875, cpu.modelname:Intel(R) Core(TM) i7-4770K CPU @ 3.50GHz, cpu.numcores:8, cpu.totalcompute:30027.671000, driver.docker:1, driver.docker.version:1.10.2, driver.exec:1, driver.raw_exec:1, hostname:biscuits, kernel.name:linux, kernel.version:4.4.0-9-generic, memory.totalbytes:25208934400, os.name:ubuntu, os.version:16.04, unique.cgroup.mountpoint:/sys/fs/cgroup, unique.network.ip-address:127.0.0.1, unique.storage.bytesfree:219781419008, unique.storage.bytestotal:246059892736, unique.storage.volume:/dev/sdb3
==> Allocations
ID Eval ID Job ID Task Group Desired Status Client Status
2c236883 aa11aca8 example cache run running
32f6e3d6 aa11aca8 example cache run running
==> Resource Utilization
CPU MemoryMB DiskMB IOPS
1000 512 600 0
```
2016-03-05 02:29:39 +00:00
|
|
|
disk,
|
2016-03-21 00:30:33 +00:00
|
|
|
totalDisk,
|
|
|
|
iops,
|
|
|
|
totalIops)
|
Print resource usage w/ alloc-status + node-status
When alloc-status is called, in it's long form only, print the resource
utilization for that single allocation.
When node-status is called, in it's long form only, print the TOTAL
resource utilization that is occurring on that single node.
Nomad Alloc Status:
```
% nomad alloc-status 195d3bf2
ID = 195d3bf2
Eval ID = c917e3ee
Name = example.cache[1]
Node ID = 1b2520a7
Job ID = example
Client Status = running
Evaluated Nodes = 1
Filtered Nodes = 0
Exhausted Nodes = 0
Allocation Time = 17.73µs
Failures = 0
==> Task "redis" is "running"
Recent Events:
Time Type Description
04/03/16 21:20:45 EST Started Task started by client
04/03/16 21:20:42 EST Received Task received by client
==> Status
Allocation "195d3bf2" status "running" (0/1 nodes filtered)
* Score "1b2520a7-6714-e78d-a8f7-68467dda6db7.binpack" = 1.209464
* Score "1b2520a7-6714-e78d-a8f7-68467dda6db7.job-anti-affinity" = -10.000000
==> Resources
CPU MemoryMB DiskMB IOPS
500 256 300 0
```
Nomad Node Status:
```
% nomad node-status 57b3a55a
ID = 57b3a55a
Name = biscuits
Class = <none>
DC = dc1
Drain = false
Status = ready
Attributes = arch:amd64, cpu.frequency:3753.458875, cpu.modelname:Intel(R) Core(TM) i7-4770K CPU @ 3.50GHz, cpu.numcores:8, cpu.totalcompute:30027.671000, driver.docker:1, driver.docker.version:1.10.2, driver.exec:1, driver.raw_exec:1, hostname:biscuits, kernel.name:linux, kernel.version:4.4.0-9-generic, memory.totalbytes:25208934400, os.name:ubuntu, os.version:16.04, unique.cgroup.mountpoint:/sys/fs/cgroup, unique.network.ip-address:127.0.0.1, unique.storage.bytesfree:219781419008, unique.storage.bytestotal:246059892736, unique.storage.volume:/dev/sdb3
==> Allocations
ID Eval ID Job ID Task Group Desired Status Client Status
2c236883 aa11aca8 example cache run running
32f6e3d6 aa11aca8 example cache run running
==> Resource Utilization
CPU MemoryMB DiskMB IOPS
1000 512 600 0
```
2016-03-05 02:29:39 +00:00
|
|
|
|
|
|
|
return resources, err
|
|
|
|
}
|
2016-05-22 09:04:27 +00:00
|
|
|
|
|
|
|
func formatFloat64(val float64) string {
|
|
|
|
return strconv.FormatFloat(val, 'f', 2, 64)
|
|
|
|
}
|