1
0
mirror of https://github.com/shirou/gopsutil.git synced 2025-04-26 13:48:59 +08:00

78 Commits

Author SHA1 Message Date
camcui
3ec3f55280 chore: fix some typos in comments
Signed-off-by: camcui <cuishua@sina.cn>
2024-04-12 15:00:55 +08:00
shirou
0665cafa1b chore: replace deprecated ioutil package to os and io 2023-09-08 17:05:14 +00:00
Antoine Toulme
38b94668ea allow to pass context values to override environment variables 2023-06-02 01:31:05 -07:00
cui fliter
9aa4e7a744 fix some comments
Signed-off-by: cui fliter <imcusg@gmail.com>
2023-05-09 16:42:07 +08:00
Ties de Wit
e4409ef6a1
Update net_linux.go 2022-09-01 09:17:10 +02:00
shirou
f11e3ba120 fix(net,linux): move IsLittleEndian to internal 2022-07-04 08:41:25 +00:00
shirou
8ae3affce0 fix(net,linux): fix decodeaddress if Big Endian 2022-07-02 13:39:32 +00:00
Matthieu MOREL
b0469a470b
Merge branch 'master' into master 2022-02-01 19:28:26 +01:00
Ville Skyttä
1e56c6f421 Spelling and grammar fixes 2022-01-30 22:48:09 +02:00
Matthieu MOREL
8ba220d241 enable contextcheck linter 2022-01-24 09:26:50 +01:00
Lomanic
d826e14e27 [net][linux] Fix #1198 "f.ReadDir undefined" on Go 1.15 by redefining a custom readDir according to go version
Using os.File.Readdir pre Go 1.16 and os.File.ReadDir post Go 1.16
2022-01-01 18:07:03 +01:00
mmorel-35
1e6b445a8a gofumpt 2021-12-22 21:54:41 +00:00
Matthieu MOREL
b673968d5d
enable errorlint linter 2021-12-04 22:29:38 +01:00
shirou
d2e27c1712 fix dependabot v2 deletion. 2021-12-01 00:12:55 +00:00
shirou
0969c9436b delete v2 directory, move v3 to top #1078 2021-11-30 23:47:59 +00:00
Disconnect3d
5c1a9e709d net_linux.go: decode port as 16-bit uint
Changes the port parsing from `/proc/net/*` files records from parsing them as 64-bit integers to parse them as 16-bit unsigned integers.

While this is mostly a cosmetic change, it will also make so that the code fails faster in case the entry is malformed (for whatever reason).

Note that the returned value is still casted to uint32 when an  `Addr` object is created.
It seems to me that the `Addr.port` field should be changed to `uint16` but maybe some other APIs/systems wants it to be `uint32` and also changing it there may require changes in users code if they update. This being said I am not changing that field's type.
2020-08-28 00:31:50 +02:00
gtosh4
936d3b27f1
Don't ignore context for io counters 2020-05-16 17:06:26 -07:00
Brian C. Williams
f00df5cffe Add WithoutUids funcs 2019-11-01 10:58:35 -04:00
Lomanic
6a8ab0308e [net][linux] Go fmt net/net_linux.go 2019-07-11 00:33:41 +02:00
chi-chi weng
809306b78a
Fix the net.ConnectionsMax BUG
`connectionsList, err := net.ConnectionsMax("tcp4", 1000)`
when you run net.ConnectionsMax,you will find some proc is not equal with the `netstat -lptn`
2019-06-12 11:37:08 +08:00
Curtis Mattoon
648bf4eebc Adds ConntrackStats to get conntrack summary stats 2019-05-11 12:45:05 -04:00
Joe Stringer
f87d9813da [net][linux] Support socket tables in nested namespaces
Signed-off-by: Joe Stringer <joe@cilium.io>
2018-11-27 10:16:31 -08:00
Iskander Sharipov
3684fce88a net: use multi-value case clause instead of fallthrough
Found using https://go-critic.github.io/overview#emptyFallthrough-ref
2018-09-13 23:52:36 +03:00
shirou
4c73494c78 Add WithContext functions. 2017-12-31 15:25:49 +09:00
Daniel Nelson
6abd227e48
[net] linux: skip if not exist error on getProcInodesAll 2017-11-17 10:46:16 -08:00
shirou
e01a14e318 [net] linux: skip if permission error on getProcInodesAll
This fixes #433
2017-10-07 11:42:26 +09:00
WAKAYAMA Shirou
09e9859714 [net]linux: return err. 2017-07-10 16:48:47 +09:00
better88
86af477d1a err omit in getProcInodes 2017-07-10 15:03:52 +08:00
Alexander Blagoev
b32353f094 Add comments with a short explanation and link to the PR request 2017-05-04 14:52:34 +03:00
Alexander Blagoev
531f9507d2 Read /proc/net files with a single read syscall.
The /proc/net files are not guaranteed to be consistent, they are only
consitent on the row level. This is probably one of the reasons why
consequent read calls might return duplicate entries - the kernel is
changing the file as it is being read. In certain situations this might
lead to loop like situations - the same net entry is being returned when
reading the file as new connections are added to the kernel tcp table, i.e
there can be a lot of duplications.

This commit is trying to reduce the duplications, by fetching the contents
of the net files with a single read syscall.
2017-05-01 20:59:02 +03:00
shirou
c251591dc7 Merge pull request #355 from sean-/fix-lint-errors
Fix lint errors
2017-05-01 22:28:17 +09:00
shirou
9af92986dd Merge pull request #358 from ablagoev/optimize-net-connections
Fromat socketType properly in tcp duplication check key
2017-04-30 23:39:46 +09:00
Alexander Blagoev
5a0a97f400 Fromat socketType properly in tcp duplication check key 2017-04-30 16:55:03 +03:00
shirou
b066db40c7 Merge pull request #356 from ablagoev/optimize-net-connections
Optimize memory usage for net.Connections on Linux
2017-04-30 20:22:54 +09:00
Alexander Blagoev
11e78812ae Build duplicate tcp connection ID in Connections for better readbility 2017-04-30 14:19:54 +03:00
Alexander Blagoev
f7dd4f97c7 Improve /proc/net/dev parsing to include all edge cases 2017-04-29 18:57:54 +03:00
Alexander Blagoev
51e4fb77cf Add socket state to TCP connection key 2017-04-28 19:34:08 +03:00
Alexander Blagoev
daaadd4f1e Optimize memory usage for net.Connections on Linux 2017-04-28 19:00:28 +03:00
Sean Chittenden
23a4ae3369
gofmt -s -w . 2017-04-27 14:40:43 -07:00
Toshi Piazza
5e1c2fa23b Fixes memory leak 2017-02-22 02:53:45 -05:00
Peter De Cleyn
e8fc31359b Added support to alias interfaces (e.g., ifname0:1) 2017-02-21 08:19:22 +01:00
Conor Branagan
276c873f0d Fast duplication check in inodes processing.
Instead of encoding a JSON string of each connection (non-trivial at high
connection volumes) we can use the connTmp struct for map look-ups if we
eliminate the unused `uids` field.

Also switches to using the empty struct instead of bool for zero memory
overhead.
2016-12-20 12:38:54 -05:00
WAKAYAMA Shirou
42156fdf0d [net]linux: fix NetFilterCounters filename 2016-12-20 23:59:53 +09:00
Conor Branagan
198e65c801 Add ConnectionsMax function that limits connections per pid.
The goal is to improve performance of connection fetching connections across
all processes when some processes can have several hundred or thousands of file
descriptors. Right now when you have many thousands of fds the process spends
lots of time inside the syscalls from Readdir and Readlink.

The public API works as before with two new functions:

- `ConnectionsMax`
- `ConnectionsPidMax`

Each function takes an additional int argument that sets the max number of fds
read per process.
2016-12-11 13:05:40 -05:00
Cameron Sparr
d74d84e593 Fix /proc/net/dev dropOut and fifoOut indices
fixes #284
2016-12-01 21:25:38 +00:00
Jean Kahrs
e004ef15e1 remove unused code 2016-10-11 10:34:47 +02:00
Jean Kahrs
ab24c97439 break import cycle 2016-10-06 15:32:25 +02:00
Jean Kahrs
cba0992ab3 add Uids field to net_linux 2016-10-06 14:50:03 +02:00
sandlbn
480ccb89e1 Added support for linux net interface fifo errors 2016-06-13 13:27:25 +01:00
Shirou WAKAYAMA
4bb84648bf JSON representation is renamed to fit Google JSON style, camelCase. 2016-03-23 10:52:46 +09:00