Skip to content

Commit

Permalink
Add psr option when ps containers
Browse files Browse the repository at this point in the history
  • Loading branch information
mJace committed May 27, 2020
1 parent 107e5aa commit 52f9cd9
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 84 deletions.
5 changes: 3 additions & 2 deletions cmd/internal/pages/assets/js/containers.js
Original file line number Diff line number Diff line change
Expand Up @@ -606,11 +606,11 @@ function drawProcesses(isRoot, rootDir, processInfo) {
}
var titles = [
'User', 'PID', 'PPID', 'Start Time', 'CPU %', 'MEM %', 'RSS',
'Virtual Size', 'Status', 'Running Time', 'Command'
'Virtual Size', 'Status', 'Running Time', 'Command', 'PSR'
];
var titleTypes = [
'string', 'number', 'number', 'string', 'number', 'number', 'number',
'number', 'string', 'string', 'string'
'number', 'string', 'string', 'string', 'number'
];
var sortIndex = 4;
if (isRoot) {
Expand Down Expand Up @@ -647,6 +647,7 @@ function drawProcesses(isRoot, rootDir, processInfo) {
cgroup.substr(0, 30) + ' </a>';
elements.push({v: cgroup, f: cgroupLink});
}
elements.push(processInfo[i].psr);
data.push(elements);
}
drawTable(titles, titleTypes, data, 'processes-top', 25, sortIndex);
Expand Down
122 changes: 43 additions & 79 deletions cmd/internal/pages/static/assets.go

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions info/v2/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ type ProcessInfo struct {
CgroupPath string `json:"cgroup_path"`
Cmd string `json:"cmd"`
FdCount int `json:"fd_count"`
Psr int `json:"psr"`
}

type TcpStat struct {
Expand Down
12 changes: 9 additions & 3 deletions manager/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,12 +286,12 @@ func (cd *containerData) GetProcessList(cadvisorContainer string, inHostNamespac
if !inHostNamespace {
rootfs = "/rootfs"
}
format := "user,pid,ppid,stime,pcpu,pmem,rss,vsz,stat,time,comm,cgroup"
format := "user,pid,ppid,stime,pcpu,pmem,rss,vsz,stat,time,comm,psr,cgroup"
out, err := cd.getPsOutput(inHostNamespace, format)
if err != nil {
return nil, err
}
expectedFields := 12
expectedFields := 13
processes := []v2.ProcessInfo{}
lines := strings.Split(string(out), "\n")
for _, line := range lines[1:] {
Expand Down Expand Up @@ -330,7 +330,12 @@ func (cd *containerData) GetProcessList(cadvisorContainer string, inHostNamespac
}
// convert to bytes
vs *= 1024
cgroup, err := cd.getCgroupPath(fields[11])
psr, err := strconv.Atoi(fields[11])
if err != nil {
return nil, fmt.Errorf("invalid pid %q: %v", fields[1], err)
}

cgroup, err := cd.getCgroupPath(fields[12])
if err != nil {
return nil, fmt.Errorf("could not parse cgroup path from %q: %v", fields[11], err)
}
Expand Down Expand Up @@ -368,6 +373,7 @@ func (cd *containerData) GetProcessList(cadvisorContainer string, inHostNamespac
Cmd: fields[10],
CgroupPath: cgroupPath,
FdCount: fdCount,
Psr: psr,
})
}
}
Expand Down

0 comments on commit 52f9cd9

Please sign in to comment.