Commit Graph

131 Commits (7e40e28bc67734eb4887882a678e37beed263efd)

Author SHA1 Message Date
Ville Skyttä 633e77013f Use short if 4 years ago
Ville Skyttä ce9d35436e Merge variable declaration with assignment 4 years ago
Ville Skyttä 5d0724f42f Comment convention fixes 4 years ago
Ville Skyttä 65616500e8 Remove unnecessary empty lines 4 years ago
Ville Skyttä a9b1ce2dec Remove unnecessary conversions 4 years ago
Ville Skyttä 7743265113 Rewrite if-else chains as switches 4 years ago
shirou 2fa855f295 add MockEnv as more generic function. 4 years ago
Johannes Drummer 76fb312c4b delete unused PdhAddCounterW 4 years ago
Johannes Drummer 82b235c9f5 v2 windows counters on non english systems 4 years ago
AtakanColak 498a39984d tidy comments 4 years ago
AtakanColak 2c98f69e11 add load v2
tidied up common/windows
added load benchmark for load_test
cpu percent is used as load if queue is zero
4 years ago
AtakanColak 24e6d6d350 add load to windows 4 years ago
Atakan 3504ea07b0 simplify virt cache 4 years ago
shirou b94f262e7d
Merge pull request #949 from boogie-byte/vet-target
Add "vet" target to the Makefile
4 years ago
Sergey Vinogradov 8ff2ab3187 Add "vet" target to the Makefile
Making the "vet" target will run "go vet ./..." for each supported
GOOS.

Also, some of the warnings produced by go 1.15 vet were mitigated.
4 years ago
Ryan Fitzpatrick 8046134504
Fix VirtualizationWithContext() race in linux 5 years ago
shirou 5084874a4c
Merge pull request #942 from AtakanColak/patch-1
Cache common/common_linux.Virtualization()
5 years ago
Ata ba243b1d14
removed explicit set to nil 5 years ago
Ata 5fd5d64304
Cache common/common_linux.Virtualization()
By assuming virtualization environment won't change during a the program's runtime, we can cache common/common_linux.Virtualization() with a simple map to reduce amount of system calls. I first mentioned this issue at https://github.com/shirou/gopsutil/pull/890#issuecomment-690211919
5 years ago
Lomanic e1082dabb6 [process][darwin] Fix #925 remove references to removed const unix.SYS___SYSCTL from x/sys/unix
More like a workaround, wanted to port process.getKProcWithContext() to use unix.SysctlRaw() to get rid of exec calls to ps
in the same time but didn't have time.
5 years ago
ninedraft baf3495197 use legacy error check in the common.TestSleep 5 years ago
ninedraft 34df4904f6 use cancelable sleep in cpu.PercentWithContext and process.Process.PercentWithContext 5 years ago
Mihir Singh 92d6df6d8f Attempted LXC guest detection from environ procfile 5 years ago
Lomanic c89193f22d
Merge pull request #857 from Gui13/fix_837
Do not cache boot time for linux. Fix #837
5 years ago
Mauro Leggieri 00957cfedc Fixed slow command line retrieval on Windows 5 years ago
Guillaume Bienkowski aeb3b6b1c7 Do not cache boot time for linux. Fix #837 5 years ago
Ilya Prudnikov 256e00319e implement proposed solution 5 years ago
shirou a21ed69d3a Revert "Merge pull request #763 from Iqoqo/add-android-support-for-host"
This reverts commit f58b2e3677, reversing
changes made to 84e6215770.
6 years ago
Ilya Guterman 11244886bb add android support for host 6 years ago
Kris Watts c3720007e4 Fixes issue #730 6 years ago
Lomanic 47323f9ad5 [process][windows] Fix #586 use win32 API in process.Exe() instead of slow WMI call
This is faster by a factor of 100.

References:
5f4287d17f/psutil/_pswindows.py (L221)
921870d540/psutil/_psutil_windows.c (L1211)
921870d540/psutil/_psutil_windows.c (L626)
6 years ago
Arturo Reuschenbach Puncernau eb15d06a52 trim quotes when reading from os-release 6 years ago
shirou 5335e3fd50
Merge pull request #685 from cmattoon/conntrack-stat
Adds ConntrackStats (/proc/net/stat/nf_conntrack)
6 years ago
shirou 07863cab0c [host]linux: add #688 diff which is removed after merging #689 6 years ago
Tyler Dixon 4e81681ab3 code review 6 years ago
Tyler Dixon a02925055c Remove cycle between process and host packages
gopsutil is a transitive dependency of another project that I am integrating
into an internal build system. We target multiple platforms and as a part
of the build system for the large internal repo, we calculate the build
graph used to determine what targets have changed and need to be build /
tested as a single DAG for all platforms.

gopsutil currently does not form a DAG if linux and any other platform are
considered at the same time. linux is the only platform where the process
package imports the host package.

To remove this cycle, the relevant methods have been moved to internal/common
with the linux build tag and are consumed the host and process packages.
6 years ago
Curtis Mattoon 648bf4eebc Adds ConntrackStats to get conntrack summary stats 6 years ago
Lomanic 0e0dd767df [process][darwin] Fix #670 remove call to common.Pipeline (prone to race condition)
Also properly parse lsof to get second txt record instead of hoping the 5th line is the right one (wrong data returned for pid 57)
6 years ago
Segflow 86c7289ccc Fix: use filename in exec.LookPath instead of full path
exec.LookPath searches for the file in the $PATH, which mean giving it an absolute path is against it's own purposes.
6 years ago
WAKAYAMA shirou bb15c85289 [mem][freebsd]: add SysctlUint which can adapt both 32 and 64 bit 6 years ago
Lomanic ef54649286 [windows] Use windows.NewLazySystemDLL to (possibly) prevent DLL hijacking
Might be useless because of https://docs.microsoft.com/en-us/windows/desktop/dlls/dynamic-link-library-search-order#search-order-for-desktop-applications
but better be safe than sorry.

Ref: https://github.com/shirou/gopsutil/issues/570#issuecomment-413951653
7 years ago
Jaime Soriano Pastor 61902bc2a5 Use HOST_* environment variables for getting disk serial number in Linux 7 years ago
shirou 145dca90f7 change to use CommandContext. 7 years ago
sada 8dd42707e2 windows: fix WithContext functions
set timeout only if parent context doesn't set.
7 years ago
shirou 079e1cb22f [internal]Windows: skip Host test. 7 years ago
leaf 65598d98cc To prevent hang if wmi.Query hangs, add a context-aware wrapper for it. 7 years ago
Daniel Nelson df2f1a8dd1
Add HOST_VAR envvar and use to locate utmp on Linux. 8 years ago
Derek Brown 7c807c86e4 Add implementation of SwapMemory() for windows 8 years ago
Michael Schurter 042305ee4a Remove SetEnv on all platforms 8 years ago
Michael Schurter 565f5c8c5e Alter subprocess's environment instead of the hosts
Fixes #415
8 years ago
Sean Chittenden 635b971c0e
Move from the `syscall` package to the `golang.org/x/sys/{unix,windows}` 8 years ago
Asato Wakisaka 16a38100b3 NumProcs() just counts files under f, so use f.Readdirnames to avoid `lstat` syscall inside f.Readdir. 8 years ago
Sean Chittenden d0e40ff723
Fix issues reported by golint. 8 years ago
Sean Chittenden 3834908232
Improve Command() handling and signal handling for launched processes. 8 years ago
WAKAYAMA Shirou 30ebb9ca3a rename expected dir to testdata. 8 years ago
tycho garen 22c56d292e close open files 8 years ago
Cameron Sparr a213bf5e6d
run go fmt ./... 8 years ago
shirou 93564b3142 Merge pull request #271 from botherder/master
Obtain executable path from macOS process (fix #270)
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
Nex 5c0ac28fed Changing a little the return values 9 years ago
Nex d9b355f75e Added proper piping of commands 9 years ago
Sean Chittenden e4f857a9ca
Fix a linter issue: s/TimeoutErr/ErrTimeout/g 9 years ago
Sean Chittenden 613ada987d
Add DoSysctrl() to Linux's common utilities. 9 years ago
Sean Chittenden e0b5f86113
Spell `error` like `err`. *facepalm* 9 years ago
Sean Chittenden a3f57b1314
Resolve cyclic import and create a common helper func, NumProcs() 9 years ago
Shirou WAKAYAMA 57f6aebc7e add Timeout to invoke command and use common.Invoke refs: #201 9 years ago
Shirou WAKAYAMA 0787e8ba3e [host]linux-arm: update type_liux.go. Test will fail. 9 years ago
Shirou WAKAYAMA adf2f03a48 fix build and path error 9 years ago
Shirou WAKAYAMA bce9212def fix build bugs. 9 years ago
Shirou WAKAYAMA d21ed2b40d search path via exec.LookPath before actual invoke. 9 years ago
Shirou WAKAYAMA 613a8a90e1 fixed by golint. 9 years ago
Shirou WAKAYAMA 944429d994 fixed by errcheck 9 years ago
Shirou WAKAYAMA fa3e1cc196 [common]linux: add HostEtc to switch '/etc' See #175. 9 years ago
Shirou WAKAYAMA 6c352016d8 [net]linux: start replacing lsof. still work in progress. 9 years ago
Shirou WAKAYAMA 3166d41538 set LC_ALL to C in order to avoid number formatting problem. 9 years ago
WAKAYAMA shirou 0af91ba32b [disk,process]freebsd: binary.go moved to internal. 9 years ago
elij d1380cba29 try to fix diskio stats on FreeBSD-10.x
FreeBSD apparently changed the magic sysctl mib values for devstats.

    --- FAIL: TestDisk_io_counters (0.00s)
    disk_test.go:39: error no such file or directory
    disk_test.go:42: ret is empty, map[]

This code uses an undocumented, but exported, go stdlib method to fetch
the sysctl by string instead of mib.
9 years ago
Shawn Smith 9cc9e82920 fix typos 9 years ago
James Lamb 22f35fd518 add netfilter counter support 9 years ago
Shirou WAKAYAMA dd13300833 process[linux,freebsd,darwin]: implements Children using pgrep. 9 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