mirror of
https://github.com/shirou/gopsutil.git
synced 2025-04-24 13:48:56 +08:00
move subdirectories. refer to issue #24
This commit is contained in:
parent
2f128c3955
commit
a4671fcc2a
@ -52,7 +52,7 @@ func readLinesOffsetN(filename string, offset uint, n int) ([]string, error) {
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func byteToString(orig []byte) string {
|
||||
func ByteToString(orig []byte) string {
|
||||
n := -1
|
||||
l := -1
|
||||
for i, b := range orig {
|
@ -7,7 +7,7 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
func doSysctrl(mib string) ([]string, error) {
|
||||
func DoSysctrl(mib string) ([]string, error) {
|
||||
out, err := exec.Command("/usr/sbin/sysctl", "-n", mib).Output()
|
||||
if err != nil {
|
||||
return []string{}, err
|
@ -7,7 +7,7 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
func doSysctrl(mib string) ([]string, error) {
|
||||
func DoSysctrl(mib string) ([]string, error) {
|
||||
out, err := exec.Command("/sbin/sysctl", "-n", mib).Output()
|
||||
if err != nil {
|
||||
return []string{}, err
|
@ -21,7 +21,7 @@ type FILETIME struct {
|
||||
}
|
||||
|
||||
// borrowed from net/interface_windows.go
|
||||
func bytePtrToString(p *uint8) string {
|
||||
func BytePtrToString(p *uint8) string {
|
||||
a := (*[10000]uint8)(unsafe.Pointer(p))
|
||||
i := 0
|
||||
for a[i] != 0 {
|
@ -7,6 +7,8 @@ import (
|
||||
"os/exec"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
common "github.com/shirou/gopsutil/common"
|
||||
)
|
||||
|
||||
// sys/resource.h
|
||||
@ -37,7 +39,7 @@ func CPUTimes(percpu bool) ([]CPUTimesStat, error) {
|
||||
ncpu = 1
|
||||
}
|
||||
|
||||
cpuTimes, err := doSysctrl(sysctlCall)
|
||||
cpuTimes, err := common.DoSysctrl(sysctlCall)
|
||||
if err != nil {
|
||||
return ret, err
|
||||
}
|
@ -7,6 +7,8 @@ import (
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
common "github.com/shirou/gopsutil/common"
|
||||
)
|
||||
|
||||
// sys/resource.h
|
||||
@ -37,7 +39,7 @@ func CPUTimes(percpu bool) ([]CPUTimesStat, error) {
|
||||
ncpu = 1
|
||||
}
|
||||
|
||||
cpuTimes, err := doSysctrl(sysctlCall)
|
||||
cpuTimes, err := common.DoSysctrl(sysctlCall)
|
||||
if err != nil {
|
||||
return ret, err
|
||||
}
|
@ -2,11 +2,15 @@
|
||||
|
||||
package gopsutil
|
||||
|
||||
import (
|
||||
common "github.com/shirou/gopsutil/common"
|
||||
)
|
||||
|
||||
func DiskPartitions(all bool) ([]DiskPartitionStat, error) {
|
||||
|
||||
return nil, NotImplementedError
|
||||
return nil, common.NotImplementedError
|
||||
}
|
||||
|
||||
func DiskIOCounters() (map[string]DiskIOCountersStat, error) {
|
||||
return nil, NotImplementedError
|
||||
return nil, common.NotImplementedError
|
||||
}
|
@ -5,6 +5,8 @@ package gopsutil
|
||||
import (
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
common "github.com/shirou/gopsutil/common"
|
||||
)
|
||||
|
||||
func DiskPartitions(all bool) ([]DiskPartitionStat, error) {
|
||||
@ -71,9 +73,9 @@ func DiskPartitions(all bool) ([]DiskPartitionStat, error) {
|
||||
}
|
||||
|
||||
d := DiskPartitionStat{
|
||||
Device: byteToString(stat.FMntfromname[:]),
|
||||
Mountpoint: byteToString(stat.FMntonname[:]),
|
||||
Fstype: byteToString(stat.FFstypename[:]),
|
||||
Device: common.ByteToString(stat.FMntfromname[:]),
|
||||
Mountpoint: common.ByteToString(stat.FMntonname[:]),
|
||||
Fstype: common.ByteToString(stat.FFstypename[:]),
|
||||
Opts: opts,
|
||||
}
|
||||
ret = append(ret, d)
|
||||
@ -83,7 +85,7 @@ func DiskPartitions(all bool) ([]DiskPartitionStat, error) {
|
||||
}
|
||||
|
||||
func DiskIOCounters() (map[string]DiskIOCountersStat, error) {
|
||||
return nil, NotImplementedError
|
||||
return nil, common.NotImplementedError
|
||||
|
||||
// statinfo->devinfo->devstat
|
||||
// /usr/include/devinfo.h
|
||||
@ -99,7 +101,7 @@ func DiskIOCounters() (map[string]DiskIOCountersStat, error) {
|
||||
|
||||
ret := make(map[string]DiskIOCountersStat, 0)
|
||||
for _, stat := range fs {
|
||||
name := byteToString(stat.FMntonname[:])
|
||||
name := ByteToString(stat.FMntonname[:])
|
||||
d := DiskIOCountersStat{
|
||||
Name: name,
|
||||
ReadCount: stat.FSyncwrites + stat.FAsyncwrites,
|
@ -6,6 +6,8 @@ import (
|
||||
"bytes"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
common "github.com/shirou/gopsutil/common"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -113,5 +115,5 @@ func DiskPartitions(all bool) ([]DiskPartitionStat, error) {
|
||||
|
||||
func DiskIOCounters() (map[string]DiskIOCountersStat, error) {
|
||||
ret := make(map[string]DiskIOCountersStat, 0)
|
||||
return ret, NotImplementedError
|
||||
return ret, common.NotImplementedError
|
||||
}
|
@ -12,6 +12,8 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"unsafe"
|
||||
|
||||
common "github.com/shirou/gopsutil/common"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -56,7 +58,7 @@ func HostInfo() (*HostInfoStat, error) {
|
||||
ret.VirtualizationRole = role
|
||||
}
|
||||
|
||||
values, err := doSysctrl("kern.boottime")
|
||||
values, err := common.DoSysctrl("kern.boottime")
|
||||
if err == nil {
|
||||
// ex: { sec = 1392261637, usec = 627534 } Thu Feb 13 12:20:37 2014
|
||||
v := strings.Replace(values[2], ",", "", 1)
|
||||
@ -71,7 +73,7 @@ func HostInfo() (*HostInfoStat, error) {
|
||||
}
|
||||
|
||||
func BootTime() (int64, error) {
|
||||
values, err := doSysctrl("kern.boottime")
|
||||
values, err := common.DoSysctrl("kern.boottime")
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
@ -114,9 +116,9 @@ func Users() ([]UserStat, error) {
|
||||
continue
|
||||
}
|
||||
user := UserStat{
|
||||
User: byteToString(u.UtUser[:]),
|
||||
// Terminal: byteToString(u.UtLine[:]),
|
||||
Host: byteToString(u.UtHost[:]),
|
||||
User: common.ByteToString(u.UtUser[:]),
|
||||
// Terminal: ByteToString(u.UtLine[:]),
|
||||
Host: common.ByteToString(u.UtHost[:]),
|
||||
// Started: int(u.UtTime),
|
||||
}
|
||||
ret = append(ret, user)
|
@ -12,6 +12,8 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"unsafe"
|
||||
|
||||
common "github.com/shirou/gopsutil/common"
|
||||
)
|
||||
|
||||
func HostInfo() (*HostInfoStat, error) {
|
||||
@ -38,7 +40,7 @@ func HostInfo() (*HostInfoStat, error) {
|
||||
ret.VirtualizationRole = role
|
||||
}
|
||||
|
||||
values, err := doSysctrl("kern.boottime")
|
||||
values, err := common.DoSysctrl("kern.boottime")
|
||||
if err == nil {
|
||||
// ex: { sec = 1392261637, usec = 627534 } Thu Feb 13 12:20:37 2014
|
||||
v := strings.Replace(values[2], ",", "", 1)
|
||||
@ -53,7 +55,7 @@ func HostInfo() (*HostInfoStat, error) {
|
||||
}
|
||||
|
||||
func BootTime() (int64, error) {
|
||||
values, err := doSysctrl("kern.boottime")
|
||||
values, err := common.DoSysctrl("kern.boottime")
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
@ -96,9 +98,9 @@ func Users() ([]UserStat, error) {
|
||||
continue
|
||||
}
|
||||
user := UserStat{
|
||||
User: byteToString(u.UtName[:]),
|
||||
Terminal: byteToString(u.UtLine[:]),
|
||||
Host: byteToString(u.UtHost[:]),
|
||||
User: common.ByteToString(u.UtName[:]),
|
||||
Terminal: common.ByteToString(u.UtLine[:]),
|
||||
Host: common.ByteToString(u.UtHost[:]),
|
||||
Started: int(u.UtTime),
|
||||
}
|
||||
ret = append(ret, user)
|
@ -13,6 +13,8 @@ import (
|
||||
"strings"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
common "github.com/shirou/gopsutil/common"
|
||||
)
|
||||
|
||||
type LSB struct {
|
||||
@ -89,9 +91,9 @@ func Users() ([]UserStat, error) {
|
||||
continue
|
||||
}
|
||||
user := UserStat{
|
||||
User: byteToString(u.UtUser[:]),
|
||||
Terminal: byteToString(u.UtLine[:]),
|
||||
Host: byteToString(u.UtHost[:]),
|
||||
User: common.ByteToString(u.UtUser[:]),
|
||||
Terminal: common.ByteToString(u.UtLine[:]),
|
||||
Host: common.ByteToString(u.UtHost[:]),
|
||||
Started: int(u.UtTv.TvSec),
|
||||
}
|
||||
ret = append(ret, user)
|
@ -4,10 +4,12 @@ package gopsutil
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
common "github.com/shirou/gopsutil/common"
|
||||
)
|
||||
|
||||
func LoadAvg() (*LoadAvgStat, error) {
|
||||
values, err := doSysctrl("vm.loadavg")
|
||||
values, err := common.DoSysctrl("vm.loadavg")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
@ -4,10 +4,12 @@ package gopsutil
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
common "github.com/shirou/gopsutil/common"
|
||||
)
|
||||
|
||||
func LoadAvg() (*LoadAvgStat, error) {
|
||||
values, err := doSysctrl("vm.loadavg")
|
||||
values, err := common.DoSysctrl("vm.loadavg")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
@ -2,8 +2,12 @@
|
||||
|
||||
package gopsutil
|
||||
|
||||
import (
|
||||
common "github.com/shirou/gopsutil/common"
|
||||
)
|
||||
|
||||
func LoadAvg() (*LoadAvgStat, error) {
|
||||
ret := LoadAvgStat{}
|
||||
|
||||
return &ret, NotImplementedError
|
||||
return &ret, common.NotImplementedError
|
||||
}
|
@ -6,6 +6,8 @@ import (
|
||||
"os/exec"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
common "github.com/shirou/gopsutil/common"
|
||||
)
|
||||
|
||||
func getPageSize() (uint64, error) {
|
||||
@ -29,11 +31,11 @@ func VirtualMemory() (*VirtualMemoryStat, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
total, err := doSysctrl("hw.memsize")
|
||||
total, err := common.DoSysctrl("hw.memsize")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
free, err := doSysctrl("vm.page_free_count")
|
||||
free, err := common.DoSysctrl("vm.page_free_count")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -68,7 +70,7 @@ func VirtualMemory() (*VirtualMemoryStat, error) {
|
||||
func SwapMemory() (*SwapMemoryStat, error) {
|
||||
var ret *SwapMemoryStat
|
||||
|
||||
swapUsage, err := doSysctrl("vm.swapusage")
|
||||
swapUsage, err := common.DoSysctrl("vm.swapusage")
|
||||
if err != nil {
|
||||
return ret, err
|
||||
}
|
@ -6,10 +6,12 @@ import (
|
||||
"os/exec"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
common "github.com/shirou/gopsutil/common"
|
||||
)
|
||||
|
||||
func VirtualMemory() (*VirtualMemoryStat, error) {
|
||||
pageSize, err := doSysctrl("vm.stats.vm.v_page_size")
|
||||
pageSize, err := common.DoSysctrl("vm.stats.vm.v_page_size")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -18,31 +20,31 @@ func VirtualMemory() (*VirtualMemoryStat, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
pageCount, err := doSysctrl("vm.stats.vm.v_page_count")
|
||||
pageCount, err := common.DoSysctrl("vm.stats.vm.v_page_count")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
free, err := doSysctrl("vm.stats.vm.v_free_count")
|
||||
free, err := common.DoSysctrl("vm.stats.vm.v_free_count")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
active, err := doSysctrl("vm.stats.vm.v_active_count")
|
||||
active, err := common.DoSysctrl("vm.stats.vm.v_active_count")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
inactive, err := doSysctrl("vm.stats.vm.v_inactive_count")
|
||||
inactive, err := common.DoSysctrl("vm.stats.vm.v_inactive_count")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
cache, err := doSysctrl("vm.stats.vm.v_cache_count")
|
||||
cache, err := common.DoSysctrl("vm.stats.vm.v_cache_count")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
buffer, err := doSysctrl("vfs.bufspace")
|
||||
buffer, err := common.DoSysctrl("vfs.bufspace")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
wired, err := doSysctrl("vm.stats.vm.v_wire_count")
|
||||
wired, err := common.DoSysctrl("vm.stats.vm.v_wire_count")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
@ -7,6 +7,8 @@ import (
|
||||
"os"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
common "github.com/shirou/gopsutil/common"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -71,7 +73,7 @@ func NetIOCounters(pernic bool) ([]NetIOCountersStat, error) {
|
||||
func NetConnections(kind string) ([]NetConnectionStat, error) {
|
||||
var ret []NetConnectionStat
|
||||
|
||||
return ret, NotImplementedError
|
||||
return ret, common.NotImplementedError
|
||||
}
|
||||
|
||||
// borrowed from src/pkg/net/interface_windows.go
|
@ -7,6 +7,10 @@ import (
|
||||
"encoding/binary"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
common "github.com/shirou/gopsutil/common"
|
||||
cpu "github.com/shirou/gopsutil/cpu"
|
||||
net "github.com/shirou/gopsutil/net"
|
||||
)
|
||||
|
||||
// MemoryInfoExStat is different between OSes
|
||||
@ -31,7 +35,7 @@ func Pids() ([]int32, error) {
|
||||
}
|
||||
|
||||
func (p *Process) Ppid() (int32, error) {
|
||||
return 0, NotImplementedError
|
||||
return 0, common.NotImplementedError
|
||||
|
||||
k, err := p.getKProc()
|
||||
if err != nil {
|
||||
@ -49,19 +53,19 @@ func (p *Process) Name() (string, error) {
|
||||
return string(k.KiComm[:]), nil
|
||||
}
|
||||
func (p *Process) Exe() (string, error) {
|
||||
return "", NotImplementedError
|
||||
return "", common.NotImplementedError
|
||||
}
|
||||
func (p *Process) Cmdline() (string, error) {
|
||||
return "", NotImplementedError
|
||||
return "", common.NotImplementedError
|
||||
}
|
||||
func (p *Process) CreateTime() (int64, error) {
|
||||
return 0, NotImplementedError
|
||||
return 0, common.NotImplementedError
|
||||
}
|
||||
func (p *Process) Cwd() (string, error) {
|
||||
return "", NotImplementedError
|
||||
return "", common.NotImplementedError
|
||||
}
|
||||
func (p *Process) Parent() (*Process, error) {
|
||||
return p, NotImplementedError
|
||||
return p, common.NotImplementedError
|
||||
}
|
||||
func (p *Process) Status() (string, error) {
|
||||
k, err := p.getKProc()
|
||||
@ -110,23 +114,23 @@ func (p *Process) Terminal() (string, error) {
|
||||
return termmap[ttyNr], nil
|
||||
}
|
||||
func (p *Process) Nice() (int32, error) {
|
||||
return 0, NotImplementedError
|
||||
return 0, common.NotImplementedError
|
||||
}
|
||||
func (p *Process) IOnice() (int32, error) {
|
||||
return 0, NotImplementedError
|
||||
return 0, common.NotImplementedError
|
||||
}
|
||||
func (p *Process) Rlimit() ([]RlimitStat, error) {
|
||||
var rlimit []RlimitStat
|
||||
return rlimit, NotImplementedError
|
||||
return rlimit, common.NotImplementedError
|
||||
}
|
||||
func (p *Process) IOCounters() (*IOCountersStat, error) {
|
||||
return nil, NotImplementedError
|
||||
return nil, common.NotImplementedError
|
||||
}
|
||||
func (p *Process) NumCtxSwitches() (*NumCtxSwitchesStat, error) {
|
||||
return nil, NotImplementedError
|
||||
return nil, common.NotImplementedError
|
||||
}
|
||||
func (p *Process) NumFDs() (int32, error) {
|
||||
return 0, NotImplementedError
|
||||
return 0, common.NotImplementedError
|
||||
}
|
||||
func (p *Process) NumThreads() (int32, error) {
|
||||
k, err := p.getKProc()
|
||||
@ -138,16 +142,16 @@ func (p *Process) NumThreads() (int32, error) {
|
||||
}
|
||||
func (p *Process) Threads() (map[string]string, error) {
|
||||
ret := make(map[string]string, 0)
|
||||
return ret, NotImplementedError
|
||||
return ret, common.NotImplementedError
|
||||
}
|
||||
func (p *Process) CPUTimes() (*CPUTimesStat, error) {
|
||||
return nil, NotImplementedError
|
||||
func (p *Process) CPUTimes() (*cpu.CPUTimesStat, error) {
|
||||
return nil, common.NotImplementedError
|
||||
}
|
||||
func (p *Process) CPUPercent() (int32, error) {
|
||||
return 0, NotImplementedError
|
||||
return 0, common.NotImplementedError
|
||||
}
|
||||
func (p *Process) CPUAffinity() ([]int32, error) {
|
||||
return nil, NotImplementedError
|
||||
return nil, common.NotImplementedError
|
||||
}
|
||||
func (p *Process) MemoryInfo() (*MemoryInfoStat, error) {
|
||||
k, err := p.getKProc()
|
||||
@ -163,30 +167,30 @@ func (p *Process) MemoryInfo() (*MemoryInfoStat, error) {
|
||||
return ret, nil
|
||||
}
|
||||
func (p *Process) MemoryInfoEx() (*MemoryInfoExStat, error) {
|
||||
return nil, NotImplementedError
|
||||
return nil, common.NotImplementedError
|
||||
}
|
||||
func (p *Process) MemoryPercent() (float32, error) {
|
||||
return 0, NotImplementedError
|
||||
return 0, common.NotImplementedError
|
||||
}
|
||||
|
||||
func (p *Process) Children() ([]*Process, error) {
|
||||
return nil, NotImplementedError
|
||||
return nil, common.NotImplementedError
|
||||
}
|
||||
|
||||
func (p *Process) OpenFiles() ([]OpenFilesStat, error) {
|
||||
return nil, NotImplementedError
|
||||
return nil, common.NotImplementedError
|
||||
}
|
||||
|
||||
func (p *Process) Connections() ([]NetConnectionStat, error) {
|
||||
return nil, NotImplementedError
|
||||
func (p *Process) Connections() ([]net.NetConnectionStat, error) {
|
||||
return nil, common.NotImplementedError
|
||||
}
|
||||
|
||||
func (p *Process) IsRunning() (bool, error) {
|
||||
return true, NotImplementedError
|
||||
return true, common.NotImplementedError
|
||||
}
|
||||
func (p *Process) MemoryMaps(grouped bool) (*[]MemoryMapsStat, error) {
|
||||
var ret []MemoryMapsStat
|
||||
return &ret, NotImplementedError
|
||||
return &ret, common.NotImplementedError
|
||||
}
|
||||
|
||||
func copyParams(k *KinfoProc, p *Process) error {
|
@ -7,6 +7,10 @@ import (
|
||||
"encoding/binary"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
common "github.com/shirou/gopsutil/common"
|
||||
cpu "github.com/shirou/gopsutil/cpu"
|
||||
net "github.com/shirou/gopsutil/net"
|
||||
)
|
||||
|
||||
// MemoryInfoExStat is different between OSes
|
||||
@ -47,19 +51,19 @@ func (p *Process) Name() (string, error) {
|
||||
return string(k.KiComm[:]), nil
|
||||
}
|
||||
func (p *Process) Exe() (string, error) {
|
||||
return "", NotImplementedError
|
||||
return "", common.NotImplementedError
|
||||
}
|
||||
func (p *Process) Cmdline() (string, error) {
|
||||
return "", NotImplementedError
|
||||
return "", common.NotImplementedError
|
||||
}
|
||||
func (p *Process) CreateTime() (int64, error) {
|
||||
return 0, NotImplementedError
|
||||
return 0, common.NotImplementedError
|
||||
}
|
||||
func (p *Process) Cwd() (string, error) {
|
||||
return "", NotImplementedError
|
||||
return "", common.NotImplementedError
|
||||
}
|
||||
func (p *Process) Parent() (*Process, error) {
|
||||
return p, NotImplementedError
|
||||
return p, common.NotImplementedError
|
||||
}
|
||||
func (p *Process) Status() (string, error) {
|
||||
k, err := p.getKProc()
|
||||
@ -108,23 +112,23 @@ func (p *Process) Terminal() (string, error) {
|
||||
return termmap[ttyNr], nil
|
||||
}
|
||||
func (p *Process) Nice() (int32, error) {
|
||||
return 0, NotImplementedError
|
||||
return 0, common.NotImplementedError
|
||||
}
|
||||
func (p *Process) IOnice() (int32, error) {
|
||||
return 0, NotImplementedError
|
||||
return 0, common.NotImplementedError
|
||||
}
|
||||
func (p *Process) Rlimit() ([]RlimitStat, error) {
|
||||
var rlimit []RlimitStat
|
||||
return rlimit, NotImplementedError
|
||||
return rlimit, common.NotImplementedError
|
||||
}
|
||||
func (p *Process) IOCounters() (*IOCountersStat, error) {
|
||||
return nil, NotImplementedError
|
||||
return nil, common.NotImplementedError
|
||||
}
|
||||
func (p *Process) NumCtxSwitches() (*NumCtxSwitchesStat, error) {
|
||||
return nil, NotImplementedError
|
||||
return nil, common.NotImplementedError
|
||||
}
|
||||
func (p *Process) NumFDs() (int32, error) {
|
||||
return 0, NotImplementedError
|
||||
return 0, common.NotImplementedError
|
||||
}
|
||||
func (p *Process) NumThreads() (int32, error) {
|
||||
k, err := p.getKProc()
|
||||
@ -136,16 +140,16 @@ func (p *Process) NumThreads() (int32, error) {
|
||||
}
|
||||
func (p *Process) Threads() (map[string]string, error) {
|
||||
ret := make(map[string]string, 0)
|
||||
return ret, NotImplementedError
|
||||
return ret, common.NotImplementedError
|
||||
}
|
||||
func (p *Process) CPUTimes() (*CPUTimesStat, error) {
|
||||
return nil, NotImplementedError
|
||||
func (p *Process) CPUTimes() (*cpu.CPUTimesStat, error) {
|
||||
return nil, common.NotImplementedError
|
||||
}
|
||||
func (p *Process) CPUPercent() (int32, error) {
|
||||
return 0, NotImplementedError
|
||||
return 0, common.NotImplementedError
|
||||
}
|
||||
func (p *Process) CPUAffinity() ([]int32, error) {
|
||||
return nil, NotImplementedError
|
||||
return nil, common.NotImplementedError
|
||||
}
|
||||
func (p *Process) MemoryInfo() (*MemoryInfoStat, error) {
|
||||
k, err := p.getKProc()
|
||||
@ -161,30 +165,30 @@ func (p *Process) MemoryInfo() (*MemoryInfoStat, error) {
|
||||
return ret, nil
|
||||
}
|
||||
func (p *Process) MemoryInfoEx() (*MemoryInfoExStat, error) {
|
||||
return nil, NotImplementedError
|
||||
return nil, common.NotImplementedError
|
||||
}
|
||||
func (p *Process) MemoryPercent() (float32, error) {
|
||||
return 0, NotImplementedError
|
||||
return 0, common.NotImplementedError
|
||||
}
|
||||
|
||||
func (p *Process) Children() ([]*Process, error) {
|
||||
return nil, NotImplementedError
|
||||
return nil, common.NotImplementedError
|
||||
}
|
||||
|
||||
func (p *Process) OpenFiles() ([]OpenFilesStat, error) {
|
||||
return nil, NotImplementedError
|
||||
return nil, common.NotImplementedError
|
||||
}
|
||||
|
||||
func (p *Process) Connections() ([]NetConnectionStat, error) {
|
||||
return nil, NotImplementedError
|
||||
func (p *Process) Connections() ([]net.NetConnectionStat, error) {
|
||||
return nil, common.NotImplementedError
|
||||
}
|
||||
|
||||
func (p *Process) IsRunning() (bool, error) {
|
||||
return true, NotImplementedError
|
||||
return true, common.NotImplementedError
|
||||
}
|
||||
func (p *Process) MemoryMaps(grouped bool) (*[]MemoryMapsStat, error) {
|
||||
var ret []MemoryMapsStat
|
||||
return &ret, NotImplementedError
|
||||
return &ret, common.NotImplementedError
|
||||
}
|
||||
|
||||
func copyParams(k *KinfoProc, p *Process) error {
|
@ -10,6 +10,10 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
common "github.com/shirou/gopsutil/common"
|
||||
cpu "github.com/shirou/gopsutil/cpu"
|
||||
net "github.com/shirou/gopsutil/net"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -89,7 +93,7 @@ func (p *Process) Cwd() (string, error) {
|
||||
return p.fillFromCwd()
|
||||
}
|
||||
func (p *Process) Parent() (*Process, error) {
|
||||
return nil, NotImplementedError
|
||||
return nil, common.NotImplementedError
|
||||
}
|
||||
func (p *Process) Status() (string, error) {
|
||||
return p.status, nil
|
||||
@ -115,10 +119,10 @@ func (p *Process) Nice() (int32, error) {
|
||||
return nice, nil
|
||||
}
|
||||
func (p *Process) IOnice() (int32, error) {
|
||||
return 0, NotImplementedError
|
||||
return 0, common.NotImplementedError
|
||||
}
|
||||
func (p *Process) Rlimit() ([]RlimitStat, error) {
|
||||
return nil, NotImplementedError
|
||||
return nil, common.NotImplementedError
|
||||
}
|
||||
func (p *Process) IOCounters() (*IOCountersStat, error) {
|
||||
return p.fillFromIO()
|
||||
@ -127,7 +131,7 @@ func (p *Process) NumCtxSwitches() (*NumCtxSwitchesStat, error) {
|
||||
return p.numCtxSwitches, nil
|
||||
}
|
||||
func (p *Process) NumFDs() (int32, error) {
|
||||
return 0, NotImplementedError
|
||||
return 0, common.NotImplementedError
|
||||
}
|
||||
func (p *Process) NumThreads() (int32, error) {
|
||||
return p.numThreads, nil
|
||||
@ -136,7 +140,7 @@ func (p *Process) Threads() (map[string]string, error) {
|
||||
ret := make(map[string]string, 0)
|
||||
return ret, nil
|
||||
}
|
||||
func (p *Process) CPUTimes() (*CPUTimesStat, error) {
|
||||
func (p *Process) CPUTimes() (*cpu.CPUTimesStat, error) {
|
||||
_, _, cpuTimes, _, _, err := p.fillFromStat()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -144,10 +148,10 @@ func (p *Process) CPUTimes() (*CPUTimesStat, error) {
|
||||
return cpuTimes, nil
|
||||
}
|
||||
func (p *Process) CPUPercent() (int32, error) {
|
||||
return 0, NotImplementedError
|
||||
return 0, common.NotImplementedError
|
||||
}
|
||||
func (p *Process) CPUAffinity() ([]int32, error) {
|
||||
return nil, NotImplementedError
|
||||
return nil, common.NotImplementedError
|
||||
}
|
||||
func (p *Process) MemoryInfo() (*MemoryInfoStat, error) {
|
||||
return p.memInfo, nil
|
||||
@ -160,23 +164,23 @@ func (p *Process) MemoryInfoEx() (*MemoryInfoExStat, error) {
|
||||
return memInfoEx, nil
|
||||
}
|
||||
func (p *Process) MemoryPercent() (float32, error) {
|
||||
return 0, NotImplementedError
|
||||
return 0, common.NotImplementedError
|
||||
}
|
||||
|
||||
func (p *Process) Children() ([]*Process, error) {
|
||||
return nil, NotImplementedError
|
||||
return nil, common.NotImplementedError
|
||||
}
|
||||
|
||||
func (p *Process) OpenFiles() ([]OpenFilesStat, error) {
|
||||
return nil, NotImplementedError
|
||||
return nil, common.NotImplementedError
|
||||
}
|
||||
|
||||
func (p *Process) Connections() ([]NetConnectionStat, error) {
|
||||
return nil, NotImplementedError
|
||||
func (p *Process) Connections() ([]net.NetConnectionStat, error) {
|
||||
return nil, common.NotImplementedError
|
||||
}
|
||||
|
||||
func (p *Process) IsRunning() (bool, error) {
|
||||
return true, NotImplementedError
|
||||
return true, common.NotImplementedError
|
||||
}
|
||||
|
||||
// MemoryMaps get memory maps from /proc/(pid)/smaps
|
||||
@ -513,7 +517,7 @@ func (p *Process) fillFromStatus() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *Process) fillFromStat() (string, int32, *CPUTimesStat, int64, int32, error) {
|
||||
func (p *Process) fillFromStat() (string, int32, *cpu.CPUTimesStat, int64, int32, error) {
|
||||
pid := p.Pid
|
||||
statPath := filepath.Join("/", "proc", strconv.Itoa(int(pid)), "stat")
|
||||
contents, err := ioutil.ReadFile(statPath)
|
||||
@ -545,7 +549,7 @@ func (p *Process) fillFromStat() (string, int32, *CPUTimesStat, int64, int32, er
|
||||
return "", 0, nil, 0, 0, err
|
||||
}
|
||||
|
||||
cpuTimes := &CPUTimesStat{
|
||||
cpuTimes := &cpu.CPUTimesStat{
|
||||
CPU: "cpu",
|
||||
User: float32(utime * (1000 / ClockTicks)),
|
||||
System: float32(stime * (1000 / ClockTicks)),
|
@ -8,6 +8,8 @@ import (
|
||||
"unsafe"
|
||||
|
||||
"github.com/shirou/w32"
|
||||
|
||||
common "github.com/shirou/gopsutil/common"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -61,7 +63,7 @@ func (p *Process) Ppid() (int32, error) {
|
||||
}
|
||||
func (p *Process) Name() (string, error) {
|
||||
name := ""
|
||||
return name, NotImplementedError
|
||||
return name, common.NotImplementedError
|
||||
}
|
||||
func (p *Process) Exe() (string, error) {
|
||||
_, _, ret, err := p.getFromSnapProcess(p.Pid)
|
||||
@ -71,51 +73,51 @@ func (p *Process) Exe() (string, error) {
|
||||
return ret, nil
|
||||
}
|
||||
func (p *Process) Cmdline() (string, error) {
|
||||
return "", NotImplementedError
|
||||
return "", common.NotImplementedError
|
||||
}
|
||||
func (p *Process) Cwd() (string, error) {
|
||||
return "", NotImplementedError
|
||||
return "", common.NotImplementedError
|
||||
}
|
||||
func (p *Process) Parent() (*Process, error) {
|
||||
return p, NotImplementedError
|
||||
return p, common.NotImplementedError
|
||||
}
|
||||
func (p *Process) Status() (string, error) {
|
||||
return "", NotImplementedError
|
||||
return "", common.NotImplementedError
|
||||
}
|
||||
func (p *Process) Username() (string, error) {
|
||||
return "", NotImplementedError
|
||||
return "", common.NotImplementedError
|
||||
}
|
||||
func (p *Process) Uids() ([]int32, error) {
|
||||
var uids []int32
|
||||
|
||||
return uids, NotImplementedError
|
||||
return uids, common.NotImplementedError
|
||||
}
|
||||
func (p *Process) Gids() ([]int32, error) {
|
||||
var gids []int32
|
||||
return gids, NotImplementedError
|
||||
return gids, common.NotImplementedError
|
||||
}
|
||||
func (p *Process) Terminal() (string, error) {
|
||||
return "", NotImplementedError
|
||||
return "", common.NotImplementedError
|
||||
}
|
||||
func (p *Process) Nice() (int32, error) {
|
||||
return 0, NotImplementedError
|
||||
return 0, common.NotImplementedError
|
||||
}
|
||||
func (p *Process) IOnice() (int32, error) {
|
||||
return 0, NotImplementedError
|
||||
return 0, common.NotImplementedError
|
||||
}
|
||||
func (p *Process) Rlimit() ([]RlimitStat, error) {
|
||||
var rlimit []RlimitStat
|
||||
|
||||
return rlimit, NotImplementedError
|
||||
return rlimit, common.NotImplementedError
|
||||
}
|
||||
func (p *Process) IOCounters() (*IOCountersStat, error) {
|
||||
return nil, NotImplementedError
|
||||
return nil, common.NotImplementedError
|
||||
}
|
||||
func (p *Process) NumCtxSwitches() (*NumCtxSwitchesStat, error) {
|
||||
return nil, NotImplementedError
|
||||
return nil, common.NotImplementedError
|
||||
}
|
||||
func (p *Process) NumFDs() (int32, error) {
|
||||
return 0, NotImplementedError
|
||||
return 0, common.NotImplementedError
|
||||
}
|
||||
func (p *Process) NumThreads() (int32, error) {
|
||||
_, ret, _, err := p.getFromSnapProcess(p.Pid)
|
||||
@ -126,46 +128,46 @@ func (p *Process) NumThreads() (int32, error) {
|
||||
}
|
||||
func (p *Process) Threads() (map[string]string, error) {
|
||||
ret := make(map[string]string, 0)
|
||||
return ret, NotImplementedError
|
||||
return ret, common.NotImplementedError
|
||||
}
|
||||
func (p *Process) CPUTimes() (*CPUTimesStat, error) {
|
||||
return nil, NotImplementedError
|
||||
return nil, common.NotImplementedError
|
||||
}
|
||||
func (p *Process) CPUPercent() (int32, error) {
|
||||
return 0, NotImplementedError
|
||||
return 0, common.NotImplementedError
|
||||
}
|
||||
func (p *Process) CPUAffinity() ([]int32, error) {
|
||||
return nil, NotImplementedError
|
||||
return nil, common.NotImplementedError
|
||||
}
|
||||
func (p *Process) MemoryInfo() (*MemoryInfoStat, error) {
|
||||
return nil, NotImplementedError
|
||||
return nil, common.NotImplementedError
|
||||
}
|
||||
func (p *Process) MemoryInfoEx() (*MemoryInfoExStat, error) {
|
||||
return nil, NotImplementedError
|
||||
return nil, common.NotImplementedError
|
||||
}
|
||||
func (p *Process) MemoryPercent() (float32, error) {
|
||||
return 0, NotImplementedError
|
||||
return 0, common.NotImplementedError
|
||||
}
|
||||
|
||||
func (p *Process) Children() ([]*Process, error) {
|
||||
return nil, NotImplementedError
|
||||
return nil, common.NotImplementedError
|
||||
}
|
||||
|
||||
func (p *Process) OpenFiles() ([]OpenFilesStat, error) {
|
||||
return nil, NotImplementedError
|
||||
return nil, common.NotImplementedError
|
||||
}
|
||||
|
||||
func (p *Process) Connections() ([]NetConnectionStat, error) {
|
||||
return nil, NotImplementedError
|
||||
return nil, common.NotImplementedError
|
||||
}
|
||||
|
||||
func (p *Process) IsRunning() (bool, error) {
|
||||
return true, NotImplementedError
|
||||
return true, common.NotImplementedError
|
||||
}
|
||||
|
||||
func (p *Process) MemoryMaps(grouped bool) (*[]MemoryMapsStat, error) {
|
||||
ret := make([]MemoryMapsStat, 0)
|
||||
return &ret, NotImplementedError
|
||||
return &ret, common.NotImplementedError
|
||||
}
|
||||
|
||||
func NewProcess(pid int32) (*Process, error) {
|
||||
@ -175,20 +177,20 @@ func NewProcess(pid int32) (*Process, error) {
|
||||
}
|
||||
|
||||
func (p *Process) SendSignal(sig syscall.Signal) error {
|
||||
return NotImplementedError
|
||||
return common.NotImplementedError
|
||||
}
|
||||
|
||||
func (p *Process) Suspend() error {
|
||||
return NotImplementedError
|
||||
return common.NotImplementedError
|
||||
}
|
||||
func (p *Process) Resume() error {
|
||||
return NotImplementedError
|
||||
return common.NotImplementedError
|
||||
}
|
||||
func (p *Process) Terminate() error {
|
||||
return NotImplementedError
|
||||
return common.NotImplementedError
|
||||
}
|
||||
func (p *Process) Kill() error {
|
||||
return NotImplementedError
|
||||
return common.NotImplementedError
|
||||
}
|
||||
|
||||
func (p *Process) getFromSnapProcess(pid int32) (int32, int32, string, error) {
|
Loading…
x
Reference in New Issue
Block a user