mirror of
https://github.com/shirou/gopsutil.git
synced 2025-05-01 13:48:52 +08:00
add args which same as psutil. but has not implemented yet.
This commit is contained in:
parent
5c8c707ddd
commit
1a820b9a10
2
cpu.go
2
cpu.go
@ -19,6 +19,6 @@ type CPU_TimesStat struct {
|
||||
Stolen float32 `json:"stolen"`
|
||||
}
|
||||
|
||||
func Cpu_counts() (int, error) {
|
||||
func Cpu_counts(logical bool) (int, error) {
|
||||
return runtime.NumCPU(), nil
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ const (
|
||||
)
|
||||
|
||||
// TODO: get per cpus
|
||||
func Cpu_times() ([]CPU_TimesStat, error) {
|
||||
func Cpu_times(percpu bool) ([]CPU_TimesStat, error) {
|
||||
ret := make([]CPU_TimesStat, 0)
|
||||
|
||||
cpu_time, err := do_sysctrl("kern.cp_time")
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
func Cpu_times() ([]CPU_TimesStat, error) {
|
||||
func Cpu_times(percpu bool) ([]CPU_TimesStat, error) {
|
||||
ret := make([]CPU_TimesStat, 0)
|
||||
|
||||
filename := "/proc/stat"
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
)
|
||||
|
||||
func TestCpu_times(t *testing.T) {
|
||||
v, err := Cpu_times()
|
||||
v, err := Cpu_times(false)
|
||||
if err != nil {
|
||||
t.Errorf("error %v", err)
|
||||
}
|
||||
@ -21,7 +21,7 @@ func TestCpu_times(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCpu_counts(t *testing.T) {
|
||||
v, err := Cpu_counts()
|
||||
v, err := Cpu_counts(true)
|
||||
if err != nil {
|
||||
t.Errorf("error %v", err)
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
func Cpu_times() ([]CPU_TimesStat, error) {
|
||||
func Cpu_times(percpu bool) ([]CPU_TimesStat, error) {
|
||||
ret := make([]CPU_TimesStat, 0)
|
||||
|
||||
var lpIdleTime FILETIME
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
func Disk_partitions() ([]Disk_partitionStat, error) {
|
||||
func Disk_partitions(all bool) ([]Disk_partitionStat, error) {
|
||||
ret := make([]Disk_partitionStat, 0)
|
||||
|
||||
// get length
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
package gopsutil
|
||||
|
||||
func Disk_partitions() ([]Disk_partitionStat, error) {
|
||||
func Disk_partitions(all bool) ([]Disk_partitionStat, error) {
|
||||
ret := make([]Disk_partitionStat, 0)
|
||||
|
||||
return ret, nil
|
||||
|
@ -21,7 +21,7 @@ func TestDisk_usage(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDisk_partitions(t *testing.T) {
|
||||
v, err := Disk_partitions()
|
||||
v, err := Disk_partitions(false)
|
||||
if err != nil {
|
||||
t.Errorf("error %v", err)
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ func Disk_usage(path string) (Disk_usageStat, error) {
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func Disk_partitions() ([]Disk_partitionStat, error) {
|
||||
func Disk_partitions(all bool) ([]Disk_partitionStat, error) {
|
||||
ret := make([]Disk_partitionStat, 0)
|
||||
lpBuffer := make([]byte, 254)
|
||||
diskret, _, err := procGetLogicalDriveStringsW.Call(
|
||||
|
@ -127,7 +127,7 @@ func (p *Process) Connections() ([]Net_connectionStat, error) {
|
||||
func (p *Process) Is_running() (bool, error) {
|
||||
return true, errors.New("Not implemented yet")
|
||||
}
|
||||
func (p *Process) Memory_Maps() (*[]Memory_mapsStat, error) {
|
||||
func (p *Process) Memory_Maps(grouped bool) (*[]Memory_mapsStat, error) {
|
||||
ret := make([]Memory_mapsStat, 0)
|
||||
return &ret, errors.New("Not implemented yet")
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ func (p *Process) Is_running() (bool, error) {
|
||||
}
|
||||
|
||||
// Get memory maps from /proc/(pid)/smaps
|
||||
func (p *Process) Memory_Maps() (*[]Memory_mapsStat, error) {
|
||||
func (p *Process) Memory_Maps(grouped bool) (*[]Memory_mapsStat, error) {
|
||||
pid := p.Pid
|
||||
ret := make([]Memory_mapsStat, 0)
|
||||
smapsPath := filepath.Join("/", "proc", strconv.Itoa(int(pid)), "smaps")
|
||||
|
@ -57,7 +57,7 @@ func Test_Process_memory_maps(t *testing.T) {
|
||||
return
|
||||
ret, err := NewProcess(int32(check_pid))
|
||||
|
||||
mmaps, err := ret.Memory_Maps()
|
||||
mmaps, err := ret.Memory_Maps(false)
|
||||
if err != nil {
|
||||
t.Errorf("memory map get error %v", err)
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ func (p *Process) Is_running() (bool, error) {
|
||||
return true, errors.New("Not implemented yet")
|
||||
}
|
||||
|
||||
func (p *Process) Memory_Maps() (*[]Memory_mapsStat, error) {
|
||||
func (p *Process) Memory_Maps(grouped bool) (*[]Memory_mapsStat, error) {
|
||||
return nil, errors.New("Not implemented yet")
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user