diff options
-rwxr-xr-x | .gitignore | 3 | ||||
-rw-r--r-- | pkg/process/state.go | 7 | ||||
-rw-r--r-- | plugins/service/plugin.go | 2 | ||||
-rw-r--r-- | tools/worker_table.go | 6 |
4 files changed, 14 insertions, 4 deletions
@@ -25,4 +25,5 @@ vendor builds/ tests/vendor/ .rr-sample.yaml -cmd
\ No newline at end of file +cmd +rr diff --git a/pkg/process/state.go b/pkg/process/state.go index 462dd47e..652ec77c 100644 --- a/pkg/process/state.go +++ b/pkg/process/state.go @@ -24,7 +24,11 @@ type State struct { // Values might vary for different operating systems and based on RSS. MemoryUsage uint64 `json:"memoryUsage"` + // CPU_Percent returns how many percent of the CPU time this process uses CPUPercent float64 + + // Command used in the service plugin and shows a command for the particular service + Command string } // WorkerProcessState creates new worker state definition. @@ -51,7 +55,7 @@ func WorkerProcessState(w worker.BaseProcess) (State, error) { }, nil } -func GeneralProcessState(pid int) (State, error) { +func GeneralProcessState(pid int, command string) (State, error) { const op = errors.Op("process_state") p, _ := process.NewProcess(int32(pid)) i, err := p.MemoryInfo() @@ -67,5 +71,6 @@ func GeneralProcessState(pid int) (State, error) { CPUPercent: percent, Pid: pid, MemoryUsage: i.RSS, + Command: command, }, nil } diff --git a/plugins/service/plugin.go b/plugins/service/plugin.go index 91e47e86..b5608ff2 100644 --- a/plugins/service/plugin.go +++ b/plugins/service/plugin.go @@ -79,7 +79,7 @@ func (service *Plugin) Workers() []process.State { defer service.Unlock() states := make([]process.State, 0, len(service.processes)) for i := 0; i < len(service.processes); i++ { - st, err := process.GeneralProcessState(service.processes[i].Pid) + st, err := process.GeneralProcessState(service.processes[i].Pid, service.processes[i].rawCmd) if err != nil { continue } diff --git a/tools/worker_table.go b/tools/worker_table.go index 7887a478..4dd70d8e 100644 --- a/tools/worker_table.go +++ b/tools/worker_table.go @@ -39,16 +39,20 @@ func WorkerTable(writer io.Writer, workers []process.State) *tablewriter.Table { // ServiceWorkerTable renders table with information about rr server workers. func ServiceWorkerTable(writer io.Writer, workers []process.State) *tablewriter.Table { tw := tablewriter.NewWriter(writer) - tw.SetHeader([]string{"PID", "Memory", "CPU%"}) + tw.SetAutoWrapText(false) + tw.SetHeader([]string{"PID", "Memory", "CPU%", "Command"}) tw.SetColMinWidth(0, 7) tw.SetColMinWidth(1, 7) tw.SetColMinWidth(2, 7) + tw.SetColMinWidth(3, 18) + tw.SetAlignment(tablewriter.ALIGN_LEFT) for i := 0; i < len(workers); i++ { tw.Append([]string{ strconv.Itoa(workers[i].Pid), humanize.Bytes(workers[i].MemoryUsage), renderCPU(workers[i].CPUPercent), + workers[i].Command, }) } |