Commit Graph

138 Commits (cf6309316c89a96a0a4b848185b32830a6e8175e)

Author SHA1 Message Date
Laurie Clark-Michalek 413cb32b6c Use static initialisation for invoke instances, instead of init funcs
The order of init function execution is dependant on the order that the
source files are passed to the compiler. This causes issues when
building under other build systems, such as bazel or buck, as they are
not guarenteed to maintain the same file order as the default go tool.
7 years ago
shirou 4c73494c78 Add WithContext functions. 7 years ago
Daniel Nelson 6abd227e48
[net] linux: skip if not exist error on getProcInodesAll 7 years ago
Marco Pfatschbacher df6462b50e Fix PR comments made by shirou 7 years ago
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.
7 years ago
shirou e01a14e318 [net] linux: skip if permission error on getProcInodesAll
This fixes #433
8 years ago
WAKAYAMA Shirou 09e9859714 [net]linux: return err. 8 years ago
better88 86af477d1a err omit in getProcInodes 8 years ago
Sean Chittenden 635b971c0e
Move from the `syscall` package to the `golang.org/x/sys/{unix,windows}` 8 years ago
Alexander Blagoev b32353f094 Add comments with a short explanation and link to the PR request 8 years ago
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.
8 years ago
shirou c251591dc7 Merge pull request #355 from sean-/fix-lint-errors
Fix lint errors
8 years ago
shirou 9af92986dd Merge pull request #358 from ablagoev/optimize-net-connections
Fromat socketType properly in tcp duplication check key
8 years ago
Alexander Blagoev 5a0a97f400 Fromat socketType properly in tcp duplication check key 8 years ago
shirou b066db40c7 Merge pull request #356 from ablagoev/optimize-net-connections
Optimize memory usage for net.Connections on Linux
8 years ago
Alexander Blagoev 11e78812ae Build duplicate tcp connection ID in Connections for better readbility 8 years ago
Alexander Blagoev f7dd4f97c7 Improve /proc/net/dev parsing to include all edge cases 8 years ago
Alexander Blagoev 51e4fb77cf Add socket state to TCP connection key 8 years ago
Alexander Blagoev daaadd4f1e Optimize memory usage for net.Connections on Linux 8 years ago
Sean Chittenden 23a4ae3369
`gofmt -s -w .` 8 years ago
Sean Chittenden d0e40ff723
Fix issues reported by golint. 8 years ago
Toshi Piazza 5e1c2fa23b Fixes memory leak 8 years ago
Peter De Cleyn e8fc31359b Added support to alias interfaces (e.g., ifname0:1) 8 years ago
Cameron Sparr a213bf5e6d
run go fmt ./... 8 years ago
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.
8 years ago
WAKAYAMA Shirou 42156fdf0d [net]linux: fix NetFilterCounters filename 8 years ago
Conor Branagan df61ef6d5f Add stub functions for ConnectionsMax in other OS versions. 8 years ago
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.
8 years ago
Cameron Sparr d74d84e593 Fix /proc/net/dev dropOut and fifoOut indices
fixes #284
8 years ago
Marco Pfatschbacher b4846b445b Add support for OpenBSD/amd64
This code is based on the FreeBSD version
and implements roughly the same feature set.
8 years ago
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
9 years ago
Jean Kahrs e004ef15e1 remove unused code 9 years ago
Jean Kahrs d6f5a9e920 fix net_test.go 9 years ago
Jean Kahrs 98a0a30dca update test 9 years ago
Jean Kahrs ab24c97439 break import cycle 9 years ago
Jean Kahrs cba0992ab3 add Uids field to net_linux 9 years ago
Bruno Clermont 3f96312057 only run ifconfig/netstat if necessary, add some tests 9 years ago
Bruno Clermont 145e48efdb actually there is 13 columns, not 12 9 years ago
Bruno Clermont 57ffe3b1ef Support interface with multiple digits 9 years ago
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.
9 years ago
sandlbn 480ccb89e1 Added support for linux net interface fifo errors 9 years ago
Shirou WAKAYAMA 57f6aebc7e add Timeout to invoke command and use common.Invoke refs: #201 9 years ago
Shirou WAKAYAMA bce9212def fix build bugs. 9 years ago
Shirou WAKAYAMA 613a8a90e1 fixed by golint. 9 years ago
Shirou WAKAYAMA 4bb84648bf JSON representation is renamed to fit Google JSON style, camelCase. 9 years ago
Shirou WAKAYAMA ea152ea901 [BREAKING CHANGE] rename functions to pass golint. ex) net.NetIOCounters -> net.IOCounters 9 years ago
Shirou WAKAYAMA 1f32ce1bb3 [net]linux: skip if "/proc/sys/net" is not exists on test environment. 9 years ago
Shirou WAKAYAMA 34b63e671b [net]linux: add a test and fix private field name. 9 years ago
Shirou WAKAYAMA 567da004c5 [net]linux: explicit skip CI. 9 years ago
Shirou WAKAYAMA 32fa88eb49 [net]linux: TestGetProcInodes will fail on CI. 9 years ago
Shirou WAKAYAMA 31439aa6b5 [net]linux: fix valious bugs in NetConnections. 9 years ago
Shirou WAKAYAMA e4ddff09d5 [net]linux: add process_unix for NetConnections. 9 years ago
Shirou WAKAYAMA 32c62b5d48 [net]linux: implement processInet(). 9 years ago
Shirou WAKAYAMA 6c352016d8 [net]linux: start replacing lsof. still work in progress. 9 years ago
Shirou WAKAYAMA d680853370 net,process[linux]: add process.NetIOCounter and net.NetIOCounterByFile. 9 years ago
Masayoshi Sekimura 3a1fa5dc80 format go program with go 1.5.2 "go fmt" 9 years ago
shirou f58654fa1c Merge pull request #122 from jimmystewpot/add_netfilter
Add nf_conntrack counter support
9 years ago
Cameron Sparr 432bcbd056 Add -W flag to netstat on BSD systems
This prevents netstat from truncating the interface name to 5
characters. See https://github.com/influxdb/telegraf/issues/438
9 years ago
shirou dc452207f2 Merge pull request #128 from ontsysmattholcomb/use-env-proto-counters
using HostProc for protocounters in linux
9 years ago
Nikolay Sivko 906df3ed85 [net] fix panic on freebsd (netstat error with exit code 0) 9 years ago
Matt Holcomb 21ccfe6b60 using HostProc for protocounters in linux 9 years ago
James Lamb a9e946c7dd change the snakecase to reflect the files being read 9 years ago
James Lamb 5700150054 Updated README.rst and included updated syntax to be more uniform with the other code 9 years ago
James Lamb 22f35fd518 add netfilter counter support 9 years ago
James Lamb dfff8af4df add nf_conntrack statistics to net_linux to query iptables/netfilter conntrack limits 9 years ago
Nathaniel Cook da832b3f12 add system wide network protocol stats 9 years ago
Shirou WAKAYAMA 7288e9a5af common[all]: add internal 10 years ago
Daniel Theophanes 0af895258e common: rename package common to internal/common. Add ENV helper funcs.
Package common wasn't used for public functions. Place it in an
internal directory to prevent other packages from using.

Remove the distributed references to "HOST_PROC" and "HOST_SYS"
consts and combine into a common function. This also helps so that
if a env var is defined with a trailing slash all will continue to
work as expected.

Fixes #100
10 years ago
Jonathan Chauncey 0461c50666 chore(*): Fixes #94
Added the ability to fetch an alternative location for /proc via an
environment variable. If the env var is not set it will return /proc as
the default value.
10 years ago
Shirou WAKAYAMA 93e226a5e3 net[freebsd,linux,darwin]: merge unix like OSes. 10 years ago
Shirou WAKAYAMA 34195b4b58 net[darwin, linux]: get UDP information when inet or all specified. 10 years ago
Shirou WAKAYAMA b3cf7354f6 process[linux, darwin]: implements Connections using lsof. 10 years ago
Shirou WAKAYAMA 4d0f737301 net: because lsof failed on drone.io, skip TestNetConnections if CI. 10 years ago
Shirou WAKAYAMA 0062ae2bfa use LookPath 10 years ago
Shirou WAKAYAMA 249a761b81 net[linux]: temporary enable error print. 10 years ago
Shirou WAKAYAMA 8d21be591e net[linux]: implements NetConnections() using lsof. 10 years ago
Shirou WAKAYAMA c50db4f462 net[darwin]: implement NetConnections(). 10 years ago
Shirou WAKAYAMA 6bb6762470 net[darwin]: add drop count to NetIOCounter. 10 years ago
Shirou WAKAYAMA e0b1d62a4d net[darwin]: add netstat -idbn example in the comment. 10 years ago
Cameron Sparr c57e866f91 Fix net stat reporting for Darwin 10 years ago
Shirou WAKAYAMA b5ffc220a6 common: Rename StringContains to StringsContains and add StringsHas. 10 years ago
Shirou WAKAYAMA 3ff690d1d8 make single network interface about NetIOCounters on darwin and freebsd 10 years ago
Shirou WAKAYAMA 406cbe9b87 implements pernic of NetIOCounters. 10 years ago
Shirou WAKAYAMA 13cd195a7e change package name. 10 years ago
Shirou WAKAYAMA c348a399b0 merged 6e713f1469 10 years ago
WAKAYAMA Shirou 9f2c985a28 fix windows build. 10 years ago
WAKAYAMA shirou d11680c773 fix bugs on FreeBSD. 10 years ago
Shirou WAKAYAMA a4671fcc2a move subdirectories. refer to issue #24 10 years ago