Add process information to the UI.

For root, we report all processes. Process stats are refreshed every minute.
This commit is contained in:
Rohit Jnagal 2015-05-12 19:08:12 +00:00
parent d61a381e84
commit 2a99748874
4 changed files with 1470 additions and 1386 deletions

View File

@ -117,13 +117,17 @@ func (c *containerData) DerivedStats() (v2.DerivedStats, error) {
} }
func (c *containerData) GetProcessList() ([]v2.ProcessInfo, error) { func (c *containerData) GetProcessList() ([]v2.ProcessInfo, error) {
pids, err := c.handler.ListProcesses(container.ListSelf) // report all processes for root.
if err != nil { isRoot := c.info.Name == "/"
return nil, err
}
pidMap := map[int]bool{} pidMap := map[int]bool{}
for _, pid := range pids { if !isRoot {
pidMap[pid] = true pids, err := c.handler.ListProcesses(container.ListSelf)
if err != nil {
return nil, err
}
for _, pid := range pids {
pidMap[pid] = true
}
} }
// 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,rss,vsz,stat,time,comm"
@ -151,7 +155,7 @@ func (c *containerData) GetProcessList() ([]v2.ProcessInfo, error) {
if err != nil { if err != nil {
return nil, fmt.Errorf("invalid ppid %q: %v", fields[2], err) return nil, fmt.Errorf("invalid ppid %q: %v", fields[2], err)
} }
if pidMap[pid] == true { if isRoot || pidMap[pid] == true {
processes = append(processes, v2.ProcessInfo{ processes = append(processes, v2.ProcessInfo{
User: fields[0], User: fields[0],
Pid: pid, Pid: pid,

View File

@ -108,6 +108,12 @@ const containersHtmlTemplate = `
</div> </div>
<div id="usage-gauge" class="panel-body"></div> <div id="usage-gauge" class="panel-body"></div>
</div> </div>
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">Processes</h3>
</div>
<div id="processes-top" class="panel-body"></div>
</div>
{{if .CpuAvailable}} {{if .CpuAvailable}}
<div class="panel panel-primary"> <div class="panel panel-primary">
<div class="panel-heading"> <div class="panel-heading">

File diff suppressed because it is too large Load Diff

1395
pages/static/gcharts_js.go Normal file

File diff suppressed because it is too large Load Diff