Merge pull request #710 from rjnagal/summary
Add memory-percent to ps output.
This commit is contained in:
commit
45a0cc2dc7
@ -171,14 +171,15 @@ type RequestOptions struct {
|
||||
}
|
||||
|
||||
type ProcessInfo struct {
|
||||
User string `json:"user"`
|
||||
Pid int `json:"pid"`
|
||||
Ppid int `json:"parent_pid"`
|
||||
StartTime string `json:"start_time"`
|
||||
PercentCpu string `json:"percent_cpu"`
|
||||
RSS string `json:"rss"`
|
||||
VirtualSize string `json:"virtual_size"`
|
||||
Status string `json:"status"`
|
||||
RunningTime string `json:"running_time"`
|
||||
Cmd string `json:"cmd"`
|
||||
User string `json:"user"`
|
||||
Pid int `json:"pid"`
|
||||
Ppid int `json:"parent_pid"`
|
||||
StartTime string `json:"start_time"`
|
||||
PercentCpu string `json:"percent_cpu"`
|
||||
PercentMemory string `json:"percent_mem"`
|
||||
RSS string `json:"rss"`
|
||||
VirtualSize string `json:"virtual_size"`
|
||||
Status string `json:"status"`
|
||||
RunningTime string `json:"running_time"`
|
||||
Cmd string `json:"cmd"`
|
||||
}
|
||||
|
@ -130,9 +130,9 @@ func (c *containerData) GetProcessList() ([]v2.ProcessInfo, error) {
|
||||
}
|
||||
}
|
||||
// TODO(rjnagal): Take format as an option?
|
||||
format := "user,pid,ppid,stime,pcpu,rss,vsz,stat,time,comm"
|
||||
format := "user,pid,ppid,stime,pcpu,pmem,rss,vsz,stat,time,comm"
|
||||
args := []string{"-e", "-o", format}
|
||||
expectedFields := 10
|
||||
expectedFields := 11
|
||||
out, err := exec.Command("ps", args...).Output()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to execute ps command: %v", err)
|
||||
@ -157,16 +157,17 @@ func (c *containerData) GetProcessList() ([]v2.ProcessInfo, error) {
|
||||
}
|
||||
if isRoot || pidMap[pid] == true {
|
||||
processes = append(processes, v2.ProcessInfo{
|
||||
User: fields[0],
|
||||
Pid: pid,
|
||||
Ppid: ppid,
|
||||
StartTime: fields[3],
|
||||
PercentCpu: fields[4],
|
||||
RSS: fields[5],
|
||||
VirtualSize: fields[6],
|
||||
Status: fields[7],
|
||||
RunningTime: fields[8],
|
||||
Cmd: strings.Join(fields[9:], " "),
|
||||
User: fields[0],
|
||||
Pid: pid,
|
||||
Ppid: ppid,
|
||||
StartTime: fields[3],
|
||||
PercentCpu: fields[4],
|
||||
PercentMemory: fields[5],
|
||||
RSS: fields[6],
|
||||
VirtualSize: fields[7],
|
||||
Status: fields[8],
|
||||
RunningTime: fields[9],
|
||||
Cmd: strings.Join(fields[10:], " "),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -427,8 +427,8 @@ function drawFileSystemUsage(machineInfo, stats) {
|
||||
}
|
||||
|
||||
function drawProcesses(processInfo) {
|
||||
var titles = ["User", "PID", "PPID", "Start Time", "CPU %", "RSS", "Virtual Size", "Status", "Running Time", "Command"];
|
||||
var titleTypes = ['string', 'number', 'number', 'string', 'string', 'string', 'string', 'string', 'string', 'string'];
|
||||
var titles = ["User", "PID", "PPID", "Start Time", "CPU %", "MEM %", "RSS", "Virtual Size", "Status", "Running Time", "Command"];
|
||||
var titleTypes = ['string', 'number', 'number', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string'];
|
||||
var data = []
|
||||
for (var i = 1; i < processInfo.length; i++) {
|
||||
var elements = [];
|
||||
@ -437,6 +437,7 @@ function drawProcesses(processInfo) {
|
||||
elements.push(processInfo[i].parent_pid);
|
||||
elements.push(processInfo[i].start_time);
|
||||
elements.push(processInfo[i].percent_cpu);
|
||||
elements.push(processInfo[i].percent_mem);
|
||||
elements.push(processInfo[i].rss);
|
||||
elements.push(processInfo[i].virtual_size);
|
||||
elements.push(processInfo[i].status);
|
||||
|
Loading…
Reference in New Issue
Block a user