fixed by golint.

pull/177/head
Shirou WAKAYAMA 9 years ago
parent 944429d994
commit 613a8a90e1

@ -6,9 +6,9 @@ package cpu
import "github.com/shirou/gopsutil/internal/common" import "github.com/shirou/gopsutil/internal/common"
func perCPUTimes() ([]TimesStat, error) { func perCPUTimes() ([]TimesStat, error) {
return []TimesStat{}, common.NotImplementedError return []TimesStat{}, common.ErrNotImplementedError
} }
func allCPUTimes() ([]TimesStat, error) { func allCPUTimes() ([]TimesStat, error) {
return []TimesStat{}, common.NotImplementedError return []TimesStat{}, common.ErrNotImplementedError
} }

@ -37,7 +37,7 @@ func Times(percpu bool) ([]TimesStat, error) {
break break
} }
lines = append(lines, line) lines = append(lines, line)
startIdx += 1 startIdx++
} }
} else { } else {
lines, _ = common.ReadLinesOffsetN(filename, 0, 1) lines, _ = common.ReadLinesOffsetN(filename, 0, 1)
@ -56,13 +56,13 @@ func Times(percpu bool) ([]TimesStat, error) {
return ret, nil 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) return common.HostSys(fmt.Sprintf("devices/system/cpu/cpu%d", cpu), relPath)
} }
func finishCPUInfo(c *InfoStat) error { func finishCPUInfo(c *InfoStat) error {
if c.Mhz == 0 { 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 { if err == nil {
value, err := strconv.ParseFloat(lines[0], 64) value, err := strconv.ParseFloat(lines[0], 64)
if err != nil { if err != nil {
@ -72,7 +72,7 @@ func finishCPUInfo(c *InfoStat) error {
} }
} }
if len(c.CoreID) == 0 { 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 { if err == nil {
c.CoreID = lines[0] c.CoreID = lines[0]
} }

@ -19,7 +19,7 @@ type Win32_Processor struct {
Manufacturer string Manufacturer string
Name string Name string
NumberOfLogicalProcessors uint32 NumberOfLogicalProcessors uint32
ProcessorId *string ProcessorID *string
Stepping *string Stepping *string
MaxClockSpeed uint32 MaxClockSpeed uint32
} }
@ -66,8 +66,8 @@ func Info() ([]InfoStat, error) {
var procID string var procID string
for i, l := range dst { for i, l := range dst {
procID = "" procID = ""
if l.ProcessorId != nil { if l.ProcessorID != nil {
procID = *l.ProcessorId procID = *l.ProcessorID
} }
cpu := InfoStat{ cpu := InfoStat{

@ -81,7 +81,7 @@ func Partitions(all bool) ([]PartitionStat, error) {
} }
func IOCounters() (map[string]IOCountersStat, 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) { 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. // 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 // 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/
func CgroupCPU(containerId string, base string) (*cpu.TimesStat, error) { func CgroupCPU(containerID string, base string) (*cpu.TimesStat, error) {
statfile := getCgroupFilePath(containerId, base, "cpuacct", "cpuacct.stat") statfile := getCgroupFilePath(containerID, base, "cpuacct", "cpuacct.stat")
lines, err := common.ReadLines(statfile) lines, err := common.ReadLines(statfile)
if err != nil { if err != nil {
return nil, err return nil, err
} }
// empty containerId means all cgroup // empty containerID means all cgroup
if len(containerId) == 0 { if len(containerID) == 0 {
containerId = "all" containerID = "all"
} }
ret := &cpu.TimesStat{CPU: containerId} ret := &cpu.TimesStat{CPU: containerID}
for _, line := range lines { for _, line := range lines {
fields := strings.Split(line, " ") fields := strings.Split(line, " ")
if fields[0] == "user" { if fields[0] == "user" {
@ -78,18 +78,18 @@ func CgroupCPUDocker(containerid string) (*cpu.TimesStat, error) {
return CgroupCPU(containerid, common.HostSys("fs/cgroup/cpuacct/docker")) return CgroupCPU(containerid, common.HostSys("fs/cgroup/cpuacct/docker"))
} }
func CgroupMem(containerId string, base string) (*CgroupMemStat, error) { func CgroupMem(containerID string, base string) (*CgroupMemStat, error) {
statfile := getCgroupFilePath(containerId, base, "memory", "memory.stat") statfile := getCgroupFilePath(containerID, base, "memory", "memory.stat")
// empty containerId means all cgroup // empty containerID means all cgroup
if len(containerId) == 0 { if len(containerID) == 0 {
containerId = "all" containerID = "all"
} }
lines, err := common.ReadLines(statfile) lines, err := common.ReadLines(statfile)
if err != nil { if err != nil {
return nil, err return nil, err
} }
ret := &CgroupMemStat{ContainerID: containerId} ret := &CgroupMemStat{ContainerID: containerID}
for _, line := range lines { for _, line := range lines {
fields := strings.Split(line, " ") fields := strings.Split(line, " ")
v, err := strconv.ParseUint(fields[1], 10, 64) 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 { if err == nil {
ret.MemUsageInBytes = r 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 { if err == nil {
ret.MemMaxUsageInBytes = r ret.MemMaxUsageInBytes = r
} }
r, err = getCgroupMemFile(containerId, base, "memoryLimitInBbytes") r, err = getCgroupMemFile(containerID, base, "memoryLimitInBbytes")
if err == nil { if err == nil {
ret.MemLimitInBytes = r ret.MemLimitInBytes = r
} }
r, err = getCgroupMemFile(containerId, base, "memoryFailcnt") r, err = getCgroupMemFile(containerID, base, "memoryFailcnt")
if err == nil { if err == nil {
ret.MemFailCnt = r ret.MemFailCnt = r
} }
@ -174,8 +174,8 @@ func CgroupMem(containerId string, base string) (*CgroupMemStat, error) {
return ret, nil return ret, nil
} }
func CgroupMemDocker(containerId string) (*CgroupMemStat, error) { func CgroupMemDocker(containerID string) (*CgroupMemStat, error) {
return CgroupMem(containerId, common.HostSys("fs/cgroup/memory/docker")) return CgroupMem(containerID, common.HostSys("fs/cgroup/memory/docker"))
} }
func (m CgroupMemStat) String() string { func (m CgroupMemStat) String() string {
@ -184,24 +184,23 @@ func (m CgroupMemStat) String() string {
} }
// getCgroupFilePath constructs file path to get targetted stats file. // 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 { if len(base) == 0 {
base = common.HostSys(fmt.Sprintf("fs/cgroup/%s/docker", target)) 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) { if _, err := os.Stat(statfile); os.IsNotExist(err) {
statfile = path.Join( 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 return statfile
} }
// getCgroupMemFile reads a cgroup file and return the contents as uint64. // getCgroupMemFile reads a cgroup file and return the contents as uint64.
func getCgroupMemFile(containerId, base, file string) (uint64, error) { func getCgroupMemFile(containerID, base, file string) (uint64, error) {
statfile := getCgroupFilePath(containerID, base, "memory", file)
statfile := getCgroupFilePath(containerId, base, "memory", file)
lines, err := common.ReadLines(statfile) lines, err := common.ReadLines(statfile)
if err != nil { if err != nil {
return 0, err return 0, err

@ -1,3 +1,5 @@
package common
// Copyright 2009 The Go Authors. All rights reserved. // Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
@ -19,8 +21,6 @@
// high-performance serialization, especially for large data structures, // high-performance serialization, especially for large data structures,
// should look at more advanced solutions such as the encoding/gob // should look at more advanced solutions such as the encoding/gob
// package or protocol buffers. // package or protocol buffers.
package common
import ( import (
"errors" "errors"
"io" "io"

@ -1,11 +1,11 @@
package common
// //
// gopsutil is a port of psutil(http://pythonhosted.org/psutil/). // gopsutil is a port of psutil(http://pythonhosted.org/psutil/).
// This covers these architectures. // This covers these architectures.
// - linux (amd64, arm) // - linux (amd64, arm)
// - freebsd (amd64) // - freebsd (amd64)
// - windows (amd64) // - windows (amd64)
package common
import ( import (
"bufio" "bufio"
"errors" "errors"
@ -59,12 +59,11 @@ func (i FakeInvoke) Command(name string, arg ...string) ([]byte, error) {
} }
if PathExists(fpath) { if PathExists(fpath) {
return ioutil.ReadFile(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. // ReadLines reads contents from a file and splits them by new lines.
// A convenience wrapper to ReadLinesOffsetN(filename, 0, -1). // A convenience wrapper to ReadLinesOffsetN(filename, 0, -1).

@ -56,10 +56,10 @@ func Misc() (*MiscStat, error) {
ret := MiscStat{} ret := MiscStat{}
for _, l := range lines { for _, l := range lines {
if strings.Contains(l, "R") { if strings.Contains(l, "R") {
ret.ProcsRunning += 1 ret.ProcsRunning++
} else if strings.Contains(l, "U") { } else if strings.Contains(l, "U") {
// uninterruptible sleep == blocked // uninterruptible sleep == blocked
ret.ProcsBlocked += 1 ret.ProcsBlocked++
} }
} }

@ -55,9 +55,9 @@ func Misc() (*MiscStat, error) {
ret := MiscStat{} ret := MiscStat{}
for _, l := range lines { for _, l := range lines {
if strings.Contains(l, "R") { if strings.Contains(l, "R") {
ret.ProcsRunning += 1 ret.ProcsRunning++
} else if strings.Contains(l, "D") { } else if strings.Contains(l, "D") {
ret.ProcsBlocked += 1 ret.ProcsBlocked++
} }
} }

@ -9,11 +9,11 @@ import (
func Avg() (*AvgStat, error) { func Avg() (*AvgStat, error) {
ret := AvgStat{} ret := AvgStat{}
return &ret, common.NotImplementedError return &ret, common.ErrNotImplementedError
} }
func Misc() (*MiscStat, error) { func Misc() (*MiscStat, error) {
ret := MiscStat{} ret := MiscStat{}
return &ret, common.NotImplementedError return &ret, common.ErrNotImplementedError
} }

@ -88,7 +88,12 @@ func VirtualMemory() (*VirtualMemoryStat, error) {
// Return swapinfo // Return swapinfo
// FreeBSD can have multiple swap devices. but use only first device // FreeBSD can have multiple swap devices. but use only first device
func SwapMemory() (*SwapMemoryStat, error) { 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 { if err != nil {
return nil, err return nil, err
} }

@ -13,7 +13,7 @@ var (
procGlobalMemoryStatusEx = common.Modkernel32.NewProc("GlobalMemoryStatusEx") procGlobalMemoryStatusEx = common.Modkernel32.NewProc("GlobalMemoryStatusEx")
) )
type MEMORYSTATUSEX struct { type memoryStatusEx struct {
cbSize uint32 cbSize uint32
dwMemoryLoad uint32 dwMemoryLoad uint32
ullTotalPhys uint64 // in bytes ullTotalPhys uint64 // in bytes
@ -26,7 +26,7 @@ type MEMORYSTATUSEX struct {
} }
func VirtualMemory() (*VirtualMemoryStat, error) { func VirtualMemory() (*VirtualMemoryStat, error) {
var memInfo MEMORYSTATUSEX var memInfo memoryStatusEx
memInfo.cbSize = uint32(unsafe.Sizeof(memInfo)) memInfo.cbSize = uint32(unsafe.Sizeof(memInfo))
mem, _, _ := procGlobalMemoryStatusEx.Call(uintptr(unsafe.Pointer(&memInfo))) mem, _, _ := procGlobalMemoryStatusEx.Call(uintptr(unsafe.Pointer(&memInfo)))
if mem == 0 { if mem == 0 {

@ -17,7 +17,11 @@ import (
// lo0 16384 ::1/128 ::1 869107 - 169411755 869107 - 169411755 - - // lo0 16384 ::1/128 ::1 869107 - 169411755 869107 - 169411755 - -
// lo0 16384 127 127.0.0.1 869107 - 169411755 869107 - 169411755 - - // lo0 16384 127 127.0.0.1 869107 - 169411755 869107 - 169411755 - -
func IOCounters(pernic bool) ([]IOCountersStat, error) { 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 { if err != nil {
return nil, err return nil, err
} }

@ -12,7 +12,11 @@ import (
) )
func IOCounters(pernic bool) ([]IOCountersStat, error) { 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 { if err != nil {
return nil, err return nil, err
} }

@ -44,7 +44,7 @@ func ConnectionsPid(kind string, pid int32) ([]ConnectionStat, error) {
case "udp6": case "udp6":
args = append(args, "6udp") args = append(args, "6udp")
case "unix": case "unix":
return ret, common.NotImplementedError return ret, common.ErrNotImplementedError
} }
r, err := common.CallLsof(invoke, pid, args...) r, err := common.CallLsof(invoke, pid, args...)

@ -14,8 +14,8 @@ import (
var ( var (
modiphlpapi = syscall.NewLazyDLL("iphlpapi.dll") modiphlpapi = syscall.NewLazyDLL("iphlpapi.dll")
procGetExtendedTcpTable = modiphlpapi.NewProc("GetExtendedTcpTable") procGetExtendedTCPTable = modiphlpapi.NewProc("GetExtendedTcpTable")
procGetExtendedUdpTable = modiphlpapi.NewProc("GetExtendedUdpTable") procGetExtendedUDPTable = modiphlpapi.NewProc("GetExtendedUdpTable")
) )
const ( const (
@ -83,7 +83,7 @@ func IOCountersByFile(pernic bool, filename string) ([]IOCountersStat, error) {
func Connections(kind string) ([]ConnectionStat, error) { func Connections(kind string) ([]ConnectionStat, error) {
var ret []ConnectionStat var ret []ConnectionStat
return ret, common.NotImplementedError return ret, common.ErrNotImplementedError
} }
// borrowed from src/pkg/net/interface_windows.go // 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 return common.IntToString(k.Proc.P_comm[:]), nil
} }
func (p *Process) Exe() (string, error) { 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 // 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 return r[0], err
} }
func (p *Process) CreateTime() (int64, error) { func (p *Process) CreateTime() (int64, error) {
return 0, common.NotImplementedError return 0, common.ErrNotImplementedError
} }
func (p *Process) Cwd() (string, error) { func (p *Process) Cwd() (string, error) {
return "", common.NotImplementedError return "", common.ErrNotImplementedError
} }
func (p *Process) Parent() (*Process, error) { func (p *Process) Parent() (*Process, error) {
rr, err := common.CallLsof(invoke, p.Pid, "-FR") rr, err := common.CallLsof(invoke, p.Pid, "-FR")
@ -159,7 +159,7 @@ func (p *Process) Gids() ([]int32, error) {
return gids, nil return gids, nil
} }
func (p *Process) Terminal() (string, error) { func (p *Process) Terminal() (string, error) {
return "", common.NotImplementedError return "", common.ErrNotImplementedError
/* /*
k, err := p.getKProc() k, err := p.getKProc()
if err != nil { if err != nil {
@ -183,20 +183,20 @@ func (p *Process) Nice() (int32, error) {
return int32(k.Proc.P_nice), nil return int32(k.Proc.P_nice), nil
} }
func (p *Process) IOnice() (int32, error) { func (p *Process) IOnice() (int32, error) {
return 0, common.NotImplementedError return 0, common.ErrNotImplementedError
} }
func (p *Process) Rlimit() ([]RlimitStat, error) { func (p *Process) Rlimit() ([]RlimitStat, error) {
var rlimit []RlimitStat var rlimit []RlimitStat
return rlimit, common.NotImplementedError return rlimit, common.ErrNotImplementedError
} }
func (p *Process) IOCounters() (*IOCountersStat, error) { func (p *Process) IOCounters() (*IOCountersStat, error) {
return nil, common.NotImplementedError return nil, common.ErrNotImplementedError
} }
func (p *Process) NumCtxSwitches() (*NumCtxSwitchesStat, error) { func (p *Process) NumCtxSwitches() (*NumCtxSwitchesStat, error) {
return nil, common.NotImplementedError return nil, common.ErrNotImplementedError
} }
func (p *Process) NumFDs() (int32, error) { func (p *Process) NumFDs() (int32, error) {
return 0, common.NotImplementedError return 0, common.ErrNotImplementedError
} }
func (p *Process) NumThreads() (int32, error) { func (p *Process) NumThreads() (int32, error) {
r, err := callPs("utime,stime", p.Pid, true) 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) { func (p *Process) Threads() (map[string]string, error) {
ret := make(map[string]string, 0) ret := make(map[string]string, 0)
return ret, common.NotImplementedError return ret, common.ErrNotImplementedError
} }
func convertCPUTimes(s string) (ret float64, err error) { func convertCPUTimes(s string) (ret float64, err error) {
@ -259,7 +259,7 @@ func (p *Process) Times() (*cpu.TimesStat, error) {
return ret, nil return ret, nil
} }
func (p *Process) CPUAffinity() ([]int32, error) { func (p *Process) CPUAffinity() ([]int32, error) {
return nil, common.NotImplementedError return nil, common.ErrNotImplementedError
} }
func (p *Process) MemoryInfo() (*MemoryInfoStat, error) { func (p *Process) MemoryInfo() (*MemoryInfoStat, error) {
r, err := callPs("rss,vsize,pagein", p.Pid, false) r, err := callPs("rss,vsize,pagein", p.Pid, false)
@ -288,7 +288,7 @@ func (p *Process) MemoryInfo() (*MemoryInfoStat, error) {
return ret, nil return ret, nil
} }
func (p *Process) MemoryInfoEx() (*MemoryInfoExStat, error) { func (p *Process) MemoryInfoEx() (*MemoryInfoExStat, error) {
return nil, common.NotImplementedError return nil, common.ErrNotImplementedError
} }
func (p *Process) Children() ([]*Process, error) { func (p *Process) Children() ([]*Process, error) {
@ -308,7 +308,7 @@ func (p *Process) Children() ([]*Process, error) {
} }
func (p *Process) OpenFiles() ([]OpenFilesStat, error) { func (p *Process) OpenFiles() ([]OpenFilesStat, error) {
return nil, common.NotImplementedError return nil, common.ErrNotImplementedError
} }
func (p *Process) Connections() ([]net.ConnectionStat, error) { 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) { func (p *Process) NetIOCounters(pernic bool) ([]net.IOCountersStat, error) {
return nil, common.NotImplementedError return nil, common.ErrNotImplementedError
} }
func (p *Process) IsRunning() (bool, error) { func (p *Process) IsRunning() (bool, error) {
return true, common.NotImplementedError return true, common.ErrNotImplementedError
} }
func (p *Process) MemoryMaps(grouped bool) (*[]MemoryMapsStat, error) { func (p *Process) MemoryMaps(grouped bool) (*[]MemoryMapsStat, error) {
var ret []MemoryMapsStat var ret []MemoryMapsStat
return &ret, common.NotImplementedError return &ret, common.ErrNotImplementedError
} }
func processes() ([]Process, error) { func processes() ([]Process, error) {

@ -51,7 +51,7 @@ func (p *Process) Name() (string, error) {
return common.IntToString(k.Comm[:]), nil return common.IntToString(k.Comm[:]), nil
} }
func (p *Process) Exe() (string, error) { func (p *Process) Exe() (string, error) {
return "", common.NotImplementedError return "", common.ErrNotImplementedError
} }
func (p *Process) Cmdline() (string, error) { func (p *Process) Cmdline() (string, error) {
@ -91,13 +91,13 @@ func (p *Process) CmdlineSlice() ([]string, error) {
return strParts, nil return strParts, nil
} }
func (p *Process) CreateTime() (int64, error) { func (p *Process) CreateTime() (int64, error) {
return 0, common.NotImplementedError return 0, common.ErrNotImplementedError
} }
func (p *Process) Cwd() (string, error) { func (p *Process) Cwd() (string, error) {
return "", common.NotImplementedError return "", common.ErrNotImplementedError
} }
func (p *Process) Parent() (*Process, error) { func (p *Process) Parent() (*Process, error) {
return p, common.NotImplementedError return p, common.ErrNotImplementedError
} }
func (p *Process) Status() (string, error) { func (p *Process) Status() (string, error) {
k, err := p.getKProc() k, err := p.getKProc()
@ -170,11 +170,11 @@ func (p *Process) Nice() (int32, error) {
return int32(k.Nice), nil return int32(k.Nice), nil
} }
func (p *Process) IOnice() (int32, error) { func (p *Process) IOnice() (int32, error) {
return 0, common.NotImplementedError return 0, common.ErrNotImplementedError
} }
func (p *Process) Rlimit() ([]RlimitStat, error) { func (p *Process) Rlimit() ([]RlimitStat, error) {
var rlimit []RlimitStat var rlimit []RlimitStat
return rlimit, common.NotImplementedError return rlimit, common.ErrNotImplementedError
} }
func (p *Process) IOCounters() (*IOCountersStat, error) { func (p *Process) IOCounters() (*IOCountersStat, error) {
k, err := p.getKProc() k, err := p.getKProc()
@ -187,10 +187,10 @@ func (p *Process) IOCounters() (*IOCountersStat, error) {
}, nil }, nil
} }
func (p *Process) NumCtxSwitches() (*NumCtxSwitchesStat, error) { func (p *Process) NumCtxSwitches() (*NumCtxSwitchesStat, error) {
return nil, common.NotImplementedError return nil, common.ErrNotImplementedError
} }
func (p *Process) NumFDs() (int32, error) { func (p *Process) NumFDs() (int32, error) {
return 0, common.NotImplementedError return 0, common.ErrNotImplementedError
} }
func (p *Process) NumThreads() (int32, error) { func (p *Process) NumThreads() (int32, error) {
k, err := p.getKProc() k, err := p.getKProc()
@ -202,7 +202,7 @@ func (p *Process) NumThreads() (int32, error) {
} }
func (p *Process) Threads() (map[string]string, error) { func (p *Process) Threads() (map[string]string, error) {
ret := make(map[string]string, 0) ret := make(map[string]string, 0)
return ret, common.NotImplementedError return ret, common.ErrNotImplementedError
} }
func (p *Process) Times() (*cpu.TimesStat, error) { func (p *Process) Times() (*cpu.TimesStat, error) {
k, err := p.getKProc() k, err := p.getKProc()
@ -216,7 +216,7 @@ func (p *Process) Times() (*cpu.TimesStat, error) {
}, nil }, nil
} }
func (p *Process) CPUAffinity() ([]int32, error) { func (p *Process) CPUAffinity() ([]int32, error) {
return nil, common.NotImplementedError return nil, common.ErrNotImplementedError
} }
func (p *Process) MemoryInfo() (*MemoryInfoStat, error) { func (p *Process) MemoryInfo() (*MemoryInfoStat, error) {
k, err := p.getKProc() k, err := p.getKProc()
@ -235,7 +235,7 @@ func (p *Process) MemoryInfo() (*MemoryInfoStat, error) {
}, nil }, nil
} }
func (p *Process) MemoryInfoEx() (*MemoryInfoExStat, error) { func (p *Process) MemoryInfoEx() (*MemoryInfoExStat, error) {
return nil, common.NotImplementedError return nil, common.ErrNotImplementedError
} }
func (p *Process) Children() ([]*Process, error) { func (p *Process) Children() ([]*Process, error) {
@ -255,23 +255,23 @@ func (p *Process) Children() ([]*Process, error) {
} }
func (p *Process) OpenFiles() ([]OpenFilesStat, error) { func (p *Process) OpenFiles() ([]OpenFilesStat, error) {
return nil, common.NotImplementedError return nil, common.ErrNotImplementedError
} }
func (p *Process) Connections() ([]net.ConnectionStat, error) { func (p *Process) Connections() ([]net.ConnectionStat, error) {
return nil, common.NotImplementedError return nil, common.ErrNotImplementedError
} }
func (p *Process) NetIOCounters(pernic bool) ([]net.IOCountersStat, error) { func (p *Process) NetIOCounters(pernic bool) ([]net.IOCountersStat, error) {
return nil, common.NotImplementedError return nil, common.ErrNotImplementedError
} }
func (p *Process) IsRunning() (bool, error) { func (p *Process) IsRunning() (bool, error) {
return true, common.NotImplementedError return true, common.ErrNotImplementedError
} }
func (p *Process) MemoryMaps(grouped bool) (*[]MemoryMapsStat, error) { func (p *Process) MemoryMaps(grouped bool) (*[]MemoryMapsStat, error) {
var ret []MemoryMapsStat var ret []MemoryMapsStat
return &ret, common.NotImplementedError return &ret, common.ErrNotImplementedError
} }
func processes() ([]Process, error) { func processes() ([]Process, error) {

@ -167,10 +167,10 @@ func (p *Process) Nice() (int32, error) {
return nice, nil return nice, nil
} }
func (p *Process) IOnice() (int32, error) { func (p *Process) IOnice() (int32, error) {
return 0, common.NotImplementedError return 0, common.ErrNotImplementedError
} }
func (p *Process) Rlimit() ([]RlimitStat, error) { func (p *Process) Rlimit() ([]RlimitStat, error) {
return nil, common.NotImplementedError return nil, common.ErrNotImplementedError
} }
func (p *Process) IOCounters() (*IOCountersStat, error) { func (p *Process) IOCounters() (*IOCountersStat, error) {
return p.fillFromIO() return p.fillFromIO()
@ -205,7 +205,7 @@ func (p *Process) Times() (*cpu.TimesStat, error) {
return cpuTimes, nil return cpuTimes, nil
} }
func (p *Process) CPUAffinity() ([]int32, error) { func (p *Process) CPUAffinity() ([]int32, error) {
return nil, common.NotImplementedError return nil, common.ErrNotImplementedError
} }
func (p *Process) MemoryInfo() (*MemoryInfoStat, error) { func (p *Process) MemoryInfo() (*MemoryInfoStat, error) {
meminfo, _, err := p.fillFromStatm() meminfo, _, err := p.fillFromStatm()
@ -264,7 +264,7 @@ func (p *Process) NetIOCounters(pernic bool) ([]net.IOCountersStat, error) {
} }
func (p *Process) IsRunning() (bool, error) { func (p *Process) IsRunning() (bool, error) {
return true, common.NotImplementedError return true, common.ErrNotImplementedError
} }
// MemoryMaps get memory maps from /proc/(pid)/smaps // MemoryMaps get memory maps from /proc/(pid)/smaps
@ -361,7 +361,7 @@ func (p *Process) fillFromfd() (int32, []*OpenFilesStat, error) {
fnames, err := d.Readdirnames(-1) fnames, err := d.Readdirnames(-1)
numFDs := int32(len(fnames)) numFDs := int32(len(fnames))
openfiles := make([]*OpenFilesStat, 0) var openfiles []*OpenFilesStat
for _, fd := range fnames { for _, fd := range fnames {
fpath := filepath.Join(statPath, fd) fpath := filepath.Join(statPath, fd)
filepath, err := os.Readlink(fpath) filepath, err := os.Readlink(fpath)

@ -51,7 +51,7 @@ type Win32_Process struct {
CommandLine *string CommandLine *string
Priority uint32 Priority uint32
CreationDate *time.Time CreationDate *time.Time
ProcessId uint32 ProcessID uint32
ThreadCount uint32 ThreadCount uint32
/* /*
@ -71,7 +71,7 @@ type Win32_Process struct {
OtherTransferCount uint64 OtherTransferCount uint64
PageFaults uint32 PageFaults uint32
PageFileUsage uint32 PageFileUsage uint32
ParentProcessId uint32 ParentProcessID uint32
PeakPageFileUsage uint32 PeakPageFileUsage uint32
PeakVirtualSize uint64 PeakVirtualSize uint64
PeakWorkingSetSize uint32 PeakWorkingSetSize uint32
@ -167,28 +167,28 @@ func (p *Process) CreateTime() (int64, error) {
} }
func (p *Process) Cwd() (string, error) { func (p *Process) Cwd() (string, error) {
return "", common.NotImplementedError return "", common.ErrNotImplementedError
} }
func (p *Process) Parent() (*Process, error) { func (p *Process) Parent() (*Process, error) {
return p, common.NotImplementedError return p, common.ErrNotImplementedError
} }
func (p *Process) Status() (string, error) { func (p *Process) Status() (string, error) {
return "", common.NotImplementedError return "", common.ErrNotImplementedError
} }
func (p *Process) Username() (string, error) { func (p *Process) Username() (string, error) {
return "", common.NotImplementedError return "", common.ErrNotImplementedError
} }
func (p *Process) Uids() ([]int32, error) { func (p *Process) Uids() ([]int32, error) {
var uids []int32 var uids []int32
return uids, common.NotImplementedError return uids, common.ErrNotImplementedError
} }
func (p *Process) Gids() ([]int32, error) { func (p *Process) Gids() ([]int32, error) {
var gids []int32 var gids []int32
return gids, common.NotImplementedError return gids, common.ErrNotImplementedError
} }
func (p *Process) Terminal() (string, error) { func (p *Process) Terminal() (string, error) {
return "", common.NotImplementedError return "", common.ErrNotImplementedError
} }
// Nice returnes priority in Windows // Nice returnes priority in Windows
@ -200,21 +200,21 @@ func (p *Process) Nice() (int32, error) {
return int32(dst[0].Priority), nil return int32(dst[0].Priority), nil
} }
func (p *Process) IOnice() (int32, error) { func (p *Process) IOnice() (int32, error) {
return 0, common.NotImplementedError return 0, common.ErrNotImplementedError
} }
func (p *Process) Rlimit() ([]RlimitStat, error) { func (p *Process) Rlimit() ([]RlimitStat, error) {
var rlimit []RlimitStat var rlimit []RlimitStat
return rlimit, common.NotImplementedError return rlimit, common.ErrNotImplementedError
} }
func (p *Process) IOCounters() (*IOCountersStat, error) { func (p *Process) IOCounters() (*IOCountersStat, error) {
return nil, common.NotImplementedError return nil, common.ErrNotImplementedError
} }
func (p *Process) NumCtxSwitches() (*NumCtxSwitchesStat, error) { func (p *Process) NumCtxSwitches() (*NumCtxSwitchesStat, error) {
return nil, common.NotImplementedError return nil, common.ErrNotImplementedError
} }
func (p *Process) NumFDs() (int32, error) { func (p *Process) NumFDs() (int32, error) {
return 0, common.NotImplementedError return 0, common.ErrNotImplementedError
} }
func (p *Process) NumThreads() (int32, error) { func (p *Process) NumThreads() (int32, error) {
dst, err := GetWin32Proc(p.Pid) dst, err := GetWin32Proc(p.Pid)
@ -225,44 +225,44 @@ func (p *Process) NumThreads() (int32, error) {
} }
func (p *Process) Threads() (map[string]string, error) { func (p *Process) Threads() (map[string]string, error) {
ret := make(map[string]string, 0) ret := make(map[string]string, 0)
return ret, common.NotImplementedError return ret, common.ErrNotImplementedError
} }
func (p *Process) Times() (*cpu.TimesStat, error) { func (p *Process) Times() (*cpu.TimesStat, error) {
return nil, common.NotImplementedError return nil, common.ErrNotImplementedError
} }
func (p *Process) CPUAffinity() ([]int32, error) { func (p *Process) CPUAffinity() ([]int32, error) {
return nil, common.NotImplementedError return nil, common.ErrNotImplementedError
} }
func (p *Process) MemoryInfo() (*MemoryInfoStat, error) { func (p *Process) MemoryInfo() (*MemoryInfoStat, error) {
return nil, common.NotImplementedError return nil, common.ErrNotImplementedError
} }
func (p *Process) MemoryInfoEx() (*MemoryInfoExStat, error) { func (p *Process) MemoryInfoEx() (*MemoryInfoExStat, error) {
return nil, common.NotImplementedError return nil, common.ErrNotImplementedError
} }
func (p *Process) Children() ([]*Process, error) { func (p *Process) Children() ([]*Process, error) {
return nil, common.NotImplementedError return nil, common.ErrNotImplementedError
} }
func (p *Process) OpenFiles() ([]OpenFilesStat, error) { func (p *Process) OpenFiles() ([]OpenFilesStat, error) {
return nil, common.NotImplementedError return nil, common.ErrNotImplementedError
} }
func (p *Process) Connections() ([]net.ConnectionStat, error) { func (p *Process) Connections() ([]net.ConnectionStat, error) {
return nil, common.NotImplementedError return nil, common.ErrNotImplementedError
} }
func (p *Process) NetIOCounters(pernic bool) ([]net.IOCountersStat, error) { func (p *Process) NetIOCounters(pernic bool) ([]net.IOCountersStat, error) {
return nil, common.NotImplementedError return nil, common.ErrNotImplementedError
} }
func (p *Process) IsRunning() (bool, error) { func (p *Process) IsRunning() (bool, error) {
return true, common.NotImplementedError return true, common.ErrNotImplementedError
} }
func (p *Process) MemoryMaps(grouped bool) (*[]MemoryMapsStat, error) { func (p *Process) MemoryMaps(grouped bool) (*[]MemoryMapsStat, error) {
ret := make([]MemoryMapsStat, 0) var ret []MemoryMapsStat
return &ret, common.NotImplementedError return &ret, common.ErrNotImplementedError
} }
func NewProcess(pid int32) (*Process, error) { func NewProcess(pid int32) (*Process, error) {
@ -272,20 +272,20 @@ func NewProcess(pid int32) (*Process, error) {
} }
func (p *Process) SendSignal(sig syscall.Signal) error { func (p *Process) SendSignal(sig syscall.Signal) error {
return common.NotImplementedError return common.ErrNotImplementedError
} }
func (p *Process) Suspend() error { func (p *Process) Suspend() error {
return common.NotImplementedError return common.ErrNotImplementedError
} }
func (p *Process) Resume() error { func (p *Process) Resume() error {
return common.NotImplementedError return common.ErrNotImplementedError
} }
func (p *Process) Terminate() error { func (p *Process) Terminate() error {
return common.NotImplementedError return common.ErrNotImplementedError
} }
func (p *Process) Kill() error { func (p *Process) Kill() error {
return common.NotImplementedError return common.ErrNotImplementedError
} }
func (p *Process) getFromSnapProcess(pid int32) (int32, int32, string, error) { func (p *Process) getFromSnapProcess(pid int32) (int32, int32, string, error) {
@ -328,7 +328,7 @@ func processes() ([]*Process, error) {
} }
results := make([]*Process, 0, len(dst)) results := make([]*Process, 0, len(dst))
for _, proc := range dst { for _, proc := range dst {
p, err := NewProcess(int32(proc.ProcessId)) p, err := NewProcess(int32(proc.ProcessID))
if err != nil { if err != nil {
continue continue
} }

Loading…
Cancel
Save