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.
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
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.
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%
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
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.
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
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.
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>
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.
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
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
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.