Commit Graph

1217 Commits

Author SHA1 Message Date
Antoine Jacoutot 7276e963eb cpu: implement Mhz and Cores
Adapted from the FreeBSD code.
Successfully tested with Nomad.
2019-01-02 17:06:46 +01:00
Lomanic db425313bf
Merge pull request #623 from Lomanic/issue621
Fix #621 Add OpenBSD 6.4+ CPU States
2018-12-31 16:08:26 +01:00
Lomanic 56acda8a5b [process][openbsd] Fix compilation on OpenBSD 2018-12-29 15:24:58 +01:00
Lomanic 5f8353c741 [cpu][openbsd] Fix #621, define CPU states according to OpenBSD version 2018-12-29 15:24:52 +01:00
Lomanic 738b966ed1 [host][darwin] Use unix.Sysctl to get kernel version and platform name 2018-12-29 14:59:17 +01:00
Lomanic 8294f67566 [host][openbsd] Remove external calls to uname in PlatformInformation() 2018-12-29 14:56:23 +01:00
Lomanic ccc1c1016b [mem][darwin] Fix #622 include Inactive memory in total calculation in TestVirtual_memory 2018-12-25 21:55:58 +01:00
Lomanic 4104adff3e [process][windows] Fix #466 add SeDebugPrivilege to current process 2018-12-22 19:30:50 +01:00
Lomanic a5ace91cce [process][windows] Propagate context internally 2018-12-20 23:41:38 +01:00
Lomanic e5ca4477a1 [process][windows] WIP #586 use win32 API in process.Exe but fallback on WMI
This method only lets a 32bit program get other 32bit processes exe path
and a 64bit program get other 64bit processes exe path, so we fallback to
the slow (but kind of reliable) WMI calls if we can't access to the other
process module.
2018-12-20 23:16:25 +01:00
shirou 51e6519305
Merge pull request #619 from remeh/dm-name-trim
disk: trim the device mapper name.
2018-12-18 09:38:19 +09:00
Remy Mathieu fda98ebc34 disk: trim the device mapper name.
While reading the value of the file with `ioutil.ReadFile`,
the name is suffixed with a `\n`

Tested on Ubuntu 18.10
2018-12-17 10:59:17 +01:00
shirou d6b9922e03
Merge pull request #617 from mznet/master
SReclaimable should be summed to Cached Memory
2018-12-17 07:55:32 +09:00
Minje Park f9e238c38b SReclaimable should be added to Cached Memory 2018-12-14 00:48:38 +09:00
shirou cce2d16538 [process]: add missing argment to process_fallback. 2018-12-10 20:20:53 +09:00
Lomanic eead265362
Merge pull request #611 from marcospedreiro/master
[cpu][windows] cpu.Times(true) should not return percent values
2018-12-09 18:35:30 +01:00
Lomanic 21ddb4f6d5
Merge pull request #605 from Lomanic/issue596
Fix #596 Implement process.Background and process.Foreground functions
2018-12-08 18:54:20 +01:00
Lomanic 8002bddf3f Merge branch 'master' into issue596 2018-12-08 18:49:40 +01:00
shirou 35815938bf
Merge pull request #614 from joestringer/netns
[net][linux] Support socket tables in nested namespaces
2018-12-03 13:35:08 +09: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
Lomanic 0f70a4a06f
Merge pull request #609 from Lomanic/windows-process-children
[process][windows] Use win32 API in process.Children() instead of slow WMI call
2018-11-24 15:38:04 +01:00
shirou 852c7686b5
Merge pull request #613 from tmm1/allow-a-b-windows-drives
do not ignore A: and B: drives on windows
2018-11-21 20:19:05 +09:00
Lomanic 3b882b034c
Merge pull request #612 from tmm1/fix-typo
fix minor typo in disk_windows
2018-11-21 00:05:00 +01:00
marcospedreiro f0ebb60b86 handle pr comments: use assert.InEpsilon 2018-11-20 13:25:17 -08:00
Aman Gupta d021425af3 do not ignore A: and B: drives on windows
from https://www.howtogeek.com/122891/what-are-the-windows-a-and-b-drives-used-for/

>if your computer does not have floppy disk drives, you can assign A and B to volumes
2018-11-20 13:09:36 -08:00
Aman Gupta ab57d4a5fe fix minor typo in disk_windows 2018-11-20 13:04:18 -08:00
marcospedreiro d47801b68b revert imports 2018-11-19 22:06:05 -08:00
marcospedreiro 3cc34ebf18 windows cpu time (true) should return cpu time not percentages 2018-11-19 21:51:27 -08:00
Lomanic b0c24b4251
Merge pull request #610 from Lomanic/issue555
[disk][linux] Fix #555 Unescape escaped sequences in fstab path in disk.Partitions
2018-11-19 07:42:09 +01:00
marcospedreiro 45aeaebda5 test windows cpu.Time(true) returning time instead of percentages 2018-11-18 22:30:47 -08:00
Lomanic 8888537497 [disk][linux] Fix #555 Unescape escaped sequences in fstab path in disk.Partitions 2018-11-18 20:39:18 +01:00
Lomanic 6b539051d2 [process][windows] Use win32 API in process.Children() instead of slow WMI call
The CreateToolhelp32Snapshot+Process32First+Process32Next combo already
iterates over all processes, so it would be inefficient to enumerate all
processes with process.Processes() and then calling p.Ppid() on each of
them: we just use this combo to get all processes and their ppid in a
single iteration.

This is faster by a factor of 25 compared to the previous WMI call.
2018-11-18 20:22:18 +01:00
Lomanic 8ffa453390 #596 Amend last commit, add missing strconv pkg in process_freebsd.go 2018-11-17 18:27:04 +01:00
Lomanic 8ef9b01052 Fix process.Foreground for BSDs, add openbsd implementation 2018-11-11 19:05:34 +01:00
Lomanic 878e0a701b Fix #596 Implement process.Background and process.Foreground functions 2018-11-08 20:52:01 +01:00
shirou 48177ef5f8
Merge pull request #603 from pierresouchay/host_id_fixed_on_linux
Have a real fixed HostID on Linux
2018-11-07 20:16:21 +09:00
Pierre Souchay 890eb80501 Better comments for fallback on /etc/machine-id 2018-11-07 00:09:22 +01:00
Pierre Souchay be2b25a7c6 Have a real fixed HostID on Linux
On Linux, most golang programs do not run as root (or at least, they should not),
by default, the kernels uses strict permissions, so most userland programs cannot
read `/sys/class/dmi/id/product_uuid`. However, programs such as Consul are relying
on it to get fixed IDs, instead they have a different ID on each boot.

We propose to use `/etc/machine-id` as fallback https://www.freedesktop.org/software/systemd/man/machine-id.html

In order to fix this, this patch does the following:
 - if `/sys/class/dmi/id/product_uuid` can be read, use it for HostID
 - else if `/etc/machine-id` exists and has 32 chars, use it and add '-' to have the same format as product_uuid
 - finally, if notthing works, use the `kernel.random.boot_id`

This will greatly increase the number of programs having correct behaviour when
those rely on having a fixed HostID.

This will fix the following issues:
 - https://github.com/shirou/gopsutil/issues/350
 - https://github.com/hashicorp/consul/issues/4741
2018-11-06 18:06:40 +01:00
Lomanic 4254ce2081
Merge pull request #601 from Lomanic/issue551
Fix #551 Filter out '_Total' results from PerfInfoWithContext and unexport this function.

Also propagate context in perCPUTimes (renamed to perCPUTimesWithContext) and unexport Win32_PerfFormattedData_Counters_ProcessorInformation type.
2018-11-06 14:56:13 +01:00
Lomanic da37b31860 Create Github issue templates 2018-11-05 16:22:32 +01:00
Lomanic 79f8a73e23 Fix #551 Filter out '_Total' results from PerfInfoWithContext and unexport this function
Also propagate context in perCPUTimes (renamed to perCPUTimesWithContext)
and unexport Win32_PerfFormattedData_Counters_ProcessorInformation.
2018-11-05 12:28:39 +01:00
shirou 3ec50d2876
Merge pull request #595 from liu4480/dev
add CgroupCPUUsageDocker just like CgroupCPUDocker
2018-10-23 22:17:00 +09:00
Lomanic feffc5e3e1
Merge pull request #597 from liu4480/arg_in_lines
correct param in docker_linux.go for memory.stat
2018-10-23 12:36:06 +02:00
Bin Liu 4ef2371dda correct param in docker_linux.go for memory.stat
The version of docker on Ubuntu18.04 and Centos7 are old, and the
parameters in memory.stat on Ubuntu18.04 and Centos7 are as following:

cat /sys/fs/cgroup/memory/docker/33f962ca254969762d750ced9a97d8deef67535b96b1e8c17abd0939a3f2cbcf/memory.stat

cache 1110016
rss 413696
rss_huge 0
shmem 0
mapped_file 1015808
dirty 0
writeback 0
pgpgin 1610
pgpgout 1238
pgfault 1923
pgmajfault 12
inactive_anon 262144
active_anon 151552
inactive_file 0
active_file 1110016
unevictable 0
hierarchical_memory_limit 9223372036854771712
total_cache 1110016
total_rss 413696
total_rss_huge 0
total_shmem 0
total_mapped_file 1015808
total_dirty 0
total_writeback 0
total_pgpgin 1610
total_pgpgout 1238
total_pgfault 1923
total_pgmajfault 12
total_inactive_anon 262144
total_active_anon 151552
total_inactive_file 0
total_active_file 1110016
total_unevictable 0

this patch is for backward.
2018-10-23 10:20:21 +08:00
Bin Liu 601dd00812 add CgroupCPUUsageDocker just like CgroupCPUDocker 2018-10-19 18:44:19 +08:00
shirou a11c78ba2c
Merge pull request #581 from CMGS/master
get docker container cpu usage from cpuacct.usage
2018-09-27 21:43:08 +09:00
CMGS 80b3769ea3 not modify old API now 2018-09-21 11:22:23 +08:00
shirou 77e5abb6f0
migrate to circleci2 (#587)
* add circleci 2.0 config, which has golang 1.9 image.
2018-09-16 17:40:02 +09:00
shirou e50c47b503
Merge pull request #528 from pytimer/win_services
[windows]services: add windows service feature
2018-09-16 14:24:14 +09:00
shirou 6f5e32dd2f
Merge pull request #584 from Quasilyte/quasilyte/commentedOutCode
cpu,process: remove commented-out code
2018-09-15 11:30:41 +09:00