Commit Graph

86 Commits

Author SHA1 Message Date
Daniel Nelson 6abd227e48
[net] linux: skip if not exist error on getProcInodesAll 2017-11-17 10:46:16 -08:00
Marco Pfatschbacher df6462b50e Fix PR comments made by shirou 2017-11-09 13:14:12 +01:00
Marco Pfatschbacher 6e7aca41d7 Implement Connection support for OpenBSD
This retrieves open TCP/UDP connections by using netstat(1)
File descriptors and pids are not supported.
2017-11-08 21:26:05 +01: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
Sean Chittenden 635b971c0e
Move from the `syscall` package to the `golang.org/x/sys/{unix,windows}` 2017-06-02 13:51:00 -07: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
Sean Chittenden d0e40ff723
Fix issues reported by golint. 2017-04-27 14:21:34 -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
Cameron Sparr a213bf5e6d
run go fmt ./... 2017-02-01 23:05:29 +00: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 df61ef6d5f Add stub functions for ConnectionsMax in other OS versions. 2016-12-11 13:06:56 -05: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
Marco Pfatschbacher b4846b445b Add support for OpenBSD/amd64
This code is based on the FreeBSD version
and implements roughly the same feature set.
2016-11-24 22:30:29 +01:00
Cameron Sparr 5af5f08785 Fix NetIOCounter windows interface behavior
addresses a few things:

- Windows has a concept of both a network "interface" and an "adapter"
- These are almost always a one-to-one relationship, though there can be
esoteric instances where they are not.
- I believe the gopsutil NetIOCounters function should only return on a
per-interface level, since this is the behavior on linux/darwin.

Previously, the plugin was basically ignoring the actual interfaces
returned from net.Interfaces(). Instead, it was looping over the net
adapters for each interface, somewhat uselessly.

FWIW, the code for getAdapterList() doesn't exist in the Go standard lib
anymore.

closes #245
2016-10-25 16:51:40 +01:00
Jean Kahrs e004ef15e1 remove unused code 2016-10-11 10:34:47 +02:00
Jean Kahrs d6f5a9e920 fix net_test.go 2016-10-06 15:46:14 +02:00
Jean Kahrs 98a0a30dca update test 2016-10-06 15:38:56 +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
Bruno Clermont 3f96312057 only run ifconfig/netstat if necessary, add some tests 2016-09-04 16:37:28 +02:00
Bruno Clermont 145e48efdb actually there is 13 columns, not 12 2016-08-31 20:41:42 +02:00
Bruno Clermont 57ffe3b1ef Support interface with multiple digits 2016-08-31 20:41:11 +02:00
Lukas Fittl da9fa1162b Add fallback code for all unsupported operating systems.
This enables using gopsutil in a codebase that gets built on other OSes
than the ones supported. Instead of a build failure as before, due to
the build tags, gopsutil will now throw an "not implemented" runtime
error.

Fixes #234.
2016-08-22 15:31:26 -07:00
sandlbn 480ccb89e1 Added support for linux net interface fifo errors 2016-06-13 13:27:25 +01:00
Shirou WAKAYAMA 57f6aebc7e add Timeout to invoke command and use common.Invoke refs: #201 2016-05-20 17:59:41 +09:00
Shirou WAKAYAMA bce9212def fix build bugs. 2016-04-01 22:22:03 +09:00
Shirou WAKAYAMA 613a8a90e1 fixed by golint. 2016-04-01 21:34:39 +09:00
Shirou WAKAYAMA 4bb84648bf JSON representation is renamed to fit Google JSON style, camelCase. 2016-03-23 10:52:46 +09:00
Shirou WAKAYAMA ea152ea901 [BREAKING CHANGE] rename functions to pass golint. ex) net.NetIOCounters -> net.IOCounters 2016-03-22 23:09:12 +09:00
Shirou WAKAYAMA 1f32ce1bb3 [net]linux: skip if "/proc/sys/net" is not exists on test environment. 2016-03-15 22:47:56 +09:00
Shirou WAKAYAMA 34b63e671b [net]linux: add a test and fix private field name. 2016-03-10 22:32:16 +09:00
Shirou WAKAYAMA 567da004c5 [net]linux: explicit skip CI. 2016-03-06 00:02:06 +09:00
Shirou WAKAYAMA 32fa88eb49 [net]linux: TestGetProcInodes will fail on CI. 2016-03-05 23:57:18 +09:00
Shirou WAKAYAMA 31439aa6b5 [net]linux: fix valious bugs in NetConnections. 2016-03-05 23:53:32 +09:00
Shirou WAKAYAMA e4ddff09d5 [net]linux: add process_unix for NetConnections. 2016-03-05 22:24:26 +09:00