Add memory-percent to ps output.
This commit is contained in:
parent
2a99748874
commit
3bcae7f430
@ -173,6 +173,7 @@ type ProcessInfo struct {
|
|||||||
Ppid int `json:"parent_pid"`
|
Ppid int `json:"parent_pid"`
|
||||||
StartTime string `json:"start_time"`
|
StartTime string `json:"start_time"`
|
||||||
PercentCpu string `json:"percent_cpu"`
|
PercentCpu string `json:"percent_cpu"`
|
||||||
|
PercentMemory string `json:"percent_mem"`
|
||||||
RSS string `json:"rss"`
|
RSS string `json:"rss"`
|
||||||
VirtualSize string `json:"virtual_size"`
|
VirtualSize string `json:"virtual_size"`
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
|
@ -130,9 +130,9 @@ func (c *containerData) GetProcessList() ([]v2.ProcessInfo, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO(rjnagal): Take format as an option?
|
// 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}
|
args := []string{"-e", "-o", format}
|
||||||
expectedFields := 10
|
expectedFields := 11
|
||||||
out, err := exec.Command("ps", args...).Output()
|
out, err := exec.Command("ps", args...).Output()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to execute ps command: %v", err)
|
return nil, fmt.Errorf("failed to execute ps command: %v", err)
|
||||||
@ -162,11 +162,12 @@ func (c *containerData) GetProcessList() ([]v2.ProcessInfo, error) {
|
|||||||
Ppid: ppid,
|
Ppid: ppid,
|
||||||
StartTime: fields[3],
|
StartTime: fields[3],
|
||||||
PercentCpu: fields[4],
|
PercentCpu: fields[4],
|
||||||
RSS: fields[5],
|
PercentMemory: fields[5],
|
||||||
VirtualSize: fields[6],
|
RSS: fields[6],
|
||||||
Status: fields[7],
|
VirtualSize: fields[7],
|
||||||
RunningTime: fields[8],
|
Status: fields[8],
|
||||||
Cmd: strings.Join(fields[9:], " "),
|
RunningTime: fields[9],
|
||||||
|
Cmd: strings.Join(fields[10:], " "),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -427,8 +427,8 @@ function drawFileSystemUsage(machineInfo, stats) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function drawProcesses(processInfo) {
|
function drawProcesses(processInfo) {
|
||||||
var titles = ["User", "PID", "PPID", "Start Time", "CPU %", "RSS", "Virtual Size", "Status", "Running Time", "Command"];
|
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'];
|
var titleTypes = ['string', 'number', 'number', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string'];
|
||||||
var data = []
|
var data = []
|
||||||
for (var i = 1; i < processInfo.length; i++) {
|
for (var i = 1; i < processInfo.length; i++) {
|
||||||
var elements = [];
|
var elements = [];
|
||||||
@ -437,6 +437,7 @@ function drawProcesses(processInfo) {
|
|||||||
elements.push(processInfo[i].parent_pid);
|
elements.push(processInfo[i].parent_pid);
|
||||||
elements.push(processInfo[i].start_time);
|
elements.push(processInfo[i].start_time);
|
||||||
elements.push(processInfo[i].percent_cpu);
|
elements.push(processInfo[i].percent_cpu);
|
||||||
|
elements.push(processInfo[i].percent_mem);
|
||||||
elements.push(processInfo[i].rss);
|
elements.push(processInfo[i].rss);
|
||||||
elements.push(processInfo[i].virtual_size);
|
elements.push(processInfo[i].virtual_size);
|
||||||
elements.push(processInfo[i].status);
|
elements.push(processInfo[i].status);
|
||||||
|
Loading…
Reference in New Issue
Block a user