Skip to content

Commit f870d01

Browse files
committed
Restore CPU usage report format
Commit 78435f8 changed the existing output format for the CPU usage from `cpu usage:` to `cpu usage (all):`. This might break existing scripts relying on this format. Revert that part of the change and only report the CPU usage for the given period with a suffix: cpu usage: 0.087% cpu usage (1s): 1.42%
1 parent 48d3575 commit f870d01

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

README.md

+11-13
Original file line numberDiff line numberDiff line change
@@ -79,23 +79,21 @@ The output displays:
7979

8080
Note that processes running the agent are marked with `*` next to the PID (e.g. `4132*`).
8181

82-
#### $ gops \<pid\> [seconds]
82+
#### $ gops \<pid\>
8383

84-
To report more information about a process, run `gops` following by a PID:
85-
> If set the seconds arg, the percent of the CPU time this process uses within given time duration will be reported.
84+
To report more information about a process, run `gops` followed by a PID:
8685

8786
```sh
8887
$ gops <pid>
89-
parent PID: 5985
90-
threads: 27
91-
memory usage: 0.199%
92-
cpu usage(all): 0.139%
93-
cpu usage(1s): 19.5% # if seconds provided
94-
username: jbd
95-
cmd+args: /Applications/Splice.app/Contents/Resources/Splice Helper.app/Contents/MacOS/Splice Helper -pid 5985
96-
local/remote: 127.0.0.1:56765 <-> :0 (LISTEN)
97-
local/remote: 127.0.0.1:56765 <-> 127.0.0.1:50955 (ESTABLISHED)
98-
local/remote: 100.76.175.164:52353 <-> 54.241.191.232:443 (ESTABLISHED)
88+
parent PID: 5985
89+
threads: 27
90+
memory usage: 0.199%
91+
cpu usage: 0.139%
92+
username: jbd
93+
cmd+args: /Applications/Splice.app/Contents/Resources/Splice Helper.app/Contents/MacOS/Splice Helper -pid 5985
94+
local/remote: 127.0.0.1:56765 <-> :0 (LISTEN)
95+
local/remote: 127.0.0.1:56765 <-> 127.0.0.1:50955 (ESTABLISHED)
96+
local/remote: 100.76.175.164:52353 <-> 54.241.191.232:443 (ESTABLISHED)
9997
```
10098

10199
#### $ gops tree

main.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,11 @@ func processInfo(pid, interval int) {
146146
fmt.Printf("memory usage:\t%.3f%%\n", v)
147147
}
148148
if v, err := p.CPUPercent(); err == nil {
149-
fmt.Printf("cpu usage(all):\t%.3f%%\n", v)
149+
fmt.Printf("cpu usage:\t%.3f%%\n", v)
150150
}
151151
if interval > 0 {
152152
if v, err := cpuPercentWithinTime(p, time.Second*time.Duration(interval)); err == nil {
153-
fmt.Printf("cpu usage(%ds):\t%.3f%%\n", interval, v)
153+
fmt.Printf("cpu usage (%ds):\t%.3f%%\n", interval, v)
154154
}
155155
}
156156
if v, err := p.Username(); err == nil {

0 commit comments

Comments
 (0)