1
0
mirror of https://github.com/shirou/gopsutil.git synced 2025-05-01 13:48:52 +08:00

585 Commits

Author SHA1 Message Date
Johan Walles
3232d34b24 Add test for process.CPUTimes() 2016-02-24 04:25:41 +01:00
shirou
1d09f7a4e9 Merge pull request #160 from walles/walles/vmtest
Document + add tests for for mem.VirtualMemory()
2016-02-22 15:56:05 +09:00
Johan Walles
dd875d4970 Fix memory stats on Darwin, non-CGO 2016-02-22 07:29:15 +01:00
Johan Walles
d109284df3 Fix memory stats on Darwin, CGO 2016-02-22 07:28:55 +01:00
Johan Walles
27093ae2d2 mem_darwin_test.go: Compare total to sysctl hw.memsize 2016-02-22 07:28:55 +01:00
Johan Walles
0d5592714b Fix memory stats on LinuxFreeBSD 2016-02-22 07:28:44 +01:00
Johan Walles
66a07939f7 Fix memory stats on Linux 2016-02-21 20:56:11 +01:00
Johan Walles
4438159155 Document + add tests for for mem.VirtualMemory()
This change changes and documents the (previously undocumented) behavior of Used
to "RAM used by programs".

We also remove the undocumented and unused Shared field of that struct.

So with this change in place, the VirtualMemoryStruct contains:
* three human-consumable fields for Total, Used and Available memory
* one human-consumable UsedPercentage field
* a number of kernel specific fields
2016-02-21 20:56:11 +01:00
shirou
e04a02d2d7 Merge pull request #161 from walles/walles/darwin-vmperf
Use OS calls rather than exec() to get memory stats on Darwin
2016-02-21 22:06:43 +09:00
Johan Walles
44f817eb8d Split mem_darwin.go into CGO and non CGO variants 2016-02-20 21:49:23 +01:00
Johan Walles
00504a37e3 Remove unused import 2016-02-19 23:39:00 +01:00
Johan Walles
a6cd6f803b Use Go's built in syscall.Getpagesize() 2016-02-19 23:37:43 +01:00
Johan Walles
13e00c76e4 Use OS calls rather than exec() to get memory statistics
Before this change we used to exec() various binaries to find out memory
information.

While this worked, it was awfully slow.

And if somebody would want to compute how many percent of available memory all
PIDs on the system uses, that would take almost ten seconds on my laptop with
the previous implementation.

This implementation fares a lot better, and is smaller.
2016-02-19 21:28:50 +01:00
Johan Walles
5771ea9465 Add Darwin specific mem.VirtualMemory() tests 2016-02-19 20:53:29 +01:00
Shirou WAKAYAMA
3166d41538 set LC_ALL to C in order to avoid number formatting problem. 2016-02-17 16:29:35 +09:00
shirou
79f021f66e Merge pull request #158 from walles/walles/darwin-memorypercent
process: Implement MemoryPercent() for Darwin
2016-02-17 12:18:26 +09:00
Johan Walles
70444b571b process: Implement platform independent MemoryPercent()
It calls mem.VirtualMemory() and process.MemoryInfo(), so on the platforms where
those work MemoryPercent() will as well.

Tested on Darwin.
2016-02-16 20:22:04 +01:00
shirou
956f92742f Merge pull request #156 from shirou/add_build_check
Add build check
2016-02-13 00:04:49 +09:00
Shirou WAKAYAMA
01ddce7ff6 test verbose. 2016-02-13 00:02:33 +09:00
Shirou WAKAYAMA
cb5866a546 we can not test other arch. 2016-02-12 23:58:01 +09:00
Shirou WAKAYAMA
fb3a6df695 add other platform test 2016-02-12 23:54:20 +09:00
Shirou WAKAYAMA
e21c97d3b2 [process]darwin: forget to change as binary.go movement. 2016-02-12 23:53:53 +09:00
WAKAYAMA shirou
0af91ba32b [disk,process]freebsd: binary.go moved to internal. 2016-02-12 23:10:40 +09:00
shirou
614df95d72 Merge pull request #155 from shirou/add_circleci
add circle.yml.
2016-02-12 22:55:46 +09:00
Shirou WAKAYAMA
fe4c9f8ffa change CI status badge to CircleCI. 2016-02-12 22:53:22 +09:00
Shirou WAKAYAMA
5a09d40f6b [process]darwin: expected ps file was changed. 2016-02-12 22:50:06 +09:00
Shirou WAKAYAMA
c822415e22 Merge branch 'master' into add_circleci 2016-02-12 22:48:53 +09:00
shirou
7fd975a4c0 Merge pull request #153 from walles/walles/processusername
Return correct user name from process.Username()
2016-02-12 22:47:10 +09:00
Shirou WAKAYAMA
7f22150707 CPU num is different on the CircleCI environemnt, so we skip it. 2016-02-12 22:44:17 +09:00
Shirou WAKAYAMA
c54ae65e78 add circle.yml. 2016-02-12 22:28:52 +09:00
Johan Walles
17db0319c8 Empty commit to trigger CI 2016-02-12 14:07:30 +01:00
Johan Walles
09fbecef59 Darwin: Remove questionable UIDs
process.Process.uids is an array of undocumented values.

That one of them is the user that the process is running as is obvious, but what
the other two are supposed to be is AFAICT undocumented.

On Darwin, the second and third UID (out of three) seem to always be 0.

This change removes the two always-zero UIDs from the process.Process struct on
Darwin, and leaves just the one that actually identifies the user the process
is running as.
2016-02-12 10:58:55 +01:00
Johan Walles
e3a7a45492 process.Username(): Correct user names on Darwin
Before this change, process.Username() returned "root" for all processes on
Darwin.
2016-02-12 10:54:41 +01:00
shirou
70b7a99f9b Merge pull request #152 from walles/walles/total-cpu-time
Make a public function for computing total CPU time
2016-02-12 00:07:32 +09:00
Johan Walles
ebaa641e63 Make a public function for computing total CPU time
This function used to be a private part of process.go.

Since I needed that functionality however I think it's better to make it public
than for me to copy it into my own code.

As a side effect of this change, I also fixed a bug in the function where Stolen
was not part of the sum. Having the function close to the CPUTimesStat
declaration will make problems like this less likely to re-occur in the future.
2016-02-10 17:53:39 +01:00
shirou
b7e206ba77 Merge pull request #151 from vrecan/mem_info
fix meminfo output on consecutive calls
2016-02-10 11:28:44 +09:00
Ben Aldrich
faeb99d327 fix meminfo output on consecutive calls 2016-02-09 18:57:56 -07:00
shirou
e77438504d Merge pull request #144 from weberr13/noChildrenError
There are two possible error scenarios for CallPgrep.
2016-02-09 10:57:08 +09:00
Robert Weber
c804a9e755 Per suggestions 2016-02-08 09:26:35 -07:00
shirou
59b63dedef Merge pull request #148 from cactus/sysctl-go
try to fix diskio stats on FreeBSD-10.x
2016-02-07 22:54:03 +09:00
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.
2016-02-06 06:20:52 -08:00
Robert Weber
4dcb099f3d no or 2016-02-04 15:15:29 -07:00
Robert Weber
6496b57b3d Need to promote this error 2016-02-04 15:14:11 -07:00
Robert Weber
21daedd6b4 There are two possible error scenarios for CallPgrep. One indicates a broken
system (no pgrep command) and one is a normal error state of pgrep
meaning no processes found for the criteria given (in this case the parent
pid does not exist or the process simply has no children).  The later case
is quite usefull to know about so I added a static error for this case.
2016-02-04 15:06:36 -07:00
shirou
cc040ddf72 Merge pull request #139 from rburchell/master
host_linux: Skip everything that isn't a normal process.
2016-02-02 23:54:59 +09:00
Robin Burchell
55cacb4730 host_darwin: Use a named constant for USER_PROCESS.
Matches the host_linux change.
2016-02-02 15:23:34 +01:00
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}
2016-02-02 15:23:32 +01:00
shirou
41f99949e3 Merge pull request #141 from ovear/master
fix callps command generate error
2016-02-02 22:14:17 +09:00
Heretic
a0692cc17a 1)fix callps command generate error 2016-02-02 18:52:57 +08:00
shirou
9d8191d6a6 Merge pull request #137 from shirou/process/add_netiocounter_for_linux
[WIP] net,process[linux]: add process.NetIOCounter and net.NetIOCounterByFile.
2016-01-29 23:41:05 +09:00