mirror of
https://github.com/shirou/gopsutil.git
synced 2025-04-24 13:48:56 +08:00
fixed by golint.
This commit is contained in:
parent
944429d994
commit
613a8a90e1
@ -6,9 +6,9 @@ package cpu
|
||||
import "github.com/shirou/gopsutil/internal/common"
|
||||
|
||||
func perCPUTimes() ([]TimesStat, error) {
|
||||
return []TimesStat{}, common.NotImplementedError
|
||||
return []TimesStat{}, common.ErrNotImplementedError
|
||||
}
|
||||
|
||||
func allCPUTimes() ([]TimesStat, error) {
|
||||
return []TimesStat{}, common.NotImplementedError
|
||||
return []TimesStat{}, common.ErrNotImplementedError
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ func Times(percpu bool) ([]TimesStat, error) {
|
||||
break
|
||||
}
|
||||
lines = append(lines, line)
|
||||
startIdx += 1
|
||||
startIdx++
|
||||
}
|
||||
} else {
|
||||
lines, _ = common.ReadLinesOffsetN(filename, 0, 1)
|
||||
@ -56,13 +56,13 @@ func Times(percpu bool) ([]TimesStat, error) {
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func sysCpuPath(cpu int32, relPath string) string {
|
||||
func sysCPUPath(cpu int32, relPath string) string {
|
||||
return common.HostSys(fmt.Sprintf("devices/system/cpu/cpu%d", cpu), relPath)
|
||||
}
|
||||
|
||||
func finishCPUInfo(c *InfoStat) error {
|
||||
if c.Mhz == 0 {
|
||||
lines, err := common.ReadLines(sysCpuPath(c.CPU, "cpufreq/cpuinfo_max_freq"))
|
||||
lines, err := common.ReadLines(sysCPUPath(c.CPU, "cpufreq/cpuinfo_max_freq"))
|
||||
if err == nil {
|
||||
value, err := strconv.ParseFloat(lines[0], 64)
|
||||
if err != nil {
|
||||
@ -72,7 +72,7 @@ func finishCPUInfo(c *InfoStat) error {
|
||||
}
|
||||
}
|
||||
if len(c.CoreID) == 0 {
|
||||
lines, err := common.ReadLines(sysCpuPath(c.CPU, "topology/coreId"))
|
||||
lines, err := common.ReadLines(sysCPUPath(c.CPU, "topology/coreId"))
|
||||
if err == nil {
|
||||
c.CoreID = lines[0]
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ type Win32_Processor struct {
|
||||
Manufacturer string
|
||||
Name string
|
||||
NumberOfLogicalProcessors uint32
|
||||
ProcessorId *string
|
||||
ProcessorID *string
|
||||
Stepping *string
|
||||
MaxClockSpeed uint32
|
||||
}
|
||||
@ -66,8 +66,8 @@ func Info() ([]InfoStat, error) {
|
||||
var procID string
|
||||
for i, l := range dst {
|
||||
procID = ""
|
||||
if l.ProcessorId != nil {
|
||||
procID = *l.ProcessorId
|
||||
if l.ProcessorID != nil {
|
||||
procID = *l.ProcessorID
|
||||
}
|
||||
|
||||
cpu := InfoStat{
|
||||
|
@ -81,7 +81,7 @@ func Partitions(all bool) ([]PartitionStat, error) {
|
||||
}
|
||||
|
||||
func IOCounters() (map[string]IOCountersStat, error) {
|
||||
return nil, common.NotImplementedError
|
||||
return nil, common.ErrNotImplementedError
|
||||
}
|
||||
|
||||
func Getfsstat(buf []Statfs_t, flags int) (n int, err error) {
|
||||
|
@ -41,20 +41,20 @@ func GetDockerIDList() ([]string, error) {
|
||||
}
|
||||
|
||||
// CgroupCPU returnes 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
|
||||
// containerId = docker-<container id>.scope and base=/sys/fs/cgroup/cpuacct/system.slice/
|
||||
func CgroupCPU(containerId string, base string) (*cpu.TimesStat, error) {
|
||||
statfile := getCgroupFilePath(containerId, base, "cpuacct", "cpuacct.stat")
|
||||
// containerID = docker-<container id>.scope and base=/sys/fs/cgroup/cpuacct/system.slice/
|
||||
func CgroupCPU(containerID string, base string) (*cpu.TimesStat, error) {
|
||||
statfile := getCgroupFilePath(containerID, base, "cpuacct", "cpuacct.stat")
|
||||
lines, err := common.ReadLines(statfile)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// empty containerId means all cgroup
|
||||
if len(containerId) == 0 {
|
||||
containerId = "all"
|
||||
// empty containerID means all cgroup
|
||||
if len(containerID) == 0 {
|
||||
containerID = "all"
|
||||
}
|
||||
ret := &cpu.TimesStat{CPU: containerId}
|
||||
ret := &cpu.TimesStat{CPU: containerID}
|
||||
for _, line := range lines {
|
||||
fields := strings.Split(line, " ")
|
||||
if fields[0] == "user" {
|
||||
@ -78,18 +78,18 @@ func CgroupCPUDocker(containerid string) (*cpu.TimesStat, error) {
|
||||
return CgroupCPU(containerid, common.HostSys("fs/cgroup/cpuacct/docker"))
|
||||
}
|
||||
|
||||
func CgroupMem(containerId string, base string) (*CgroupMemStat, error) {
|
||||
statfile := getCgroupFilePath(containerId, base, "memory", "memory.stat")
|
||||
func CgroupMem(containerID string, base string) (*CgroupMemStat, error) {
|
||||
statfile := getCgroupFilePath(containerID, base, "memory", "memory.stat")
|
||||
|
||||
// empty containerId means all cgroup
|
||||
if len(containerId) == 0 {
|
||||
containerId = "all"
|
||||
// empty containerID means all cgroup
|
||||
if len(containerID) == 0 {
|
||||
containerID = "all"
|
||||
}
|
||||
lines, err := common.ReadLines(statfile)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ret := &CgroupMemStat{ContainerID: containerId}
|
||||
ret := &CgroupMemStat{ContainerID: containerID}
|
||||
for _, line := range lines {
|
||||
fields := strings.Split(line, " ")
|
||||
v, err := strconv.ParseUint(fields[1], 10, 64)
|
||||
@ -154,19 +154,19 @@ func CgroupMem(containerId string, base string) (*CgroupMemStat, error) {
|
||||
}
|
||||
}
|
||||
|
||||
r, err := getCgroupMemFile(containerId, base, "memory.usage_in_bytes")
|
||||
r, err := getCgroupMemFile(containerID, base, "memory.usage_in_bytes")
|
||||
if err == nil {
|
||||
ret.MemUsageInBytes = r
|
||||
}
|
||||
r, err = getCgroupMemFile(containerId, base, "memory.max_usage_in_bytes")
|
||||
r, err = getCgroupMemFile(containerID, base, "memory.max_usage_in_bytes")
|
||||
if err == nil {
|
||||
ret.MemMaxUsageInBytes = r
|
||||
}
|
||||
r, err = getCgroupMemFile(containerId, base, "memoryLimitInBbytes")
|
||||
r, err = getCgroupMemFile(containerID, base, "memoryLimitInBbytes")
|
||||
if err == nil {
|
||||
ret.MemLimitInBytes = r
|
||||
}
|
||||
r, err = getCgroupMemFile(containerId, base, "memoryFailcnt")
|
||||
r, err = getCgroupMemFile(containerID, base, "memoryFailcnt")
|
||||
if err == nil {
|
||||
ret.MemFailCnt = r
|
||||
}
|
||||
@ -174,8 +174,8 @@ func CgroupMem(containerId string, base string) (*CgroupMemStat, error) {
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func CgroupMemDocker(containerId string) (*CgroupMemStat, error) {
|
||||
return CgroupMem(containerId, common.HostSys("fs/cgroup/memory/docker"))
|
||||
func CgroupMemDocker(containerID string) (*CgroupMemStat, error) {
|
||||
return CgroupMem(containerID, common.HostSys("fs/cgroup/memory/docker"))
|
||||
}
|
||||
|
||||
func (m CgroupMemStat) String() string {
|
||||
@ -184,24 +184,23 @@ func (m CgroupMemStat) String() string {
|
||||
}
|
||||
|
||||
// getCgroupFilePath constructs file path to get targetted stats file.
|
||||
func getCgroupFilePath(containerId, base, target, file string) string {
|
||||
func getCgroupFilePath(containerID, base, target, file string) string {
|
||||
if len(base) == 0 {
|
||||
base = common.HostSys(fmt.Sprintf("fs/cgroup/%s/docker", target))
|
||||
}
|
||||
statfile := path.Join(base, containerId, file)
|
||||
statfile := path.Join(base, containerID, file)
|
||||
|
||||
if _, err := os.Stat(statfile); os.IsNotExist(err) {
|
||||
statfile = path.Join(
|
||||
common.HostSys(fmt.Sprintf("fs/cgroup/%s/system.slice", target)), "docker-"+containerId+".scope", file)
|
||||
common.HostSys(fmt.Sprintf("fs/cgroup/%s/system.slice", target)), "docker-"+containerID+".scope", file)
|
||||
}
|
||||
|
||||
return statfile
|
||||
}
|
||||
|
||||
// getCgroupMemFile reads a cgroup file and return the contents as uint64.
|
||||
func getCgroupMemFile(containerId, base, file string) (uint64, error) {
|
||||
|
||||
statfile := getCgroupFilePath(containerId, base, "memory", file)
|
||||
func getCgroupMemFile(containerID, base, file string) (uint64, error) {
|
||||
statfile := getCgroupFilePath(containerID, base, "memory", file)
|
||||
lines, err := common.ReadLines(statfile)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
|
@ -1,3 +1,5 @@
|
||||
package common
|
||||
|
||||
// Copyright 2009 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
@ -19,8 +21,6 @@
|
||||
// high-performance serialization, especially for large data structures,
|
||||
// should look at more advanced solutions such as the encoding/gob
|
||||
// package or protocol buffers.
|
||||
package common
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io"
|
||||
|
@ -1,11 +1,11 @@
|
||||
package common
|
||||
|
||||
//
|
||||
// gopsutil is a port of psutil(http://pythonhosted.org/psutil/).
|
||||
// This covers these architectures.
|
||||
// - linux (amd64, arm)
|
||||
// - freebsd (amd64)
|
||||
// - windows (amd64)
|
||||
package common
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"errors"
|
||||
@ -59,12 +59,11 @@ func (i FakeInvoke) Command(name string, arg ...string) ([]byte, error) {
|
||||
}
|
||||
if PathExists(fpath) {
|
||||
return ioutil.ReadFile(fpath)
|
||||
} else {
|
||||
return exec.Command(name, arg...).Output()
|
||||
}
|
||||
return exec.Command(name, arg...).Output()
|
||||
}
|
||||
|
||||
var NotImplementedError = errors.New("not implemented yet")
|
||||
var ErrNotImplementedError = errors.New("not implemented yet")
|
||||
|
||||
// ReadLines reads contents from a file and splits them by new lines.
|
||||
// A convenience wrapper to ReadLinesOffsetN(filename, 0, -1).
|
||||
|
@ -56,10 +56,10 @@ func Misc() (*MiscStat, error) {
|
||||
ret := MiscStat{}
|
||||
for _, l := range lines {
|
||||
if strings.Contains(l, "R") {
|
||||
ret.ProcsRunning += 1
|
||||
ret.ProcsRunning++
|
||||
} else if strings.Contains(l, "U") {
|
||||
// uninterruptible sleep == blocked
|
||||
ret.ProcsBlocked += 1
|
||||
ret.ProcsBlocked++
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,9 +55,9 @@ func Misc() (*MiscStat, error) {
|
||||
ret := MiscStat{}
|
||||
for _, l := range lines {
|
||||
if strings.Contains(l, "R") {
|
||||
ret.ProcsRunning += 1
|
||||
ret.ProcsRunning++
|
||||
} else if strings.Contains(l, "D") {
|
||||
ret.ProcsBlocked += 1
|
||||
ret.ProcsBlocked++
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,11 +9,11 @@ import (
|
||||
func Avg() (*AvgStat, error) {
|
||||
ret := AvgStat{}
|
||||
|
||||
return &ret, common.NotImplementedError
|
||||
return &ret, common.ErrNotImplementedError
|
||||
}
|
||||
|
||||
func Misc() (*MiscStat, error) {
|
||||
ret := MiscStat{}
|
||||
|
||||
return &ret, common.NotImplementedError
|
||||
return &ret, common.ErrNotImplementedError
|
||||
}
|
||||
|
@ -88,7 +88,12 @@ func VirtualMemory() (*VirtualMemoryStat, error) {
|
||||
// Return swapinfo
|
||||
// FreeBSD can have multiple swap devices. but use only first device
|
||||
func SwapMemory() (*SwapMemoryStat, error) {
|
||||
out, err := exec.Command("swapinfo").Output()
|
||||
swapinfo, err := exec.LookPath("swapinfo")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
out, err := exec.Command(swapinfo).Output()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ var (
|
||||
procGlobalMemoryStatusEx = common.Modkernel32.NewProc("GlobalMemoryStatusEx")
|
||||
)
|
||||
|
||||
type MEMORYSTATUSEX struct {
|
||||
type memoryStatusEx struct {
|
||||
cbSize uint32
|
||||
dwMemoryLoad uint32
|
||||
ullTotalPhys uint64 // in bytes
|
||||
@ -26,7 +26,7 @@ type MEMORYSTATUSEX struct {
|
||||
}
|
||||
|
||||
func VirtualMemory() (*VirtualMemoryStat, error) {
|
||||
var memInfo MEMORYSTATUSEX
|
||||
var memInfo memoryStatusEx
|
||||
memInfo.cbSize = uint32(unsafe.Sizeof(memInfo))
|
||||
mem, _, _ := procGlobalMemoryStatusEx.Call(uintptr(unsafe.Pointer(&memInfo)))
|
||||
if mem == 0 {
|
||||
|
@ -17,7 +17,11 @@ import (
|
||||
// lo0 16384 ::1/128 ::1 869107 - 169411755 869107 - 169411755 - -
|
||||
// lo0 16384 127 127.0.0.1 869107 - 169411755 869107 - 169411755 - -
|
||||
func IOCounters(pernic bool) ([]IOCountersStat, error) {
|
||||
out, err := exec.Command("/usr/sbin/netstat", "-ibdnW").Output()
|
||||
netstat, err := exec.LookPath("/usr/bin/netstat")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out, err := exec.Command(netstat, "-ibdnW").Output()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -12,7 +12,11 @@ import (
|
||||
)
|
||||
|
||||
func IOCounters(pernic bool) ([]IOCountersStat, error) {
|
||||
out, err := exec.Command("/usr/bin/netstat", "-ibdnW").Output()
|
||||
netstat, err := exec.LookPath("/usr/bin/netstat")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out, err := exec.Command(netstat, "-ibdnW").Output()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ func ConnectionsPid(kind string, pid int32) ([]ConnectionStat, error) {
|
||||
case "udp6":
|
||||
args = append(args, "6udp")
|
||||
case "unix":
|
||||
return ret, common.NotImplementedError
|
||||
return ret, common.ErrNotImplementedError
|
||||
}
|
||||
|
||||
r, err := common.CallLsof(invoke, pid, args...)
|
||||
|
@ -14,8 +14,8 @@ import (
|
||||
|
||||
var (
|
||||
modiphlpapi = syscall.NewLazyDLL("iphlpapi.dll")
|
||||
procGetExtendedTcpTable = modiphlpapi.NewProc("GetExtendedTcpTable")
|
||||
procGetExtendedUdpTable = modiphlpapi.NewProc("GetExtendedUdpTable")
|
||||
procGetExtendedTCPTable = modiphlpapi.NewProc("GetExtendedTcpTable")
|
||||
procGetExtendedUDPTable = modiphlpapi.NewProc("GetExtendedUdpTable")
|
||||
)
|
||||
|
||||
const (
|
||||
@ -83,7 +83,7 @@ func IOCountersByFile(pernic bool, filename string) ([]IOCountersStat, error) {
|
||||
func Connections(kind string) ([]ConnectionStat, error) {
|
||||
var ret []ConnectionStat
|
||||
|
||||
return ret, common.NotImplementedError
|
||||
return ret, common.ErrNotImplementedError
|
||||
}
|
||||
|
||||
// borrowed from src/pkg/net/interface_windows.go
|
||||
|
@ -79,7 +79,7 @@ func (p *Process) Name() (string, error) {
|
||||
return common.IntToString(k.Proc.P_comm[:]), nil
|
||||
}
|
||||
func (p *Process) Exe() (string, error) {
|
||||
return "", common.NotImplementedError
|
||||
return "", common.ErrNotImplementedError
|
||||
}
|
||||
|
||||
// Cmdline returns the command line arguments of the process as a string with
|
||||
@ -105,10 +105,10 @@ func (p *Process) CmdlineSlice() ([]string, error) {
|
||||
return r[0], err
|
||||
}
|
||||
func (p *Process) CreateTime() (int64, error) {
|
||||
return 0, common.NotImplementedError
|
||||
return 0, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) Cwd() (string, error) {
|
||||
return "", common.NotImplementedError
|
||||
return "", common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) Parent() (*Process, error) {
|
||||
rr, err := common.CallLsof(invoke, p.Pid, "-FR")
|
||||
@ -159,7 +159,7 @@ func (p *Process) Gids() ([]int32, error) {
|
||||
return gids, nil
|
||||
}
|
||||
func (p *Process) Terminal() (string, error) {
|
||||
return "", common.NotImplementedError
|
||||
return "", common.ErrNotImplementedError
|
||||
/*
|
||||
k, err := p.getKProc()
|
||||
if err != nil {
|
||||
@ -183,20 +183,20 @@ func (p *Process) Nice() (int32, error) {
|
||||
return int32(k.Proc.P_nice), nil
|
||||
}
|
||||
func (p *Process) IOnice() (int32, error) {
|
||||
return 0, common.NotImplementedError
|
||||
return 0, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) Rlimit() ([]RlimitStat, error) {
|
||||
var rlimit []RlimitStat
|
||||
return rlimit, common.NotImplementedError
|
||||
return rlimit, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) IOCounters() (*IOCountersStat, error) {
|
||||
return nil, common.NotImplementedError
|
||||
return nil, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) NumCtxSwitches() (*NumCtxSwitchesStat, error) {
|
||||
return nil, common.NotImplementedError
|
||||
return nil, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) NumFDs() (int32, error) {
|
||||
return 0, common.NotImplementedError
|
||||
return 0, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) NumThreads() (int32, error) {
|
||||
r, err := callPs("utime,stime", p.Pid, true)
|
||||
@ -207,7 +207,7 @@ func (p *Process) NumThreads() (int32, error) {
|
||||
}
|
||||
func (p *Process) Threads() (map[string]string, error) {
|
||||
ret := make(map[string]string, 0)
|
||||
return ret, common.NotImplementedError
|
||||
return ret, common.ErrNotImplementedError
|
||||
}
|
||||
|
||||
func convertCPUTimes(s string) (ret float64, err error) {
|
||||
@ -259,7 +259,7 @@ func (p *Process) Times() (*cpu.TimesStat, error) {
|
||||
return ret, nil
|
||||
}
|
||||
func (p *Process) CPUAffinity() ([]int32, error) {
|
||||
return nil, common.NotImplementedError
|
||||
return nil, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) MemoryInfo() (*MemoryInfoStat, error) {
|
||||
r, err := callPs("rss,vsize,pagein", p.Pid, false)
|
||||
@ -288,7 +288,7 @@ func (p *Process) MemoryInfo() (*MemoryInfoStat, error) {
|
||||
return ret, nil
|
||||
}
|
||||
func (p *Process) MemoryInfoEx() (*MemoryInfoExStat, error) {
|
||||
return nil, common.NotImplementedError
|
||||
return nil, common.ErrNotImplementedError
|
||||
}
|
||||
|
||||
func (p *Process) Children() ([]*Process, error) {
|
||||
@ -308,7 +308,7 @@ func (p *Process) Children() ([]*Process, error) {
|
||||
}
|
||||
|
||||
func (p *Process) OpenFiles() ([]OpenFilesStat, error) {
|
||||
return nil, common.NotImplementedError
|
||||
return nil, common.ErrNotImplementedError
|
||||
}
|
||||
|
||||
func (p *Process) Connections() ([]net.ConnectionStat, error) {
|
||||
@ -316,15 +316,15 @@ func (p *Process) Connections() ([]net.ConnectionStat, error) {
|
||||
}
|
||||
|
||||
func (p *Process) NetIOCounters(pernic bool) ([]net.IOCountersStat, error) {
|
||||
return nil, common.NotImplementedError
|
||||
return nil, common.ErrNotImplementedError
|
||||
}
|
||||
|
||||
func (p *Process) IsRunning() (bool, error) {
|
||||
return true, common.NotImplementedError
|
||||
return true, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) MemoryMaps(grouped bool) (*[]MemoryMapsStat, error) {
|
||||
var ret []MemoryMapsStat
|
||||
return &ret, common.NotImplementedError
|
||||
return &ret, common.ErrNotImplementedError
|
||||
}
|
||||
|
||||
func processes() ([]Process, error) {
|
||||
|
@ -51,7 +51,7 @@ func (p *Process) Name() (string, error) {
|
||||
return common.IntToString(k.Comm[:]), nil
|
||||
}
|
||||
func (p *Process) Exe() (string, error) {
|
||||
return "", common.NotImplementedError
|
||||
return "", common.ErrNotImplementedError
|
||||
}
|
||||
|
||||
func (p *Process) Cmdline() (string, error) {
|
||||
@ -91,13 +91,13 @@ func (p *Process) CmdlineSlice() ([]string, error) {
|
||||
return strParts, nil
|
||||
}
|
||||
func (p *Process) CreateTime() (int64, error) {
|
||||
return 0, common.NotImplementedError
|
||||
return 0, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) Cwd() (string, error) {
|
||||
return "", common.NotImplementedError
|
||||
return "", common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) Parent() (*Process, error) {
|
||||
return p, common.NotImplementedError
|
||||
return p, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) Status() (string, error) {
|
||||
k, err := p.getKProc()
|
||||
@ -170,11 +170,11 @@ func (p *Process) Nice() (int32, error) {
|
||||
return int32(k.Nice), nil
|
||||
}
|
||||
func (p *Process) IOnice() (int32, error) {
|
||||
return 0, common.NotImplementedError
|
||||
return 0, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) Rlimit() ([]RlimitStat, error) {
|
||||
var rlimit []RlimitStat
|
||||
return rlimit, common.NotImplementedError
|
||||
return rlimit, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) IOCounters() (*IOCountersStat, error) {
|
||||
k, err := p.getKProc()
|
||||
@ -187,10 +187,10 @@ func (p *Process) IOCounters() (*IOCountersStat, error) {
|
||||
}, nil
|
||||
}
|
||||
func (p *Process) NumCtxSwitches() (*NumCtxSwitchesStat, error) {
|
||||
return nil, common.NotImplementedError
|
||||
return nil, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) NumFDs() (int32, error) {
|
||||
return 0, common.NotImplementedError
|
||||
return 0, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) NumThreads() (int32, error) {
|
||||
k, err := p.getKProc()
|
||||
@ -202,7 +202,7 @@ func (p *Process) NumThreads() (int32, error) {
|
||||
}
|
||||
func (p *Process) Threads() (map[string]string, error) {
|
||||
ret := make(map[string]string, 0)
|
||||
return ret, common.NotImplementedError
|
||||
return ret, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) Times() (*cpu.TimesStat, error) {
|
||||
k, err := p.getKProc()
|
||||
@ -216,7 +216,7 @@ func (p *Process) Times() (*cpu.TimesStat, error) {
|
||||
}, nil
|
||||
}
|
||||
func (p *Process) CPUAffinity() ([]int32, error) {
|
||||
return nil, common.NotImplementedError
|
||||
return nil, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) MemoryInfo() (*MemoryInfoStat, error) {
|
||||
k, err := p.getKProc()
|
||||
@ -235,7 +235,7 @@ func (p *Process) MemoryInfo() (*MemoryInfoStat, error) {
|
||||
}, nil
|
||||
}
|
||||
func (p *Process) MemoryInfoEx() (*MemoryInfoExStat, error) {
|
||||
return nil, common.NotImplementedError
|
||||
return nil, common.ErrNotImplementedError
|
||||
}
|
||||
|
||||
func (p *Process) Children() ([]*Process, error) {
|
||||
@ -255,23 +255,23 @@ func (p *Process) Children() ([]*Process, error) {
|
||||
}
|
||||
|
||||
func (p *Process) OpenFiles() ([]OpenFilesStat, error) {
|
||||
return nil, common.NotImplementedError
|
||||
return nil, common.ErrNotImplementedError
|
||||
}
|
||||
|
||||
func (p *Process) Connections() ([]net.ConnectionStat, error) {
|
||||
return nil, common.NotImplementedError
|
||||
return nil, common.ErrNotImplementedError
|
||||
}
|
||||
|
||||
func (p *Process) NetIOCounters(pernic bool) ([]net.IOCountersStat, error) {
|
||||
return nil, common.NotImplementedError
|
||||
return nil, common.ErrNotImplementedError
|
||||
}
|
||||
|
||||
func (p *Process) IsRunning() (bool, error) {
|
||||
return true, common.NotImplementedError
|
||||
return true, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) MemoryMaps(grouped bool) (*[]MemoryMapsStat, error) {
|
||||
var ret []MemoryMapsStat
|
||||
return &ret, common.NotImplementedError
|
||||
return &ret, common.ErrNotImplementedError
|
||||
}
|
||||
|
||||
func processes() ([]Process, error) {
|
||||
|
@ -167,10 +167,10 @@ func (p *Process) Nice() (int32, error) {
|
||||
return nice, nil
|
||||
}
|
||||
func (p *Process) IOnice() (int32, error) {
|
||||
return 0, common.NotImplementedError
|
||||
return 0, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) Rlimit() ([]RlimitStat, error) {
|
||||
return nil, common.NotImplementedError
|
||||
return nil, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) IOCounters() (*IOCountersStat, error) {
|
||||
return p.fillFromIO()
|
||||
@ -205,7 +205,7 @@ func (p *Process) Times() (*cpu.TimesStat, error) {
|
||||
return cpuTimes, nil
|
||||
}
|
||||
func (p *Process) CPUAffinity() ([]int32, error) {
|
||||
return nil, common.NotImplementedError
|
||||
return nil, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) MemoryInfo() (*MemoryInfoStat, error) {
|
||||
meminfo, _, err := p.fillFromStatm()
|
||||
@ -264,7 +264,7 @@ func (p *Process) NetIOCounters(pernic bool) ([]net.IOCountersStat, error) {
|
||||
}
|
||||
|
||||
func (p *Process) IsRunning() (bool, error) {
|
||||
return true, common.NotImplementedError
|
||||
return true, common.ErrNotImplementedError
|
||||
}
|
||||
|
||||
// MemoryMaps get memory maps from /proc/(pid)/smaps
|
||||
@ -361,7 +361,7 @@ func (p *Process) fillFromfd() (int32, []*OpenFilesStat, error) {
|
||||
fnames, err := d.Readdirnames(-1)
|
||||
numFDs := int32(len(fnames))
|
||||
|
||||
openfiles := make([]*OpenFilesStat, 0)
|
||||
var openfiles []*OpenFilesStat
|
||||
for _, fd := range fnames {
|
||||
fpath := filepath.Join(statPath, fd)
|
||||
filepath, err := os.Readlink(fpath)
|
||||
|
@ -51,7 +51,7 @@ type Win32_Process struct {
|
||||
CommandLine *string
|
||||
Priority uint32
|
||||
CreationDate *time.Time
|
||||
ProcessId uint32
|
||||
ProcessID uint32
|
||||
ThreadCount uint32
|
||||
|
||||
/*
|
||||
@ -71,7 +71,7 @@ type Win32_Process struct {
|
||||
OtherTransferCount uint64
|
||||
PageFaults uint32
|
||||
PageFileUsage uint32
|
||||
ParentProcessId uint32
|
||||
ParentProcessID uint32
|
||||
PeakPageFileUsage uint32
|
||||
PeakVirtualSize uint64
|
||||
PeakWorkingSetSize uint32
|
||||
@ -167,28 +167,28 @@ func (p *Process) CreateTime() (int64, error) {
|
||||
}
|
||||
|
||||
func (p *Process) Cwd() (string, error) {
|
||||
return "", common.NotImplementedError
|
||||
return "", common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) Parent() (*Process, error) {
|
||||
return p, common.NotImplementedError
|
||||
return p, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) Status() (string, error) {
|
||||
return "", common.NotImplementedError
|
||||
return "", common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) Username() (string, error) {
|
||||
return "", common.NotImplementedError
|
||||
return "", common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) Uids() ([]int32, error) {
|
||||
var uids []int32
|
||||
|
||||
return uids, common.NotImplementedError
|
||||
return uids, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) Gids() ([]int32, error) {
|
||||
var gids []int32
|
||||
return gids, common.NotImplementedError
|
||||
return gids, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) Terminal() (string, error) {
|
||||
return "", common.NotImplementedError
|
||||
return "", common.ErrNotImplementedError
|
||||
}
|
||||
|
||||
// Nice returnes priority in Windows
|
||||
@ -200,21 +200,21 @@ func (p *Process) Nice() (int32, error) {
|
||||
return int32(dst[0].Priority), nil
|
||||
}
|
||||
func (p *Process) IOnice() (int32, error) {
|
||||
return 0, common.NotImplementedError
|
||||
return 0, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) Rlimit() ([]RlimitStat, error) {
|
||||
var rlimit []RlimitStat
|
||||
|
||||
return rlimit, common.NotImplementedError
|
||||
return rlimit, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) IOCounters() (*IOCountersStat, error) {
|
||||
return nil, common.NotImplementedError
|
||||
return nil, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) NumCtxSwitches() (*NumCtxSwitchesStat, error) {
|
||||
return nil, common.NotImplementedError
|
||||
return nil, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) NumFDs() (int32, error) {
|
||||
return 0, common.NotImplementedError
|
||||
return 0, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) NumThreads() (int32, error) {
|
||||
dst, err := GetWin32Proc(p.Pid)
|
||||
@ -225,44 +225,44 @@ func (p *Process) NumThreads() (int32, error) {
|
||||
}
|
||||
func (p *Process) Threads() (map[string]string, error) {
|
||||
ret := make(map[string]string, 0)
|
||||
return ret, common.NotImplementedError
|
||||
return ret, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) Times() (*cpu.TimesStat, error) {
|
||||
return nil, common.NotImplementedError
|
||||
return nil, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) CPUAffinity() ([]int32, error) {
|
||||
return nil, common.NotImplementedError
|
||||
return nil, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) MemoryInfo() (*MemoryInfoStat, error) {
|
||||
return nil, common.NotImplementedError
|
||||
return nil, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) MemoryInfoEx() (*MemoryInfoExStat, error) {
|
||||
return nil, common.NotImplementedError
|
||||
return nil, common.ErrNotImplementedError
|
||||
}
|
||||
|
||||
func (p *Process) Children() ([]*Process, error) {
|
||||
return nil, common.NotImplementedError
|
||||
return nil, common.ErrNotImplementedError
|
||||
}
|
||||
|
||||
func (p *Process) OpenFiles() ([]OpenFilesStat, error) {
|
||||
return nil, common.NotImplementedError
|
||||
return nil, common.ErrNotImplementedError
|
||||
}
|
||||
|
||||
func (p *Process) Connections() ([]net.ConnectionStat, error) {
|
||||
return nil, common.NotImplementedError
|
||||
return nil, common.ErrNotImplementedError
|
||||
}
|
||||
|
||||
func (p *Process) NetIOCounters(pernic bool) ([]net.IOCountersStat, error) {
|
||||
return nil, common.NotImplementedError
|
||||
return nil, common.ErrNotImplementedError
|
||||
}
|
||||
|
||||
func (p *Process) IsRunning() (bool, error) {
|
||||
return true, common.NotImplementedError
|
||||
return true, common.ErrNotImplementedError
|
||||
}
|
||||
|
||||
func (p *Process) MemoryMaps(grouped bool) (*[]MemoryMapsStat, error) {
|
||||
ret := make([]MemoryMapsStat, 0)
|
||||
return &ret, common.NotImplementedError
|
||||
var ret []MemoryMapsStat
|
||||
return &ret, common.ErrNotImplementedError
|
||||
}
|
||||
|
||||
func NewProcess(pid int32) (*Process, error) {
|
||||
@ -272,20 +272,20 @@ func NewProcess(pid int32) (*Process, error) {
|
||||
}
|
||||
|
||||
func (p *Process) SendSignal(sig syscall.Signal) error {
|
||||
return common.NotImplementedError
|
||||
return common.ErrNotImplementedError
|
||||
}
|
||||
|
||||
func (p *Process) Suspend() error {
|
||||
return common.NotImplementedError
|
||||
return common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) Resume() error {
|
||||
return common.NotImplementedError
|
||||
return common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) Terminate() error {
|
||||
return common.NotImplementedError
|
||||
return common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) Kill() error {
|
||||
return common.NotImplementedError
|
||||
return common.ErrNotImplementedError
|
||||
}
|
||||
|
||||
func (p *Process) getFromSnapProcess(pid int32) (int32, int32, string, error) {
|
||||
@ -328,7 +328,7 @@ func processes() ([]*Process, error) {
|
||||
}
|
||||
results := make([]*Process, 0, len(dst))
|
||||
for _, proc := range dst {
|
||||
p, err := NewProcess(int32(proc.ProcessId))
|
||||
p, err := NewProcess(int32(proc.ProcessID))
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user