mirror of
https://github.com/shirou/gopsutil.git
synced 2025-04-24 13:48:56 +08:00
Spelling and grammar fixes
This commit is contained in:
parent
696bb11b1e
commit
1e56c6f421
2
LICENSE
2
LICENSE
@ -28,7 +28,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
|
|
||||||
|
|
||||||
-------
|
-------
|
||||||
internal/common/binary.go in the gopsutil is copied and modifid from golang/encoding/binary.go.
|
internal/common/binary.go in the gopsutil is copied and modified from golang/encoding/binary.go.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ challenge is porting all psutil functions on some architectures.
|
|||||||
|
|
||||||
## v3 migration
|
## v3 migration
|
||||||
|
|
||||||
from v3.20.10, gopsutil becomes v3 which breaks backwards compatiblity.
|
from v3.20.10, gopsutil becomes v3 which breaks backwards compatibility.
|
||||||
See [v3Changes.md](_tools/v3migration/v3Changes.md) more detail changes.
|
See [v3Changes.md](_tools/v3migration/v3Changes.md) more detail changes.
|
||||||
|
|
||||||
## Tag semantics
|
## Tag semantics
|
||||||
@ -21,7 +21,7 @@ for example, v2.17.04 means
|
|||||||
- 17: release year, 2017
|
- 17: release year, 2017
|
||||||
- 04: release month
|
- 04: release month
|
||||||
|
|
||||||
gopsutil aims to keep backwards-compatiblity until major version change.
|
gopsutil aims to keep backwards compatibility until major version change.
|
||||||
|
|
||||||
Tagged at every end of month, but if there are only a few commits, it
|
Tagged at every end of month, but if there are only a few commits, it
|
||||||
can be skipped.
|
can be skipped.
|
||||||
@ -229,7 +229,7 @@ Some code is ported from Ohai. many thanks.
|
|||||||
|**HostInfo** | | | | | | |
|
|**HostInfo** | | | | | | |
|
||||||
|hostname |x |x |x |x |x |x |
|
|hostname |x |x |x |x |x |x |
|
||||||
|uptime |x |x |x |x | |x |
|
|uptime |x |x |x |x | |x |
|
||||||
|proces |x |x |x | | |x |
|
|process |x |x |x | | |x |
|
||||||
|os |x |x |x |x |x |x |
|
|os |x |x |x |x |x |x |
|
||||||
|platform |x |x |x |x | |x |
|
|platform |x |x |x |x | |x |
|
||||||
|platformfamily |x |x |x |x | |x |
|
|platformfamily |x |x |x |x | |x |
|
||||||
|
@ -57,7 +57,7 @@ func GetDockerStatWithContext(ctx context.Context) ([]CgroupDockerStat, error) {
|
|||||||
return ret, nil
|
return ret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetDockerIDList returnes a list of DockerID.
|
// GetDockerIDList returns a list of DockerID.
|
||||||
// This requires certain permission.
|
// This requires certain permission.
|
||||||
func GetDockerIDList() ([]string, error) {
|
func GetDockerIDList() ([]string, error) {
|
||||||
return GetDockerIDListWithContext(context.Background())
|
return GetDockerIDListWithContext(context.Background())
|
||||||
@ -86,7 +86,7 @@ func GetDockerIDListWithContext(ctx context.Context) ([]string, error) {
|
|||||||
return ret, nil
|
return ret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CgroupCPU returnes specified cgroup id CPU status.
|
// CgroupCPU returns specified cgroup id CPU status.
|
||||||
// containerID is same as docker id if you use docker.
|
// containerID is same as docker id if you use docker.
|
||||||
// If you use container via systemd.slice, you could use
|
// If you use container via systemd.slice, you could use
|
||||||
// containerID = docker-<container id>.scope and base=/sys/fs/cgroup/cpuacct/system.slice/
|
// containerID = docker-<container id>.scope and base=/sys/fs/cgroup/cpuacct/system.slice/
|
||||||
@ -94,7 +94,7 @@ func CgroupCPU(containerID string, base string) (*CgroupCPUStat, error) {
|
|||||||
return CgroupCPUWithContext(context.Background(), containerID, base)
|
return CgroupCPUWithContext(context.Background(), containerID, base)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CgroupCPUUsage returnes specified cgroup id CPU usage.
|
// CgroupCPUUsage returns specified cgroup id CPU usage.
|
||||||
// containerID is same as docker id if you use docker.
|
// containerID is same as docker id if you use docker.
|
||||||
// If you use container via systemd.slice, you could use
|
// If you use container via systemd.slice, you could use
|
||||||
// containerID = docker-<container id>.scope and base=/sys/fs/cgroup/cpuacct/system.slice/
|
// containerID = docker-<container id>.scope and base=/sys/fs/cgroup/cpuacct/system.slice/
|
||||||
|
@ -19,7 +19,7 @@ func GetDockerStatWithContext(ctx context.Context) ([]CgroupDockerStat, error) {
|
|||||||
return nil, ErrDockerNotAvailable
|
return nil, ErrDockerNotAvailable
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetDockerIDList returnes a list of DockerID.
|
// GetDockerIDList returns a list of DockerID.
|
||||||
// This requires certain permission.
|
// This requires certain permission.
|
||||||
func GetDockerIDList() ([]string, error) {
|
func GetDockerIDList() ([]string, error) {
|
||||||
return GetDockerIDListWithContext(context.Background())
|
return GetDockerIDListWithContext(context.Background())
|
||||||
@ -29,7 +29,7 @@ func GetDockerIDListWithContext(ctx context.Context) ([]string, error) {
|
|||||||
return nil, ErrDockerNotAvailable
|
return nil, ErrDockerNotAvailable
|
||||||
}
|
}
|
||||||
|
|
||||||
// CgroupCPU returnes specified cgroup id CPU status.
|
// CgroupCPU returns specified cgroup id CPU status.
|
||||||
// containerid is same as docker id if you use docker.
|
// containerid is same as docker id if you use docker.
|
||||||
// If you use container via systemd.slice, you could use
|
// If you use container via systemd.slice, you could use
|
||||||
// containerid = docker-<container id>.scope and base=/sys/fs/cgroup/cpuacct/system.slice/
|
// containerid = docker-<container id>.scope and base=/sys/fs/cgroup/cpuacct/system.slice/
|
||||||
|
@ -64,7 +64,7 @@ func (i Invoke) CommandWithContext(ctx context.Context, name string, arg ...stri
|
|||||||
|
|
||||||
type FakeInvoke struct {
|
type FakeInvoke struct {
|
||||||
Suffix string // Suffix species expected file name suffix such as "fail"
|
Suffix string // Suffix species expected file name suffix such as "fail"
|
||||||
Error error // If Error specfied, return the error.
|
Error error // If Error specified, return the error.
|
||||||
}
|
}
|
||||||
|
|
||||||
// Command in FakeInvoke returns from expected file if exists.
|
// Command in FakeInvoke returns from expected file if exists.
|
||||||
|
@ -39,7 +39,7 @@ func AvgWithContext(ctx context.Context) (*AvgStat, error) {
|
|||||||
return ret, nil
|
return ret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Misc returnes miscellaneous host-wide statistics.
|
// Misc returns miscellaneous host-wide statistics.
|
||||||
// darwin use ps command to get process running/blocked count.
|
// darwin use ps command to get process running/blocked count.
|
||||||
// Almost same as FreeBSD implementation, but state is different.
|
// Almost same as FreeBSD implementation, but state is different.
|
||||||
// U means 'Uninterruptible Sleep'.
|
// U means 'Uninterruptible Sleep'.
|
||||||
|
@ -68,7 +68,7 @@ func fileAvgWithContext() (*AvgStat, error) {
|
|||||||
return ret, nil
|
return ret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Misc returnes miscellaneous host-wide statistics.
|
// Misc returns miscellaneous host-wide statistics.
|
||||||
// Note: the name should be changed near future.
|
// Note: the name should be changed near future.
|
||||||
func Misc() (*MiscStat, error) {
|
func Misc() (*MiscStat, error) {
|
||||||
return MiscWithContext(context.Background())
|
return MiscWithContext(context.Background())
|
||||||
|
@ -305,7 +305,7 @@ func fillFromMeminfoWithContext() (*VirtualMemoryStat, *VirtualMemoryExStat, err
|
|||||||
|
|
||||||
if !memavail {
|
if !memavail {
|
||||||
if activeFile && inactiveFile && sReclaimable {
|
if activeFile && inactiveFile && sReclaimable {
|
||||||
ret.Available = calcuateAvailVmem(ret, retEx)
|
ret.Available = calculateAvailVmem(ret, retEx)
|
||||||
} else {
|
} else {
|
||||||
ret.Available = ret.Cached + ret.Free
|
ret.Available = ret.Cached + ret.Free
|
||||||
}
|
}
|
||||||
@ -387,10 +387,10 @@ func SwapMemoryWithContext(ctx context.Context) (*SwapMemoryStat, error) {
|
|||||||
return ret, nil
|
return ret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// calcuateAvailVmem is a fallback under kernel 3.14 where /proc/meminfo does not provide
|
// calculateAvailVmem is a fallback under kernel 3.14 where /proc/meminfo does not provide
|
||||||
// "MemAvailable:" column. It reimplements an algorithm from the link below
|
// "MemAvailable:" column. It reimplements an algorithm from the link below
|
||||||
// https://github.com/giampaolo/psutil/pull/890
|
// https://github.com/giampaolo/psutil/pull/890
|
||||||
func calcuateAvailVmem(ret *VirtualMemoryStat, retEx *VirtualMemoryExStat) uint64 {
|
func calculateAvailVmem(ret *VirtualMemoryStat, retEx *VirtualMemoryExStat) uint64 {
|
||||||
var watermarkLow uint64
|
var watermarkLow uint64
|
||||||
|
|
||||||
fn := common.HostProc("zoneinfo")
|
fn := common.HostProc("zoneinfo")
|
||||||
|
@ -105,7 +105,7 @@ func IOCountersWithContext(ctx context.Context, pernic bool) ([]IOCountersStat,
|
|||||||
return iocounters, nil
|
return iocounters, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// NetIOCountersByFile is an method which is added just a compatibility for linux.
|
// IOCountersByFile exists just for compatibility with Linux.
|
||||||
func IOCountersByFile(pernic bool, filename string) ([]IOCountersStat, error) {
|
func IOCountersByFile(pernic bool, filename string) ([]IOCountersStat, error) {
|
||||||
return IOCountersByFileWithContext(context.Background(), pernic, filename)
|
return IOCountersByFileWithContext(context.Background(), pernic, filename)
|
||||||
}
|
}
|
||||||
|
@ -257,7 +257,7 @@ func IOCountersWithContext(ctx context.Context, pernic bool) ([]IOCountersStat,
|
|||||||
return ret, nil
|
return ret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// NetIOCountersByFile is an method which is added just a compatibility for linux.
|
// IOCountersByFile exists just for compatibility with Linux.
|
||||||
func IOCountersByFile(pernic bool, filename string) ([]IOCountersStat, error) {
|
func IOCountersByFile(pernic bool, filename string) ([]IOCountersStat, error) {
|
||||||
return IOCountersByFileWithContext(context.Background(), pernic, filename)
|
return IOCountersByFileWithContext(context.Background(), pernic, filename)
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,7 @@ func IOCountersWithContext(ctx context.Context, pernic bool) ([]IOCountersStat,
|
|||||||
return ret, nil
|
return ret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// NetIOCountersByFile is an method which is added just a compatibility for linux.
|
// IOCountersByFile exists just for compatibility with Linux.
|
||||||
func IOCountersByFile(pernic bool, filename string) ([]IOCountersStat, error) {
|
func IOCountersByFile(pernic bool, filename string) ([]IOCountersStat, error) {
|
||||||
return IOCountersByFileWithContext(context.Background(), pernic, filename)
|
return IOCountersByFileWithContext(context.Background(), pernic, filename)
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ const ( // Conntrack Column numbers
|
|||||||
ctSEARCH_RESTART
|
ctSEARCH_RESTART
|
||||||
)
|
)
|
||||||
|
|
||||||
// NetIOCounters returnes network I/O statistics for every network
|
// NetIOCounters returns network I/O statistics for every network
|
||||||
// interface installed on the system. If pernic argument is false,
|
// interface installed on the system. If pernic argument is false,
|
||||||
// return only sum of all information (which name is 'all'). If true,
|
// return only sum of all information (which name is 'all'). If true,
|
||||||
// every network interface installed on the system is returned
|
// every network interface installed on the system is returned
|
||||||
@ -188,7 +188,7 @@ func ProtoCountersWithContext(ctx context.Context, protocols []string) ([]ProtoC
|
|||||||
line := lines[i]
|
line := lines[i]
|
||||||
r := strings.IndexRune(line, ':')
|
r := strings.IndexRune(line, ':')
|
||||||
if r == -1 {
|
if r == -1 {
|
||||||
return nil, errors.New(filename + " is not fomatted correctly, expected ':'.")
|
return nil, errors.New(filename + " is not formatted correctly, expected ':'.")
|
||||||
}
|
}
|
||||||
proto := strings.ToLower(line[:r])
|
proto := strings.ToLower(line[:r])
|
||||||
if !protos[proto] {
|
if !protos[proto] {
|
||||||
@ -204,7 +204,7 @@ func ProtoCountersWithContext(ctx context.Context, protocols []string) ([]ProtoC
|
|||||||
i++
|
i++
|
||||||
statValues := strings.Split(lines[i][r+2:], " ")
|
statValues := strings.Split(lines[i][r+2:], " ")
|
||||||
if len(statNames) != len(statValues) {
|
if len(statNames) != len(statValues) {
|
||||||
return nil, errors.New(filename + " is not fomatted correctly, expected same number of columns.")
|
return nil, errors.New(filename + " is not formatted correctly, expected same number of columns.")
|
||||||
}
|
}
|
||||||
stat := ProtoCountersStat{
|
stat := ProtoCountersStat{
|
||||||
Protocol: proto,
|
Protocol: proto,
|
||||||
@ -539,7 +539,7 @@ func statsFromInodes(root string, pid int32, tmap []netConnectionKindType, inode
|
|||||||
return ret, nil
|
return ret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// getProcInodes returnes fd of the pid.
|
// getProcInodes returns fd of the pid.
|
||||||
func getProcInodes(root string, pid int32, max int) (map[string][]inodeMap, error) {
|
func getProcInodes(root string, pid int32, max int) (map[string][]inodeMap, error) {
|
||||||
ret := make(map[string][]inodeMap)
|
ret := make(map[string][]inodeMap)
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ func IOCountersWithContext(ctx context.Context, pernic bool) ([]IOCountersStat,
|
|||||||
return ret, nil
|
return ret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// NetIOCountersByFile is an method which is added just a compatibility for linux.
|
// IOCountersByFile exists just for compatibility with Linux.
|
||||||
func IOCountersByFile(pernic bool, filename string) ([]IOCountersStat, error) {
|
func IOCountersByFile(pernic bool, filename string) ([]IOCountersStat, error) {
|
||||||
return IOCountersByFileWithContext(context.Background(), pernic, filename)
|
return IOCountersByFileWithContext(context.Background(), pernic, filename)
|
||||||
}
|
}
|
||||||
|
@ -200,7 +200,7 @@ func IOCountersWithContext(ctx context.Context, pernic bool) ([]IOCountersStat,
|
|||||||
return counters, nil
|
return counters, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// NetIOCountersByFile is an method which is added just a compatibility for linux.
|
// IOCountersByFile exists just for compatibility with Linux.
|
||||||
func IOCountersByFile(pernic bool, filename string) ([]IOCountersStat, error) {
|
func IOCountersByFile(pernic bool, filename string) ([]IOCountersStat, error) {
|
||||||
return IOCountersByFileWithContext(context.Background(), pernic, filename)
|
return IOCountersByFileWithContext(context.Background(), pernic, filename)
|
||||||
}
|
}
|
||||||
|
@ -47,13 +47,13 @@ type Process struct {
|
|||||||
const (
|
const (
|
||||||
// Running marks a task a running or runnable (on the run queue)
|
// Running marks a task a running or runnable (on the run queue)
|
||||||
Running = "running"
|
Running = "running"
|
||||||
// Blocked marks a task waiting on a short, uninterruptable operation (usually IO)
|
// Blocked marks a task waiting on a short, uninterruptible operation (usually I/O)
|
||||||
Blocked = "blocked"
|
Blocked = "blocked"
|
||||||
// Idle marks a task sleeping for more than about 20 seconds
|
// Idle marks a task sleeping for more than about 20 seconds
|
||||||
Idle = "idle"
|
Idle = "idle"
|
||||||
// Lock marks a task waiting to acquire a lock
|
// Lock marks a task waiting to acquire a lock
|
||||||
Lock = "lock"
|
Lock = "lock"
|
||||||
// Sleep marks task waiting for short, interruptable operation
|
// Sleep marks task waiting for short, interruptible operation
|
||||||
Sleep = "sleep"
|
Sleep = "sleep"
|
||||||
// Stop marks a stopped process
|
// Stop marks a stopped process
|
||||||
Stop = "stop"
|
Stop = "stop"
|
||||||
@ -230,7 +230,7 @@ func (p *Process) BackgroundWithContext(ctx context.Context) (bool, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If interval is 0, return difference from last call(non-blocking).
|
// If interval is 0, return difference from last call(non-blocking).
|
||||||
// If interval > 0, wait interval sec and return diffrence between start and end.
|
// If interval > 0, wait interval sec and return difference between start and end.
|
||||||
func (p *Process) Percent(interval time.Duration) (float64, error) {
|
func (p *Process) Percent(interval time.Duration) (float64, error) {
|
||||||
return p.PercentWithContext(context.Background(), interval)
|
return p.PercentWithContext(context.Background(), interval)
|
||||||
}
|
}
|
||||||
|
@ -526,7 +526,7 @@ func (p *Process) fillFromLimitsWithContext() ([]RlimitStat, error) {
|
|||||||
// Assert that last item is a Hard limit
|
// Assert that last item is a Hard limit
|
||||||
statItem.Hard, err = limitToUint(str[len(str)-1])
|
statItem.Hard, err = limitToUint(str[len(str)-1])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// On error remove last item an try once again since it can be unit or header line
|
// On error remove last item and try once again since it can be unit or header line
|
||||||
str = str[:len(str)-1]
|
str = str[:len(str)-1]
|
||||||
statItem.Hard, err = limitToUint(str[len(str)-1])
|
statItem.Hard, err = limitToUint(str[len(str)-1])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -189,7 +189,7 @@ type winLUIDAndAttributes struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TOKEN_PRIVILEGES
|
// TOKEN_PRIVILEGES
|
||||||
type winTokenPriviledges struct {
|
type winTokenPrivileges struct {
|
||||||
PrivilegeCount winDWord
|
PrivilegeCount winDWord
|
||||||
Privileges [1]winLUIDAndAttributes
|
Privileges [1]winLUIDAndAttributes
|
||||||
}
|
}
|
||||||
@ -218,23 +218,23 @@ func init() {
|
|||||||
}
|
}
|
||||||
defer token.Close()
|
defer token.Close()
|
||||||
|
|
||||||
tokenPriviledges := winTokenPriviledges{PrivilegeCount: 1}
|
tokenPrivileges := winTokenPrivileges{PrivilegeCount: 1}
|
||||||
lpName := syscall.StringToUTF16("SeDebugPrivilege")
|
lpName := syscall.StringToUTF16("SeDebugPrivilege")
|
||||||
ret, _, _ := procLookupPrivilegeValue.Call(
|
ret, _, _ := procLookupPrivilegeValue.Call(
|
||||||
0,
|
0,
|
||||||
uintptr(unsafe.Pointer(&lpName[0])),
|
uintptr(unsafe.Pointer(&lpName[0])),
|
||||||
uintptr(unsafe.Pointer(&tokenPriviledges.Privileges[0].Luid)))
|
uintptr(unsafe.Pointer(&tokenPrivileges.Privileges[0].Luid)))
|
||||||
if ret == 0 {
|
if ret == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
tokenPriviledges.Privileges[0].Attributes = 0x00000002 // SE_PRIVILEGE_ENABLED
|
tokenPrivileges.Privileges[0].Attributes = 0x00000002 // SE_PRIVILEGE_ENABLED
|
||||||
|
|
||||||
procAdjustTokenPrivileges.Call(
|
procAdjustTokenPrivileges.Call(
|
||||||
uintptr(token),
|
uintptr(token),
|
||||||
0,
|
0,
|
||||||
uintptr(unsafe.Pointer(&tokenPriviledges)),
|
uintptr(unsafe.Pointer(&tokenPrivileges)),
|
||||||
uintptr(unsafe.Sizeof(tokenPriviledges)),
|
uintptr(unsafe.Sizeof(tokenPrivileges)),
|
||||||
0,
|
0,
|
||||||
0)
|
0)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user