ProcessPID: major=<name>, minor=<host> (<pid>)

This commit is contained in:
Peter Bourgon
2015-05-20 10:04:44 +02:00
parent 59588e721d
commit 3e9ef67485
3 changed files with 7 additions and 6 deletions

View File

@@ -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"},
}

View File

@@ -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 != ""

View File

@@ -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",
},
{