From d928d02d85c24ce3293d8187c7190c5da3721641 Mon Sep 17 00:00:00 2001 From: Diptanu Choudhury Date: Fri, 3 Jun 2016 06:57:05 -0700 Subject: [PATCH] Removing inode percent since it doesn't work in some cases --- api/nodes.go | 13 ++++++------- client/client.go | 1 - client/stats/host.go | 26 ++++++++++++-------------- command/node_status.go | 13 +++++++------ 4 files changed, 25 insertions(+), 28 deletions(-) diff --git a/api/nodes.go b/api/nodes.go index 5ed88d6b0..b4edb585a 100644 --- a/api/nodes.go +++ b/api/nodes.go @@ -139,13 +139,12 @@ type HostCPUStats struct { } type HostDiskStats struct { - Device string - Mountpoint string - Size uint64 - Used uint64 - Available uint64 - UsedPercent float64 - InodesUsedPercent float64 + Device string + Mountpoint string + Size uint64 + Used uint64 + Available uint64 + UsedPercent float64 } // NodeListStub is a subset of information returned during diff --git a/client/client.go b/client/client.go index 531bc0f81..0ac2c631b 100644 --- a/client/client.go +++ b/client/client.go @@ -1370,6 +1370,5 @@ func (c *Client) emitStats(hStats *stats.HostStats) { metrics.EmitKey([]string{"disk", disk.Device, "used"}, float32(disk.Used)) metrics.EmitKey([]string{"disk", disk.Device, "available"}, float32(disk.Available)) metrics.EmitKey([]string{"disk", disk.Device, "used_percent"}, float32(disk.UsedPercent)) - metrics.EmitKey([]string{"disk", disk.Device, "inodes_percent"}, float32(disk.InodesUsedPercent)) } } diff --git a/client/stats/host.go b/client/stats/host.go index a14126f35..f800c72ac 100644 --- a/client/stats/host.go +++ b/client/stats/host.go @@ -37,13 +37,12 @@ type CPUStats struct { // DiskStats represents stats related to disk usage type DiskStats struct { - Device string - Mountpoint string - Size uint64 - Used uint64 - Available uint64 - UsedPercent float64 - InodesUsedPercent float64 + Device string + Mountpoint string + Size uint64 + Used uint64 + Available uint64 + UsedPercent float64 } // HostStatsCollector collects host resource usage stats @@ -98,13 +97,12 @@ func (h *HostStatsCollector) Collect() (*HostStats, error) { for _, partition := range partitions { if usage, err := disk.Usage(partition.Mountpoint); err == nil { ds := DiskStats{ - Device: partition.Device, - Mountpoint: partition.Mountpoint, - Size: usage.Total, - Used: usage.Used, - Available: usage.Free, - UsedPercent: usage.UsedPercent, - InodesUsedPercent: usage.InodesUsedPercent, + Device: partition.Device, + Mountpoint: partition.Mountpoint, + Size: usage.Total, + Used: usage.Used, + Available: usage.Free, + UsedPercent: usage.UsedPercent, } diskStats = append(diskStats, &ds) } diff --git a/command/node_status.go b/command/node_status.go index 05a5c3866..006480f7b 100644 --- a/command/node_status.go +++ b/command/node_status.go @@ -8,12 +8,14 @@ import ( "time" "github.com/dustin/go-humanize" + "github.com/mitchellh/colorstring" "github.com/hashicorp/nomad/api" ) type NodeStatusCommand struct { Meta + color *colorstring.Colorize } func (c *NodeStatusCommand) Help() string { @@ -199,12 +201,12 @@ func (c *NodeStatusCommand) Run(args []string) int { } if hostStats, err = client.Nodes().Stats(node.ID, nil); err != nil { - c.Ui.Error(fmt.Sprintf("error fetching node resource utilization stats: %v", err)) + c.Ui.Error(fmt.Sprintf("error fetching node resource utilization stats: %#v", err)) } // Format the output basic := []string{ - fmt.Sprintf("ID|%s", limit(node.ID, length)), + fmt.Sprintf("[bold]Node ID[reset]|%s", limit(node.ID, length)), fmt.Sprintf("Name|%s", node.Name), fmt.Sprintf("Class|%s", node.NodeClass), fmt.Sprintf("DC|%s", node.Datacenter), @@ -215,7 +217,7 @@ func (c *NodeStatusCommand) Run(args []string) int { uptime := time.Duration(hostStats.Uptime * uint64(time.Second)) basic = append(basic, fmt.Sprintf("Uptime|%s", uptime.String())) } - c.Ui.Output(formatKV(basic)) + c.Ui.Output(c.Colorize().Color(formatKV(basic))) if !short { resources, err := getResources(client, node) @@ -223,7 +225,7 @@ func (c *NodeStatusCommand) Run(args []string) int { c.Ui.Error(fmt.Sprintf("Error querying node resources: %s", err)) return 1 } - c.Ui.Output("\n==> Resource Utilization") + c.Ui.Output(c.Colorize().Color("\n[bold]==> Resource Utilization (Actual)[reset]")) c.Ui.Output(formatList(resources)) if hostStats != nil { c.Ui.Output("\n===> Node CPU Stats") @@ -291,14 +293,13 @@ func (c *NodeStatusCommand) printMemoryStats(hostStats *api.HostStats) { func (c *NodeStatusCommand) printDiskStats(hostStats *api.HostStats) { for _, diskStat := range hostStats.DiskStats { - diskStatsAttr := make([]string, 7) + diskStatsAttr := make([]string, 6) 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("") }