Commit Graph

275 Commits (b1ddeddda532f09f00fb7a83dc0b83d41a41dc93)

Author SHA1 Message Date
shirou cd915bdc31
Merge pull request #508 from shirou/issue507
[host] Fix docker uptime parsing (fix #507)
Lomanic 1b47825dcb [host] Fix docker uptime parsing (fix #507)
shirou fc04d2dd9a [host]linux/mips: copy mips64 definition from mips.
It just copy from mips, so it may be corrupt, but I can not check it.
If something wrong, please open an issue.
shirou 145dca90f7 change to use CommandContext.
shirou b99342a9ce [host] fallback: implement PlatformInformation()
shirou ebe614f6e1 [solaris] host: add PlatformInformation() which is missing.
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.
linuxhe ee5d6a3d8f fix docker uptime
shirou d76e8c18d8
Merge pull request #496 from shirou/add_docker_to_use_btime
[host] linux: use uptime even if docker guest.
Steven Hartland f846eda923 Eliminate call to uname on FreeBSD
Improve performance by eliminating the fork out to uname on FreeBSD which also helps prevent crashes / hangs due to the outstanding fork crash bug:
golang/go#15658

Also added a test for PlatformInformation.
shirou 28f7cb0d63 [host] linux: use uptime even if docker guest.
sada 8dd42707e2 windows: fix WithContext functions
set timeout only if parent context doesn't set.
CHEVY S. HUNGERFORD 29f8dfa1ad fixing SensorKey output
CHEVY S. HUNGERFORD 1c4fa5628c giving temperature more verbose output
shirou 4ac6b5b4d3 Revert "Merge pull request #470 from improbable-io/bug-darwin-build-2"
This reverts commit bb09b4e7d9, reversing
changes made to 6a368fb7cd.
shirou bb09b4e7d9
Merge pull request #470 from improbable-io/bug-darwin-build-2
Fix build with bazel on OSX attempt 2 (add stub for host_cgo.go)
Tatiana Borisova 945c2f41de Fix host_cgo file
Tatiana Borisova a271cb7c1c Fix package name in host_cgo.go
shirou a97abd3450
Merge branch 'master' into feature/add_context_support
shirou d1fb05a30b Skip some test if CircleCI.
shirou cd61c36c4f
Merge branch 'master' into feature/add_context_support
shirou 8b2468f1e7 Merge branch 'master' of github.com:shirou/gopsutil into feature/lxd_boot_time
shirou 4c73494c78 Add WithContext functions.
Lomanic e3ae39aa5b Fix #442, trim sensor names and properly handle CentOS in host.SensorsTemperatures()
Tatiana Borisova 1be443f398 Fix build attempt 3 (add stub for host_cgo.go)
leaf 65598d98cc To prevent hang if wmi.Query hangs, add a context-aware wrapper for it.
shawnps befc2c3d92 call Fatal if length of Users() is 0
shirou dc3a09c1d0 [host] linux: change file if in a lxc container.
Daniel Nelson df2f1a8dd1
Add HOST_VAR envvar and use to locate utmp on Linux.
Steven Hartland 6450c60b61 Eliminate use of sysctl command on FreeBSD
In order to improve performance and help prevent crashes due to the outstanding fork crash bug:
https://github.com/golang/go/issues/15658

Replace string parsed values from the sysctl command with native reads of sysctl values using unix.SysctlRaw and unix.SysctlUint32.

This also merges OpenBSD and FreeBSD load implementations which are identical.
Yoshio HANAWA a889bcce1a Add type definitions for mips and mipsle
WAKAYAMA Shirou 114c78c777 [host]: add not implemented methods.
WAKAYAMA Shirou 9c5b318e0d [host] windows: define Virtualization()
Sean Chittenden 42a72cbfae
Add HostID support to the `solaris` build target.
Sean Chittenden 635b971c0e
Move from the `syscall` package to the `golang.org/x/sys/{unix,windows}`
Frank Schroeder a9e803ef6a
Fix data race in host.BootTime
Shirou WAKAYAMA cdcb9bb2ed [linux] host: fix typo
WAKAYAMA Shirou 25d50d5bc3 [linux]host: change to use filepath.Join
WAKAYAMA Shirou dfbb3e40da fix build bugs.
Shirou WAKAYAMA fee973abda [linux]host: fix HostTempreture func
shirou 8e36fe6d8f Merge pull request #334 from dotpy3/macos-linux-temperatures
Added temperatures sensors for macOS and Linux
WAKAYAMA Shirou e49a95f3d5 [host]darwin: PlatformInformation has been 5 values other is 4.
itnihao 490dbd4ea4 Add hostinfo Virtualization vmware
Eric Gourlaouen 22aefb460a Replaced sys by HostSys
Added TemperatureStat string test
Eric Gourlaouen 8b08ca5fdc added temperatures
WAKAYAMA Shirou f8ef680a47 error strings change to lowercase
James Nugent 408005be94 host: Add Solaris support for Info, {Boot,Up}time
This commit adds support for Info(), BootTime() and Uptime() in package
Host. It uses no cgo, preferring to parse the output of `kstat -p`
instead.

Thanks go to @gfrey for the parsing logic for `/etc/release` and `uname`.
shirou 23f4b7eb14 Merge pull request #323 from molecul/patch-2
Fix for getMachineGuid() return value
Shirou WAKAYAMA 85d3530ae8 fix test.
Alexey Galkin b1f19a76c7 Fix for getMachineGuid() return value
getMachineGuid() function return a empty value in x86 windows builds.
Issue: https://github.com/shirou/gopsutil/issues/322
Alexey Galkin 2287b035c8 Add new test 'TestHostGuid'
For issue: https://github.com/shirou/gopsutil/issues/322
tycho garen 22c56d292e close open files
Sean Chittenden 36f5033d97
Unconditionally lowercase the `HostID` from all supported platforms.
Sean Chittenden 650c4d595f
Use `HKLM/SOFTWARE\Microsoft\Cryptography`'s `MachineGuid` registry key to enable `HostID` support on Windows.
Cameron Sparr a213bf5e6d
run go fmt ./...
Sean Chittenden 955821b5ab
Add Go-native structs for Darwin/386 and FreeBSD/arm
Sam Kleinman 488c56586b add platform compatibility
shirou a2257218e1 Merge pull request #289 from DataDog/conor/cache-boot-time
Cache the boot time after first query.
Marco Pfatschbacher b4846b445b Add support for OpenBSD/amd64
This code is based on the FreeBSD version
and implements roughly the same feature set.
Conor Branagan 5afd6f21c9 Cache the boot time after first query.
When fetching stats on all processes at once there's a non-trivial amount of
time spent in the `BootTime` call. But since this value should never change
during a live process, we can use a cached version for all subsequent calls.
Shirou WAKAYAMA b9067179ef [host]darwin: change to use sw_vers to get platform version
shirou a8e24d70f9 Merge pull request #247 from lfittl/fallback-for-unsupported-architectures
Add fallback code for all unsupported operating systems
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.
Lukas Fittl 13aedadcde Add separate kernelVersion field to host information.
This is mostly intended for Linux, where we are returning the OS version
in the PlatformVersion field, which seems reasonable. Often it is still
useful to know which Linux kernel is running.

For FreeBSD and Darwin the kernel version matches the platform version,
since they previously used the kernel version for the platform version.

For Windows the kernel version is empty, since there is no clear way
to determine it.
Sean Chittenden d490d634ca
On Linux, attempt to read from /sys/class/dmi/id/product_uuid first
before falling back to kernel.random.boot_id.

`/sys/class/dmi/id/product_uuid` is still managed by permissions, so
for root-run processes where `/sys/class/dmi/id/product_uuid` is
available, the host's UUID will be used instead, otherwise the UUID
from kernel.random.boot_id will be used instead.
Sean Chittenden 59094cd5b7
Add HostID to the Host InfoStat struct returned from host.Info().
On supported hosts the value returned is a UUID (case preserving
from the value of the underlying OS).

For Linux this is generated once, randomly per boot.  For FreeBSD and
Darwin this is a more durable value that should persist across reboots.
Sean Chittenden 4f79984afe
Remove redefined import name for common.
Sean Chittenden a3f57b1314
Resolve cyclic import and create a common helper func, NumProcs()
Sean Chittenden fcd296ea11
Merge branch 'master' of github.com:shirou/gopsutil
Sean Chittenden 69f7f8eaeb
Update host.Info() to return the number of processes on all platforms.
Fixes: #227
Shirou WAKAYAMA dd9b50926c [host]linux: add coreos to Info() and Virtualization().
WAKAYAMA Shirou 53406b2832 [host]Windows: BootTime and Uptime are reversed on Windows.
Shirou WAKAYAMA e9afb36ccf [host] linux: detect docker and rkt correctly
Shirou WAKAYAMA c0d1185809 [host]linux: add alpine linux to detect host.Info().
Shirou WAKAYAMA 57f6aebc7e add Timeout to invoke command and use common.Invoke refs: #201
Johannes 'fish' Ziemke 2a69690d62 Add type definitions for arm64 and ppc64le
WAKAYAMA shirou e864f2a037 [disk]freebsd: update 386.
WAKAYAMA shirou 01832c6a58 [host]freebsd: add freebsd_386.
WAKAYAMA shirou d9e994bec8 [host]freebsd: update freebsd_amd64
Shirou WAKAYAMA ce98590a35 [host]linux: forgot to add sizeOfUtmp.
Shirou WAKAYAMA 15ff7e19df [host]linux: fix i386 and gofmt.
Shirou WAKAYAMA b1df5a912c [host]linux: type file changed.
Shirou WAKAYAMA 0787e8ba3e [host]linux-arm: update type_liux.go. Test will fail.
Shirou WAKAYAMA bce9212def fix build bugs.
Shirou WAKAYAMA d21ed2b40d search path via exec.LookPath before actual invoke.
Shirou WAKAYAMA 4bb84648bf JSON representation is renamed to fit Google JSON style, camelCase.
Shirou WAKAYAMA ea152ea901 [BREAKING CHANGE] rename functions to pass golint. ex) net.NetIOCounters -> net.IOCounters
Shirou WAKAYAMA fa3e1cc196 [common]linux: add HostEtc to switch '/etc' See #175.
Robin Burchell 55cacb4730 host_darwin: Use a named constant for USER_PROCESS.
Matches the host_linux change.
Robin Burchell 3fc7bc1ef7 host_linux: Skip everything that isn't a normal process.
host_darwin does the same filtering. Not doing this gives us some rather strange
entries that likely aren't what we want.

Before:
    {"user":"reboot","terminal":"~","host":"3.10.0-327.4.5.el7.x86_64","started":1454378260}
    {"user":"LOGIN","terminal":"ttyS0","host":"","started":1454378270}
    {"user":"LOGIN","terminal":"tty1","host":"","started":1454378270}
    {"user":"runlevel","terminal":"~","host":"3.10.0-327.4.5.el7.x86_64","started":1454378276}
    {"user":"root","terminal":"pts/0","host":"vpn","started":1454404513}

After:
    {"user":"root","terminal":"pts/0","host":"vpn","started":1454404513}
Paul Querna 008f2b4e18 Get Arch Linux Version from LSB
WAKAYAMA shirou 54a6c186c1 host[freebsd]: BREAKING CHANGE. Boottime() should return uint64 same as other.
Shirou WAKAYAMA 0afd653fab host[all]: fix #114 String() issue.
Cameron Sparr 444ee723c3 Fix HostInfo.Uptime, which has been returning boot time
Also adding a HostInfo.BootTime field for holding the boot time
Shirou WAKAYAMA 7288e9a5af common[all]: add internal
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
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.
Nick Galbreath 99d93f93b2 shirou/gopsutil#90 make hostinfo more robust
Shirou WAKAYAMA 3303647209 host[linux]: fix utmp struct on arm.
mayowa bf16d0a6a7 modified PlatformVersion and PlatformFamily string to (somewhat) match the output from sysinfo
mayowa ee43e655c2 implemented GetPlatformInfo and refactored HostInfo() to use it
mayowa 56d70ecc5e implemented HostStatInfo.Platform* for windows
WAKAYAMA shirou abb4086531 host[freebsd]: change to use utmpx for 9.0 or later.
Shirou WAKAYAMA ba88128af1 host_linux: change some virtualization check StringsContains to StringsHas.`
Shirou WAKAYAMA b5ffc220a6 common: Rename StringContains to StringsContains and add StringsHas.
Shirou WAKAYAMA 3bd9ace228 [linux] fix Host.BootTime(). It was seconds from Booted, not from epoch.
Fabian Ruff 91a97374c4 Add SuSe platform detection
WAKAYAMA shirou 64357f04e7 use StackExchange/wmi instead of invoking wmic process.
Note: This may not work on some old Windows XP.
WAKAYAMA Shirou 5f8b99aa65 windows: GetWmic returns [][]string where string split by ","
Shirou WAKAYAMA 8f05d68a09 host: forget to convert to uint64.
Shirou WAKAYAMA 515398a6f6 host: Boottime return type was wrong on darwin #40
WAKAYAMA Shirou 4b0f5a03dc host: use wmic OS instead of calling GetTickCount on Windows.
若山史郎 f2435bc8de host: skip if utmp.Type is not USERPROCESS (defined in utmpx.h)
若山史郎 a5d366a70c host: Users() on darwin works. but Started is not correct.
rekby 29807862fb + host and process for linux 386
Shirou WAKAYAMA cfb473f810 host linux now use godefs.
WAKAYAMA shirou 64f1a93c00 forget to add.
WAKAYAMA shirou b0c9f81246 host_freebsd now use godefs
Shirou WAKAYAMA 13cd195a7e change package name.
Shirou WAKAYAMA 1cb67eb4c2 merge 039b9defab
Shirou WAKAYAMA 16de570414 merge 039b9defab
WAKAYAMA Shirou 9f2c985a28 fix windows build.
Shirou WAKAYAMA a1c1d7b25f fix on Linux.
WAKAYAMA shirou d11680c773 fix bugs on FreeBSD.
Shirou WAKAYAMA a4671fcc2a move subdirectories. refer to issue #24