diff --git a/LICENSE b/LICENSE index da71a5e72..6f06adcbf 100644 --- a/LICENSE +++ b/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. diff --git a/README.md b/README.md index ad8be35f7..191f3c7fb 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ challenge is porting all psutil functions on some architectures. ## 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. ## Tag semantics @@ -21,7 +21,7 @@ for example, v2.17.04 means - 17: release year, 2017 - 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 can be skipped. @@ -229,7 +229,7 @@ Some code is ported from Ohai. many thanks. |**HostInfo** | | | | | | | |hostname |x |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 | |platform |x |x |x |x | |x | |platformfamily |x |x |x |x | |x | diff --git a/docker/docker_linux.go b/docker/docker_linux.go index 0c073122d..edcb8e4d4 100644 --- a/docker/docker_linux.go +++ b/docker/docker_linux.go @@ -57,7 +57,7 @@ func GetDockerStatWithContext(ctx context.Context) ([]CgroupDockerStat, error) { return ret, nil } -// GetDockerIDList returnes a list of DockerID. +// GetDockerIDList returns a list of DockerID. // This requires certain permission. func GetDockerIDList() ([]string, error) { return GetDockerIDListWithContext(context.Background()) @@ -86,7 +86,7 @@ func GetDockerIDListWithContext(ctx context.Context) ([]string, error) { 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. // If you use container via systemd.slice, you could use // containerID = docker-.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) } -// CgroupCPUUsage returnes specified cgroup id CPU usage. +// CgroupCPUUsage returns specified cgroup id CPU usage. // containerID is same as docker id if you use docker. // If you use container via systemd.slice, you could use // containerID = docker-.scope and base=/sys/fs/cgroup/cpuacct/system.slice/ diff --git a/docker/docker_notlinux.go b/docker/docker_notlinux.go index df335126d..2bd91110b 100644 --- a/docker/docker_notlinux.go +++ b/docker/docker_notlinux.go @@ -19,7 +19,7 @@ func GetDockerStatWithContext(ctx context.Context) ([]CgroupDockerStat, error) { return nil, ErrDockerNotAvailable } -// GetDockerIDList returnes a list of DockerID. +// GetDockerIDList returns a list of DockerID. // This requires certain permission. func GetDockerIDList() ([]string, error) { return GetDockerIDListWithContext(context.Background()) @@ -29,7 +29,7 @@ func GetDockerIDListWithContext(ctx context.Context) ([]string, error) { 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. // If you use container via systemd.slice, you could use // containerid = docker-.scope and base=/sys/fs/cgroup/cpuacct/system.slice/ diff --git a/internal/common/common.go b/internal/common/common.go index 9bfb3663a..4f6df9a3a 100644 --- a/internal/common/common.go +++ b/internal/common/common.go @@ -64,7 +64,7 @@ func (i Invoke) CommandWithContext(ctx context.Context, name string, arg ...stri type FakeInvoke struct { 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. diff --git a/load/load_darwin.go b/load/load_darwin.go index 73e62cab5..e0df3c9f3 100644 --- a/load/load_darwin.go +++ b/load/load_darwin.go @@ -39,7 +39,7 @@ func AvgWithContext(ctx context.Context) (*AvgStat, error) { 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. // Almost same as FreeBSD implementation, but state is different. // U means 'Uninterruptible Sleep'. diff --git a/load/load_linux.go b/load/load_linux.go index 30bba35e0..debf0733c 100644 --- a/load/load_linux.go +++ b/load/load_linux.go @@ -68,7 +68,7 @@ func fileAvgWithContext() (*AvgStat, error) { return ret, nil } -// Misc returnes miscellaneous host-wide statistics. +// Misc returns miscellaneous host-wide statistics. // Note: the name should be changed near future. func Misc() (*MiscStat, error) { return MiscWithContext(context.Background()) diff --git a/mem/mem_linux.go b/mem/mem_linux.go index cea5400ee..9a5967cae 100644 --- a/mem/mem_linux.go +++ b/mem/mem_linux.go @@ -305,7 +305,7 @@ func fillFromMeminfoWithContext() (*VirtualMemoryStat, *VirtualMemoryExStat, err if !memavail { if activeFile && inactiveFile && sReclaimable { - ret.Available = calcuateAvailVmem(ret, retEx) + ret.Available = calculateAvailVmem(ret, retEx) } else { ret.Available = ret.Cached + ret.Free } @@ -387,10 +387,10 @@ func SwapMemoryWithContext(ctx context.Context) (*SwapMemoryStat, error) { 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 // https://github.com/giampaolo/psutil/pull/890 -func calcuateAvailVmem(ret *VirtualMemoryStat, retEx *VirtualMemoryExStat) uint64 { +func calculateAvailVmem(ret *VirtualMemoryStat, retEx *VirtualMemoryExStat) uint64 { var watermarkLow uint64 fn := common.HostProc("zoneinfo") diff --git a/net/net_aix.go b/net/net_aix.go index d89db7ccf..84e36091c 100644 --- a/net/net_aix.go +++ b/net/net_aix.go @@ -105,7 +105,7 @@ func IOCountersWithContext(ctx context.Context, pernic bool) ([]IOCountersStat, 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) { return IOCountersByFileWithContext(context.Background(), pernic, filename) } diff --git a/net/net_darwin.go b/net/net_darwin.go index 9badcf6ac..ec9ba4174 100644 --- a/net/net_darwin.go +++ b/net/net_darwin.go @@ -257,7 +257,7 @@ func IOCountersWithContext(ctx context.Context, pernic bool) ([]IOCountersStat, 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) { return IOCountersByFileWithContext(context.Background(), pernic, filename) } diff --git a/net/net_freebsd.go b/net/net_freebsd.go index 0a30423de..50fe93a0e 100644 --- a/net/net_freebsd.go +++ b/net/net_freebsd.go @@ -95,7 +95,7 @@ func IOCountersWithContext(ctx context.Context, pernic bool) ([]IOCountersStat, 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) { return IOCountersByFileWithContext(context.Background(), pernic, filename) } diff --git a/net/net_linux.go b/net/net_linux.go index d323781c3..0d909fc0a 100644 --- a/net/net_linux.go +++ b/net/net_linux.go @@ -40,7 +40,7 @@ const ( // Conntrack Column numbers 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, // return only sum of all information (which name is 'all'). If true, // every network interface installed on the system is returned @@ -188,7 +188,7 @@ func ProtoCountersWithContext(ctx context.Context, protocols []string) ([]ProtoC line := lines[i] r := strings.IndexRune(line, ':') 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]) if !protos[proto] { @@ -204,7 +204,7 @@ func ProtoCountersWithContext(ctx context.Context, protocols []string) ([]ProtoC i++ statValues := strings.Split(lines[i][r+2:], " ") 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{ Protocol: proto, @@ -539,7 +539,7 @@ func statsFromInodes(root string, pid int32, tmap []netConnectionKindType, inode 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) { ret := make(map[string][]inodeMap) diff --git a/net/net_openbsd.go b/net/net_openbsd.go index 04b9b1d69..5f066a09f 100644 --- a/net/net_openbsd.go +++ b/net/net_openbsd.go @@ -139,7 +139,7 @@ func IOCountersWithContext(ctx context.Context, pernic bool) ([]IOCountersStat, 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) { return IOCountersByFileWithContext(context.Background(), pernic, filename) } diff --git a/net/net_windows.go b/net/net_windows.go index f742d8225..731c8f97b 100644 --- a/net/net_windows.go +++ b/net/net_windows.go @@ -200,7 +200,7 @@ func IOCountersWithContext(ctx context.Context, pernic bool) ([]IOCountersStat, 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) { return IOCountersByFileWithContext(context.Background(), pernic, filename) } diff --git a/process/process.go b/process/process.go index 9e6542e0c..0ca26c210 100644 --- a/process/process.go +++ b/process/process.go @@ -47,13 +47,13 @@ type Process struct { const ( // Running marks a task a running or runnable (on the run queue) 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" // Idle marks a task sleeping for more than about 20 seconds Idle = "idle" // Lock marks a task waiting to acquire a lock Lock = "lock" - // Sleep marks task waiting for short, interruptable operation + // Sleep marks task waiting for short, interruptible operation Sleep = "sleep" // Stop marks a stopped process 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 > 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) { return p.PercentWithContext(context.Background(), interval) } diff --git a/process/process_linux.go b/process/process_linux.go index ef953330d..8b7d3fd58 100644 --- a/process/process_linux.go +++ b/process/process_linux.go @@ -526,7 +526,7 @@ func (p *Process) fillFromLimitsWithContext() ([]RlimitStat, error) { // Assert that last item is a Hard limit statItem.Hard, err = limitToUint(str[len(str)-1]) 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] statItem.Hard, err = limitToUint(str[len(str)-1]) if err != nil { diff --git a/process/process_windows.go b/process/process_windows.go index 2a3a0c493..d7bb53e67 100644 --- a/process/process_windows.go +++ b/process/process_windows.go @@ -189,7 +189,7 @@ type winLUIDAndAttributes struct { } // TOKEN_PRIVILEGES -type winTokenPriviledges struct { +type winTokenPrivileges struct { PrivilegeCount winDWord Privileges [1]winLUIDAndAttributes } @@ -218,23 +218,23 @@ func init() { } defer token.Close() - tokenPriviledges := winTokenPriviledges{PrivilegeCount: 1} + tokenPrivileges := winTokenPrivileges{PrivilegeCount: 1} lpName := syscall.StringToUTF16("SeDebugPrivilege") ret, _, _ := procLookupPrivilegeValue.Call( 0, uintptr(unsafe.Pointer(&lpName[0])), - uintptr(unsafe.Pointer(&tokenPriviledges.Privileges[0].Luid))) + uintptr(unsafe.Pointer(&tokenPrivileges.Privileges[0].Luid))) if ret == 0 { return } - tokenPriviledges.Privileges[0].Attributes = 0x00000002 // SE_PRIVILEGE_ENABLED + tokenPrivileges.Privileges[0].Attributes = 0x00000002 // SE_PRIVILEGE_ENABLED procAdjustTokenPrivileges.Call( uintptr(token), 0, - uintptr(unsafe.Pointer(&tokenPriviledges)), - uintptr(unsafe.Sizeof(tokenPriviledges)), + uintptr(unsafe.Pointer(&tokenPrivileges)), + uintptr(unsafe.Sizeof(tokenPrivileges)), 0, 0) }