1
0
mirror of https://github.com/shirou/gopsutil.git synced 2025-05-02 22:17:08 +08:00

add args which same as psutil. but has not implemented yet.

This commit is contained in:
WAKAYAMA Shirou 2014-04-29 14:01:59 +09:00
parent 5c8c707ddd
commit 1a820b9a10
13 changed files with 14 additions and 14 deletions

2
cpu.go
View File

@ -19,6 +19,6 @@ type CPU_TimesStat struct {
Stolen float32 `json:"stolen"` Stolen float32 `json:"stolen"`
} }
func Cpu_counts() (int, error) { func Cpu_counts(logical bool) (int, error) {
return runtime.NumCPU(), nil return runtime.NumCPU(), nil
} }

View File

@ -22,7 +22,7 @@ const (
) )
// TODO: get per cpus // TODO: get per cpus
func Cpu_times() ([]CPU_TimesStat, error) { func Cpu_times(percpu bool) ([]CPU_TimesStat, error) {
ret := make([]CPU_TimesStat, 0) ret := make([]CPU_TimesStat, 0)
cpu_time, err := do_sysctrl("kern.cp_time") cpu_time, err := do_sysctrl("kern.cp_time")

View File

@ -8,7 +8,7 @@ import (
"strings" "strings"
) )
func Cpu_times() ([]CPU_TimesStat, error) { func Cpu_times(percpu bool) ([]CPU_TimesStat, error) {
ret := make([]CPU_TimesStat, 0) ret := make([]CPU_TimesStat, 0)
filename := "/proc/stat" filename := "/proc/stat"

View File

@ -5,7 +5,7 @@ import (
) )
func TestCpu_times(t *testing.T) { func TestCpu_times(t *testing.T) {
v, err := Cpu_times() v, err := Cpu_times(false)
if err != nil { if err != nil {
t.Errorf("error %v", err) t.Errorf("error %v", err)
} }
@ -21,7 +21,7 @@ func TestCpu_times(t *testing.T) {
} }
func TestCpu_counts(t *testing.T) { func TestCpu_counts(t *testing.T) {
v, err := Cpu_counts() v, err := Cpu_counts(true)
if err != nil { if err != nil {
t.Errorf("error %v", err) t.Errorf("error %v", err)
} }

View File

@ -7,7 +7,7 @@ import (
"unsafe" "unsafe"
) )
func Cpu_times() ([]CPU_TimesStat, error) { func Cpu_times(percpu bool) ([]CPU_TimesStat, error) {
ret := make([]CPU_TimesStat, 0) ret := make([]CPU_TimesStat, 0)
var lpIdleTime FILETIME var lpIdleTime FILETIME

View File

@ -7,7 +7,7 @@ import (
"unsafe" "unsafe"
) )
func Disk_partitions() ([]Disk_partitionStat, error) { func Disk_partitions(all bool) ([]Disk_partitionStat, error) {
ret := make([]Disk_partitionStat, 0) ret := make([]Disk_partitionStat, 0)
// get length // get length

View File

@ -2,7 +2,7 @@
package gopsutil package gopsutil
func Disk_partitions() ([]Disk_partitionStat, error) { func Disk_partitions(all bool) ([]Disk_partitionStat, error) {
ret := make([]Disk_partitionStat, 0) ret := make([]Disk_partitionStat, 0)
return ret, nil return ret, nil

View File

@ -21,7 +21,7 @@ func TestDisk_usage(t *testing.T) {
} }
func TestDisk_partitions(t *testing.T) { func TestDisk_partitions(t *testing.T) {
v, err := Disk_partitions() v, err := Disk_partitions(false)
if err != nil { if err != nil {
t.Errorf("error %v", err) t.Errorf("error %v", err)
} }

View File

@ -44,7 +44,7 @@ func Disk_usage(path string) (Disk_usageStat, error) {
return ret, nil return ret, nil
} }
func Disk_partitions() ([]Disk_partitionStat, error) { func Disk_partitions(all bool) ([]Disk_partitionStat, error) {
ret := make([]Disk_partitionStat, 0) ret := make([]Disk_partitionStat, 0)
lpBuffer := make([]byte, 254) lpBuffer := make([]byte, 254)
diskret, _, err := procGetLogicalDriveStringsW.Call( diskret, _, err := procGetLogicalDriveStringsW.Call(

View File

@ -127,7 +127,7 @@ func (p *Process) Connections() ([]Net_connectionStat, error) {
func (p *Process) Is_running() (bool, error) { func (p *Process) Is_running() (bool, error) {
return true, errors.New("Not implemented yet") 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) ret := make([]Memory_mapsStat, 0)
return &ret, errors.New("Not implemented yet") return &ret, errors.New("Not implemented yet")
} }

View File

@ -188,7 +188,7 @@ func (p *Process) Is_running() (bool, error) {
} }
// Get memory maps from /proc/(pid)/smaps // 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 pid := p.Pid
ret := make([]Memory_mapsStat, 0) ret := make([]Memory_mapsStat, 0)
smapsPath := filepath.Join("/", "proc", strconv.Itoa(int(pid)), "smaps") smapsPath := filepath.Join("/", "proc", strconv.Itoa(int(pid)), "smaps")

View File

@ -57,7 +57,7 @@ func Test_Process_memory_maps(t *testing.T) {
return return
ret, err := NewProcess(int32(check_pid)) ret, err := NewProcess(int32(check_pid))
mmaps, err := ret.Memory_Maps() mmaps, err := ret.Memory_Maps(false)
if err != nil { if err != nil {
t.Errorf("memory map get error %v", err) t.Errorf("memory map get error %v", err)
} }

View File

@ -160,7 +160,7 @@ func (p *Process) Is_running() (bool, error) {
return true, errors.New("Not implemented yet") 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") return nil, errors.New("Not implemented yet")
} }