Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Treat pid as numeric and sort by #containers #1125

Merged
merged 1 commit into from
Mar 4, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions render/detailed/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (

var (
processNodeMetadata = []MetadataRowTemplate{
Latest{ID: process.PID, Prime: true},
Latest{ID: process.PID, Prime: true, Datatype: number},
Latest{ID: process.Cmdline, Prime: true},
Latest{ID: process.PPID, Prime: true},
Latest{ID: process.Threads, Prime: true},
Expand Down Expand Up @@ -63,6 +63,7 @@ type Latest struct {
ID string
Truncate int // If > 0, truncate the value to this length.
Prime bool // Whether the row should be shown by default
Datatype string
}

// MetadataRows implements MetadataRowTemplate
Expand All @@ -71,7 +72,7 @@ func (l Latest) MetadataRows(n report.Node) []MetadataRow {
if l.Truncate > 0 && len(val) > l.Truncate {
val = val[:l.Truncate]
}
return []MetadataRow{{ID: l.ID, Value: val, Prime: l.Prime}}
return []MetadataRow{{ID: l.ID, Value: val, Prime: l.Prime, Datatype: l.Datatype}}
}
return nil
}
Expand Down
62 changes: 49 additions & 13 deletions render/detailed/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,19 +139,55 @@ var (
topologyID string
NodeSummaryGroup
}{
{report.Host, NodeSummaryGroup{TopologyID: "hosts", Label: "Hosts", Columns: []Column{
MakeColumn(host.CPUUsage), MakeColumn(host.MemoryUsage),
}}},
{report.Pod, NodeSummaryGroup{TopologyID: "pods", Label: "Pods"}},
{report.Container, NodeSummaryGroup{TopologyID: "containers", Label: "Containers", Columns: []Column{
MakeColumn(docker.CPUTotalUsage), MakeColumn(docker.MemoryUsage),
}}},
{report.Process, NodeSummaryGroup{TopologyID: "processes", Label: "Processes", Columns: []Column{
MakeColumn(process.PID), MakeColumn(process.CPUUsage), MakeColumn(process.MemoryUsage),
}}},
{report.ContainerImage, NodeSummaryGroup{TopologyID: "containers-by-image", Label: "Container Images", Columns: []Column{
MakeColumn(render.ContainersKey),
}}},
{
topologyID: report.Host,
NodeSummaryGroup: NodeSummaryGroup{
TopologyID: "hosts",
Label: "Hosts",
Columns: []Column{
MakeColumn(host.CPUUsage),
MakeColumn(host.MemoryUsage),
},
},
},
{
topologyID: report.Pod,
NodeSummaryGroup: NodeSummaryGroup{
TopologyID: "pods",
Label: "Pods",
},
},
{
topologyID: report.Container,
NodeSummaryGroup: NodeSummaryGroup{
TopologyID: "containers",
Label: "Containers", Columns: []Column{
MakeColumn(docker.CPUTotalUsage),
MakeColumn(docker.MemoryUsage),
},
},
},
{
topologyID: report.Process,
NodeSummaryGroup: NodeSummaryGroup{
TopologyID: "processes",
Label: "Processes", Columns: []Column{
{ID: process.PID, Label: Label(process.PID)},
MakeColumn(process.CPUUsage),
MakeColumn(process.MemoryUsage),
},
},
},
{
topologyID: report.ContainerImage,
NodeSummaryGroup: NodeSummaryGroup{
TopologyID: "containers-by-image",
Label: "Container Images",
Columns: []Column{
{ID: render.ContainersKey, Label: Label(render.ContainersKey), DefaultSort: true},
},
},
},
}
)

Expand Down
8 changes: 5 additions & 3 deletions render/detailed/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,10 @@ func TestMakeDetailedHostNode(t *testing.T) {
{
Label: "Container Images",
TopologyID: "containers-by-image",
Columns: []detailed.Column{detailed.MakeColumn(render.ContainersKey)},
Nodes: []detailed.NodeSummary{containerImageNodeSummary},
Columns: []detailed.Column{
{ID: render.ContainersKey, Label: detailed.Label(render.ContainersKey), DefaultSort: true},
},
Nodes: []detailed.NodeSummary{containerImageNodeSummary},
},
},
Connections: []detailed.NodeSummaryGroup{
Expand Down Expand Up @@ -201,7 +203,7 @@ func TestMakeDetailedContainerNode(t *testing.T) {
Label: "apache",
Linkable: true,
Metadata: []detailed.MetadataRow{
{ID: process.PID, Value: fixture.ServerPID, Prime: true},
{ID: process.PID, Value: fixture.ServerPID, Prime: true, Datatype: "number"},
},
Metrics: []detailed.MetricRow{},
},
Expand Down