1
0
mirror of https://github.com/google/gops.git synced 2024-11-24 08:22:25 +02:00
Commit Graph

220 Commits

Author SHA1 Message Date
Tobias Klauser
4e8ba583e7
Remove vendored modules (#188) 2022-11-22 07:49:29 -08:00
dependabot[bot]
ed01246b0a build(deps): bump github.com/shirou/gopsutil/v3 from 3.22.9 to 3.22.10
Bumps [github.com/shirou/gopsutil/v3](https://github.com/shirou/gopsutil) from 3.22.9 to 3.22.10.
- [Release notes](https://github.com/shirou/gopsutil/releases)
- [Commits](https://github.com/shirou/gopsutil/compare/v3.22.9...v3.22.10)

---
updated-dependencies:
- dependency-name: github.com/shirou/gopsutil/v3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-11-08 04:10:37 +01:00
dependabot[bot]
f8e83ad200 build(deps): bump github.com/spf13/cobra from 1.5.0 to 1.6.1
Bumps [github.com/spf13/cobra](https://github.com/spf13/cobra) from 1.5.0 to 1.6.1.
- [Release notes](https://github.com/spf13/cobra/releases)
- [Commits](https://github.com/spf13/cobra/compare/v1.5.0...v1.6.1)

---
updated-dependencies:
- dependency-name: github.com/spf13/cobra
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-11-07 08:38:41 +01:00
dependabot[bot]
31f906129d build(deps): bump github.com/shirou/gopsutil/v3 from 3.22.8 to 3.22.9
Bumps [github.com/shirou/gopsutil/v3](https://github.com/shirou/gopsutil) from 3.22.8 to 3.22.9.
- [Release notes](https://github.com/shirou/gopsutil/releases)
- [Commits](https://github.com/shirou/gopsutil/compare/v3.22.8...v3.22.9)

---
updated-dependencies:
- dependency-name: github.com/shirou/gopsutil/v3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-03 23:31:51 +02:00
Tobias Klauser
cf6a02a850 Update CI to Go 1.19 2022-09-01 22:51:33 +02:00
dependabot[bot]
6a7f594c94 build(deps): bump github.com/shirou/gopsutil/v3 from 3.22.7 to 3.22.8
Bumps [github.com/shirou/gopsutil/v3](https://github.com/shirou/gopsutil) from 3.22.7 to 3.22.8.
- [Release notes](https://github.com/shirou/gopsutil/releases)
- [Commits](https://github.com/shirou/gopsutil/compare/v3.22.7...v3.22.8)

---
updated-dependencies:
- dependency-name: github.com/shirou/gopsutil/v3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-01 22:48:53 +02:00
dependabot[bot]
1b6dca4616 build(deps): bump github.com/shirou/gopsutil/v3 from 3.22.4 to 3.22.7
Bumps [github.com/shirou/gopsutil/v3](https://github.com/shirou/gopsutil) from 3.22.4 to 3.22.7.
- [Release notes](https://github.com/shirou/gopsutil/releases)
- [Commits](https://github.com/shirou/gopsutil/compare/v3.22.4...v3.22.7)

---
updated-dependencies:
- dependency-name: github.com/shirou/gopsutil/v3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-01 06:36:37 +02:00
dependabot[bot]
ab74a57fd9 build(deps): bump github.com/spf13/cobra from 1.4.0 to 1.5.0
Bumps [github.com/spf13/cobra](https://github.com/spf13/cobra) from 1.4.0 to 1.5.0.
- [Release notes](https://github.com/spf13/cobra/releases)
- [Commits](https://github.com/spf13/cobra/compare/v1.4.0...v1.5.0)

---
updated-dependencies:
- dependency-name: github.com/spf13/cobra
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-31 06:13:22 +02:00
dependabot[bot]
b328946709 build(deps): bump actions/setup-go from 2 to 3
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 2 to 3.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](https://github.com/actions/setup-go/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/setup-go
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-31 06:05:39 +02:00
dependabot[bot]
62a38d18c9 build(deps): bump actions/checkout from 2 to 3
Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 3.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-31 05:38:47 +02:00
Tobias Klauser
12769e9c68
ci: add dependabot config (#176) 2022-08-31 02:21:56 +03:00
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
3655f623db vendor: include cobra 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
c14dce915a ci: run tests with -race 2022-07-07 18:07:51 +02:00
Tobias Klauser
5ddd2779fb agent: fix data race in Listen
Fix the following data race in agent.Listen:

==================
WARNING: DATA RACE
Write at 0x0000007620a0 by goroutine 9:
  github.com/google/gops/agent.Listen()
      /home/tklauser/go/src/github.com/google/gops/agent/agent.go:112 +0x207
  github.com/google/gops/agent.TestAgentClose()
      /home/tklauser/go/src/github.com/google/gops/agent/agent_test.go:21 +0x6e
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:1439 +0x213
  testing.(*T).Run.func1()
      /usr/local/go/src/testing/testing.go:1486 +0x47

Previous read at 0x0000007620a0 by goroutine 8:
  github.com/google/gops/agent.listen()
      /home/tklauser/go/src/github.com/google/gops/agent/agent.go:130 +0x5a

Goroutine 9 (running) created at:
  testing.(*T).Run()
      /usr/local/go/src/testing/testing.go:1486 +0x724
  testing.runTests.func1()
      /usr/local/go/src/testing/testing.go:1839 +0x99
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:1439 +0x213
  testing.runTests()
      /usr/local/go/src/testing/testing.go:1837 +0x7e4
  testing.(*M).Run()
      /usr/local/go/src/testing/testing.go:1719 +0xa71
  main.main()
      _testmain.go:57 +0x2e4

Goroutine 8 (finished) created at:
  github.com/google/gops/agent.Listen()
      /home/tklauser/go/src/github.com/google/gops/agent/agent.go:123 +0x43b
  github.com/google/gops/agent.TestListen()
      /home/tklauser/go/src/github.com/google/gops/agent/agent_test.go:13 +0x57
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:1439 +0x213
  testing.(*T).Run.func1()
      /usr/local/go/src/testing/testing.go:1486 +0x47
==================
--- FAIL: TestAgentClose (0.00s)
    testing.go:1312: race detected during execution of test
FAIL
FAIL	github.com/google/gops/agent	0.026s
2022-07-07 18:07:51 +02:00
Tobias Klauser
8442404056 internal: inline getOSUserConfigDir 2022-06-27 09:52:46 +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
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