1
0
mirror of https://github.com/google/gops.git synced 2024-11-27 08:31:17 +02:00
Commit Graph

45 Commits

Author SHA1 Message Date
Glib Smaga
9069aa4d19 Migrate gops to use spf13/cobra for command execution
Manual command setup was starting to show some strain in
terms of documentation and also adding new features
(regardless of what the protocol supports currently).

This new setup aims to make it easier to add new
documentation and functionality.

In comparison to the previous version, this increased the
binary size by 2.4M.
```
6.4M gops
4.0M gops_master
```
2022-08-30 14:31:29 +02:00
Glib Smaga
024cce5849 internal/cmd: Move code here from the main package 2022-08-30 14:31:29 +02:00
Tobias Klauser
9f8280461a Only report CPU percentage per period if period is > 0
The change in #154 lead to the CPU usage being reported for a 0s
duration:

cpu usage (0s):	NaN%

Fix this by only reporting CPU usage per period if the user specified a
positive duration.
2022-07-08 10:33:55 +02:00
Tobias Klauser
bf851ab3df Sort tree output by PPID
Otherwise the processes might appear in arbitrary order and
disassociated from their parent process. Also avoid printing a stray
newline after the tree.

Before:

```
...
├── 2493
│   └── 4952 (gops) {go1.18.1}
├── 1
│   └── 117 (com.docker.vmnetd) {go1.17.5}
├── 4405
│   └── 4416 (gopls) {go1.18.2}
└── 4404

```

After:

```
...
├── 1
│   └── 117 (com.docker.vmnetd) {go1.17.5}
├── 2493
│   └── 4945 (gops) {go1.18.3}
└── 4404
    └── 4405 (gopls) {go1.18.2}
        └── 4416 (gopls) {go1.18.2}
```
2022-06-24 22:54:34 +02:00
Elton SV
e6cb0303ad
Error out when the given duration is negative (#155)
Validate processInfo period & log a fatal error in the case of negative duration.
2021-11-10 14:15:35 +01:00
Tobias Klauser
8918f15c19 Allow to specify CPU usage period as duration string
The current implementation assumes the given duration in seconds.
Instead, also allow to specify a duration in the format as expected by
`time.ParseDuration` and use that if found. If a plain integer is
specified, it is still parsed as a duration in seconds.
2021-07-01 12:01:38 +02:00
Tobias Klauser
f870d0110a Restore CPU usage report format
Commit 78435f89 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%
2021-07-01 12:01:38 +02:00
村口大白鹅
78435f89d8
Support for reporting the percent of CPU time usage within given time (#143) 2021-04-17 13:14:45 -07:00
Tobias Klauser
9a13441a02 Switch to use github.com/shirou/gopsutil/v3
Use the properly versioned Go module github.com/shirou/gopsutil/v3
instead of github.com/shirou/gopsutil (which does not provide a go.mod
file).
2021-03-01 21:30:25 +01:00
Tobias Klauser
b55933ebc4 Use strings.Builder
It's been there since Go 1.10 and go.mod requires at least Go 1.12.
2020-11-03 13:47:01 +01:00
Tobias Klauser
d64b2d5ce7 Fix formatting for multiple of 24 hours
In case a process has been running for a multiple of 24 hours, the
process runtime will be formatted as DD-MM:SS instead of DD-HH:MM:SS.
Fix this and add a test for fmtEtimeDuration.
2020-11-03 13:47:01 +01:00
Tobias Klauser
ea7dd03981
Remove unnecessary type conversion (#105) 2020-05-14 22:03:09 +02:00
JBD
59c8be2ead
Improve the help text (#94)
Avoid using tabs, remove help from "subcommands" list,
don't differentiate the profiling commands from others.
2019-08-01 22:19:10 -07:00
Yash Ladha
036f72c5be Fix exit code if a valid cmd is passed (#91) 2019-03-27 10:35:05 -07:00
Pavlos Ratis
954ead6c72 add support for elapsed time (etime) (#80) 2019-03-20 14:59:55 -07:00
JBD
89672dbe3c fix out of bounds panic 2018-07-11 12:15:44 -07:00
Shi Han
e4108e7e73 address breaking changes from xlab/treeprint (#84)
A PR of xlab/treeprint (https://github.com/xlab/treeprint/pull/6)
which was merged might break gops in the future.
The PR removed treeprint.EdgeTypeStart. To set the root node,
we can now use SetValue(value Value) instead.

In this commit,

    dep ensure -update github.com/xlab/treeprint

was executed to update the library and then fix is applied.
2018-07-11 10:08:06 -07:00
Pavlos Ratis
48c083dd34 add command to display a process tree (#72)
Implemented a command, where users can list all running Go
processes in a tree-like format (like pstree).

Example:

$ gops tree
...
├── 13744
│   └── 71746 (gops) {go1.10}
├── 1
│   └── 13962 (gocode) {go1.9}
└── 557
    └── 635 (com.docker.supervisor) {go1.9.2}
        └── 638 (com.docker.driver.amd64-linux) {go1.9.2}
2018-03-10 19:43:39 -08:00
JBD
09ff00a4dd
Add process info (#59)
Example output:

$ gops <pid>
parent PID:	5985
threads:	27
memory usage:	0.199%
cpu usage:	0.139%
username:	jbd
cmd+args:	/Applications/Splice.app/Contents/Resources/Splice Helper.app/Contents/MacOS/Splice Helper -pid 5985
local/remote:	127.0.0.1:56765 <-> :0 (LISTEN)
local/remote:	127.0.0.1:56765 <-> 127.0.0.1:50955 (ESTABLISHED)
local/remote:	100.76.175.164:52353 <-> 54.241.191.232:443 (ESTABLISHED)

Fixes #58.
2018-02-27 19:41:44 -08:00
Nazri Ramliy
2209de1300 Add usage synopsis in help message (#64) 2017-11-23 18:41:11 -07:00
Daniel Fireman
ed4f1f24a6 Introducing support to debug.SetGCPercent. (#56)
* Introducing support to debug.SetGCPercent.

 Fixes #8

On my I needed to augment a little bit the communication
protocol to add support to optional parameters.
2017-10-06 17:50:40 -06:00
Jaana Burcu Dogan
57e77c5c37 agent indicator should be postfix 2017-09-04 23:05:17 -07:00
Jaana Burcu Dogan
a1c72eeaa8 shorthen devel build version string 2017-09-04 20:08:19 -07:00
Jaana Burcu Dogan
f0a29dc244 add PPID to the output 2017-09-04 18:49:17 -07:00
Jaana Burcu Dogan
bfd379ce45 goprocess: report info about a single process 2017-09-04 11:45:49 -07:00
JBD
414c940baf output better aligned results (#46)
Before the change, the output looked:
43819	gops	go1.9	/Users/jbd/bin/gops
20160	corp-ssh-helper	go1.8.1.typealias	/usr/local/bin/corp-ssh-helper
30492	dlv	go1.9	/Users/jbd/bin/dlv
31212	godoc	devel +990dac2723 Fri Jun 30 18:24:58 2017 +0000	/Users/jbd/bin/godoc
18579	mnp_logger	go1.7.1	/usr/local/bin/mnp_logger

After the change, it looks:
48071  gops            go1.9                                            /Users/jbd/bin/gops
31212  godoc           devel +990dac2723 Fri Jun 30 18:24:58 2017 +0000 /Users/jbd/bin/godoc
18579  mnp_logger      go1.7.1                                          /usr/local/bin/mnp_logger
20160  corp-ssh-helper go1.8.1.typealias                                /usr/local/bin/corp-ssh-helper
30492  dlv             go1.9                                            /Users/jbd/bin/dlv
44512  gocode          devel +990dac2723 Fri Jun 30 18:24:58 2017 +0000 /Users/jbd/bin/gocode
2017-09-01 18:43:29 -06:00
Jaana Burcu Dogan
5c0015f27d Export Go process reporting section as a package. 2017-08-28 19:33:06 -07:00
Jaana Burcu Dogan
112843115d report go build version 2017-08-26 14:47:02 -07:00
Nick K
288e543fee add remote mode support (#30) 2017-03-02 11:51:14 -08:00
Jaana Burcu Dogan
671bd43984 gops: add Go execution trace support 2017-01-20 13:10:54 -08:00
Jaana Burcu Dogan
3fe5c6c719 reorg the help text 2017-01-19 18:50:59 -08:00
Jaana Burcu Dogan
fa6968806c fix godoc 2017-01-19 18:43:31 -08:00
Jaana Burcu Dogan
218c61a1d3 gops: Stat pidfile to determine if agent is working
Fixes #27.
2017-01-19 18:37:32 -08:00
Jaana Burcu Dogan
290a9a1e3d gops: concurrently lookup for Go processes 2017-01-19 16:35:21 -08:00
Jaana Burcu Dogan
0e47ba961c rename vitals to stats 2017-01-03 01:15:13 -08:00
Jaana Burcu Dogan
6379e59497 Remove the -p flag.
Fixes #25.
2017-01-01 19:54:15 -08:00
kakilangit
edc722bd55 fix typo in README and usage (#18) 2016-11-20 13:16:04 -08:00
Alejandro Ramon Lopez del Huerto
282d5a56fb doc: improve README and update usage (#17) 2016-11-16 12:38:16 -08:00
Jaana Burcu Dogan
0d70d8989d indicate agent running processes with * 2016-11-13 23:26:37 -08:00
Jaana Burcu Dogan
40f925db08 fix usage text 2016-11-13 21:59:09 -08:00
Jaana Burcu Dogan
9423f02414 introduce pprof-* subcommands 2016-11-13 21:50:30 -08:00
Jaana Burcu Dogan
1c7ca3d7a5 show 'help' on usage text 2016-11-13 21:05:11 -08:00
Jaana Burcu Dogan
a0334e989c support cpu profile 2016-11-13 20:38:17 -08:00
Yasuhiro Matsumoto
d8ff5c67b7 ignore system process 2016-11-12 21:26:51 +09:00
Jaana Burcu Dogan
0f5d168dd7 rename files 2016-11-11 19:57:09 -08:00