mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-28 09:41:57 +00:00
ProcessPID: major=<name>, minor=<host> (<pid>)
This commit is contained in:
@@ -47,6 +47,6 @@ var topologyRegistry = map[string]struct {
|
||||
hasGrouped bool
|
||||
typ string
|
||||
}{
|
||||
"applications": {"Applications", selectProcess, report.ProcessName, true, "Process"},
|
||||
"applications": {"Applications", selectProcess, report.ProcessPID, true, "Process"},
|
||||
"hosts": {"Hosts", selectNetwork, report.NetworkHostname, false, "Network"},
|
||||
}
|
||||
|
||||
@@ -26,13 +26,14 @@ type MappedNode struct {
|
||||
type MapFunc func(string, NodeMetadata, bool) (MappedNode, bool)
|
||||
|
||||
// ProcessPID takes a node NodeMetadata from a Process topology, and returns a
|
||||
// representation based on the process PID.
|
||||
// representation with the ID based on the process PID and the labels based
|
||||
// on the process name.
|
||||
func ProcessPID(id string, m NodeMetadata, grouped bool) (MappedNode, bool) {
|
||||
var (
|
||||
domain = m["domain"]
|
||||
pid = m["pid"]
|
||||
name = m["name"]
|
||||
minor = fmt.Sprintf("%s (%s)", domain, name)
|
||||
minor = fmt.Sprintf("%s (%s)", domain, pid)
|
||||
)
|
||||
|
||||
if grouped {
|
||||
@@ -42,7 +43,7 @@ func ProcessPID(id string, m NodeMetadata, grouped bool) (MappedNode, bool) {
|
||||
|
||||
return MappedNode{
|
||||
ID: fmt.Sprintf("pid:%s:%s", domain, pid),
|
||||
Major: pid,
|
||||
Major: name,
|
||||
Minor: minor,
|
||||
Rank: pid,
|
||||
}, pid != ""
|
||||
|
||||
@@ -73,8 +73,8 @@ func TestMapping(t *testing.T) {
|
||||
},
|
||||
wantOK: true,
|
||||
wantID: "pid:hosta:42",
|
||||
wantMajor: "42",
|
||||
wantMinor: "hosta (curl)",
|
||||
wantMajor: "curl",
|
||||
wantMinor: "hosta (42)",
|
||||
wantRank: "42",
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user