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

202 Commits

Author SHA1 Message Date
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
Tobias Klauser
14e2449428
internal: remove getOSUserConfigDir fallback for Go ≤ 1.13 (#170) 2022-06-24 05:13:01 -07:00
Tobias Klauser
35533050c7 go.mod, vendor: update dependencies
Update direct dependencies to the following versions:

- github.com/shirou/gopsutil/v3 v3.22.4
- golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a
2022-05-30 14:10:58 +02:00
Tobias Klauser
72a03a3c85
Bump minimum Go version to 1.13 (#169) 2022-05-30 03:03:16 -07:00
Tobias Klauser
33938f8089 Remove CircleCI
CircleCI tests currently seem fail consistently. GitHub actions
introduced in #136 are providing the same coverage (and more), have been
running stable for over a year and are easier to maintain. Thus, remove
Circle CI integration.

Ref. https://github.com/google/gops/pull/136#issuecomment-786529797
2022-05-04 23:47:46 +02:00
Tobias Klauser
53ee352cc8 goprocess: use debug/buildinfo on Go 1.18 and newer
Use package debug/buildinfo [1] introduced in Go 1.18 [2] when possible.
This should avoid previous issues with rsc.io/goversion where Go
processes were no longer listed.

[1] https://pkg.go.dev/debug/buildinfo
[2] https://go.dev/doc/go1.18#debug/buildinfo

For #102
For #159
For #160
2022-05-04 22:48:20 +02:00
Tobias Klauser
3d102a4755 Update CI to Go 1.18
Also only test on the minimum supported version (currently Go 1.12) and
the latest two versions supported by the Go project.
2022-05-04 22:48:20 +02:00
DuckSoft
4e16ac7815
Fix minor white space issue in README.md (#162) 2022-03-16 13:42:24 +01:00
Eli Bendersky
3e83813cbc
Fix minor typo in README.md (#161) 2022-02-10 08:13:40 +00: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
db6b6e9ba0 agent: rename setsockoptReuseAddrAndPort to setReuseAddrAndPortSockopts 2021-10-11 18:06:37 +02:00
Tobias Klauser
f38bd6a1ee agent: fix solaris build
Solaris doesn't provide the SO_REUSEPORT socket option.
2021-10-11 18:06:37 +02:00
Tobias Klauser
f57f013e90 go.mod, vendor: update gopsutil and go-ole to fix windows/arm64 build
Update github.com/shirou/gopsutil/v3 to v3.21.9 and
github.com/go-ole/go-ole to latest master to fix the build on
windows/arm64.
2021-10-08 18:51:17 +02:00
Tobias Klauser
e9831286ac go.mod, vendor: update dependencies
Update direct dependencies to the following versions:

  github.com/shirou/gopsutil/v3 v3.21.8
  golang.org/x/sys v0.0.0-20210902050250-f475640dd07b
2021-09-03 09:57:33 +02:00
Tobias Klauser
c5ab645ce5 Use Go 1.17 in CI
Also drop tests for 1.13 and 1.14, these are no longer supported
upstream. Keep 1.12 though as this is the mimimum supported version for
gops.
2021-09-03 09:57:33 +02:00
Tobias Klauser
a22894be16 Add //go:build tags for Go 1.17
Run Go 1.17 gofmt to add //go:build tags.
2021-09-03 09:57:33 +02:00
Tobias Klauser
f5057debe6 README.md: update installation instructions
Using `go get -u github.com/google/gops` fails to install gops when
using Go modules. Update the installation instructions accordingly.

For #147
2021-07-15 10:52:58 +02: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
Tobias Klauser
48d3575c6a go.mod, vendor: update dependencies
Update direct dependencies to the following versions:

  github.com/shirou/gopsutil/v3 v3.21.5
  github.com/xlab/treeprint v1.1.0
  golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c
2021-07-01 10:00:02 +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
0bf845d3d5 agent: mention SO_REUSEPORT in Options.ReuseSocketAddrAndPort godoc
The godoc comment mentions SO_REUSEADDR twice, fix this.
2021-03-31 01:05:10 +02:00
Tobias Klauser
55729d43c2 agent: use filepath.Join to construct portfile path
If gopsdir contains a trailing slash, the resulting portfile path will
contain a trailing double slash which might lead to problems in some
circumstances. Moreover iut could also be problematic on platforms where
other path separators are used (e.g. Windows).

Fix this by using filepath.Join to construct the path.
2021-03-09 12:42:07 +01: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
81f7a00714 README.md: add GitHub action status badge 2021-03-01 10:00:41 +01:00
Tobias Klauser
dc7f958b78 Add GitHub action for CI testing
This extends the testing currently done in CircleCI:

* run CI on macOS in addition to Linux and Windows
* testing with multiple Go versions (1.12 through 1.16), not just Go
  1.12 like CircleCI
* checks that the code is properly gofmt'ed
* checks proper module vendoring
2021-02-26 10:38:08 +01:00
Pavel Borzenkov
a3d463ce8a vendor: sync 'vendor' dir with go.mod
The commit contains changes produced by 'go mod vendor' command. It
syncs the dependencies listed in `go.mod` file with the ones in
`vendor/` directory.

With this change `go build -mod=vendor` works again.
2021-02-24 16:46:44 +01:00
Tobias Klauser
268f11e4fc agent: allow to set SO_REUSEPORT on listening socket
Introduce Option.SocketReuseAddrAndPort which, if set, will lead to the
SO_REUSEPORT socket option being set on the listening socket on
Unix-like OSes. This also sets SO_REUSEADDR which is already the default
in net.Listen (see net.setDefaultSockopts).

Setting these options increases the chance to re-bind() to the same
address and port upon agent restart if Options.Addr is set.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2020-12-09 19:27:52 +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
yarcat
5d514cabbb
goprocess: add test for FindAll (#127)
The test verifies that #123 is fixed and prevents future regressions.
2020-09-10 10:12:57 +02:00
JBD
c9150606f9
Fix the worker concurrency model (#126)
Limit the number of concurrent workers by starting a fixed number of goroutines and providing work by an input channel.

Fixes #123
2020-09-07 14:23:34 -07:00
sans
6fb0d860e5
README.md: fix typo (#119) 2020-08-12 11:16:51 +02:00
sans
b96604fa98
goprocess: fix EMFILE error on macOS Catalina (#118)
Limit the number of concurrent goroutines to avoid EMFILE on macOS Catalina.
2020-08-05 10:11:35 +02:00
Tobias Klauser
983b7ba5c9
agent: report additional runtime.MemStats fields (#116)
Report PauseEnd, NumForcedGC and GCCPUFraction from runtime.Memstats.
2020-07-06 12:55:48 +02:00
Tobias Klauser
f7e323ca2e
internal: use filepath.Join in PIDFile (#114)
Use filepath.Join to create a path with correct path delimiters on
Windows.

Based on a change by @42wim submitted in #107
2020-05-30 09:42:52 +02:00
Tobias Klauser
1e1db3f61d
internal: add gops subdirectory in ConfigDir (#112)
Use a subdirectory of the directory returned by os.UserConfigDir instead
of the UserConfigDir directly. This was missed in #103. Also add a test.

Based on a change by @42wim submitted in #107
2020-05-30 09:40:59 +02:00
Tobias Klauser
38c00cd8c2
circleci: test on Windows (#113) 2020-05-30 09:39:11 +02:00
Tobias Klauser
ccffbf8d4a
agent: check error return values (#109)
In func handle, check the error return values of pprof.WriteHeapProfile
and trace.Start.
2020-05-25 10:43:40 +02:00
Tobias Klauser
10df6abaad
Update dependencies (#108)
Updated by running go get -u && go mod tidy && go mod vendor. As a nice
side effect this will get rid of the indirect dependency
github.com/shirou/w32 which is no longer needed by
github.com/shirou/gopsutil
2020-05-18 19:30:29 +02:00
Tobias Klauser
4fa525724f
Update module vendoring (#106)
Run go mod tidy && go mod vendor to clean up vendored modules. This
will drop any unused (sub-)package from the vendor directory.
2020-05-14 23:45:10 +02:00
Tobias Klauser
2715d03f64
agent: clean up socket and port file on SIGTERM and SIGQUIT (#104)
In case the agent is exiting due to a SIGTERM or SIGQUIT it is leaking
the port files in the gops config directory, as e.g. reported in
cilium/cilium#11455

Make sure the socket is cleaned up and port files in the gops config
directory are removed upon these signals by also relaying these signals
to the signal channel in gracefulShutdown. In case of SIGTERM, which is
the "normal" termination signal, exit the process with exit status 0.
2020-05-14 14:06:09 -07:00
Yasushi Saito
932d9779da
Remove dependency on kardianos/osext (#89)
It's superseded by the standard os package in go 1.8+
2020-05-14 22:04:21 +02:00
Tobias Klauser
ea7dd03981
Remove unnecessary type conversion (#105) 2020-05-14 22:03:09 +02:00
Tobias Klauser
ed67c5b345
Use os.UserConfigDir for internal.ConfigDir if available (#103)
On Go ≥ 1.13 the os package has os.ConfigDir
(https://golang.org/pkg/os/#UserConfigDir) which returns the default
root directory to use for user-specific configuration data. Use this in
internal.ConfigDir if available, while still making sure that any
directory specified in GOPS_CONFIG_DIR takes precedence.
2020-05-14 22:01:34 +02:00
Tobias Klauser
f1b8f2b15c
Add prefix to profile dump file names (#101)
When getting profile dumps for further processing, it's hard to distinguish
CPU and heap profiles from the file names alone. Make this easier by
adding a prefix (cpu or heap) to the file name depending on the type of
profile.
2020-04-29 10:44:32 -07:00
Dan Peterson
3a98d6d245
agent: silence error on listener close (#97)
As part of agent.Close, Close is called on the listener. This has
Accept return a "use of closed network connection" error, which is
expected. This error is logged but it would be nice if it wasn't.

Unfortunately, there's not a great way to check for this
error (https://golang.org/issues/4373) so use a best-effort
strings.Contains check.
2020-02-29 14:34:15 -08:00
Tobias Klauser
9025be33d5
Don't log path to profile dump twice (#98)
The path to the profile dump is already logged after writing the file
(cmd.go line 121). Remove the duplicate log line.

Co-authored-by: Emmanuel T Odeke <odeke@ualberta.ca>
2020-02-29 14:27:25 -08:00
Jakub Łukasiewicz
71c4255d55
Check $XDG_CONFIG_HOME before falling to ~/.config (#99) 2020-02-29 14:24:56 -08: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