return "not implemented yet" error instead of nil.

pull/4/head
WAKAYAMA Shirou 11 years ago
parent 7e2e63dc13
commit 5c8c707ddd

@ -5,6 +5,7 @@ package gopsutil
import ( import (
"bytes" "bytes"
"encoding/binary" "encoding/binary"
"errors"
"syscall" "syscall"
"unsafe" "unsafe"
) )
@ -30,106 +31,105 @@ func Pids() ([]int32, error) {
return ret, nil return ret, nil
} }
func (p *Process) Ppid() (int32, error) { func (p *Process) Ppid() (int32, error) {
return 0, nil return 0, errors.New("Not implemented yet")
} }
func (p *Process) Name() (string, error) { func (p *Process) Name() (string, error) {
name := "" name := ""
return name, nil return name, errors.New("Not implemented yet")
} }
func (p *Process) Exe() (string, error) { func (p *Process) Exe() (string, error) {
return "", nil return "", errors.New("Not implemented yet")
} }
func (p *Process) Cmdline() (string, error) { func (p *Process) Cmdline() (string, error) {
return "", nil return "", errors.New("Not implemented yet")
} }
func (p *Process) Cwd() (string, error) { func (p *Process) Cwd() (string, error) {
return "", nil return "", errors.New("Not implemented yet")
} }
func (p *Process) Parent() (*Process, error) { func (p *Process) Parent() (*Process, error) {
return p, nil return p, errors.New("Not implemented yet")
} }
func (p *Process) Status() (string, error) { func (p *Process) Status() (string, error) {
return "", nil return "", errors.New("Not implemented yet")
} }
func (p *Process) Username() (string, error) { func (p *Process) Username() (string, error) {
return "", nil return "", errors.New("Not implemented yet")
} }
func (p *Process) Uids() ([]int32, error) { func (p *Process) Uids() ([]int32, error) {
uids := make([]int32, 0) uids := make([]int32, 0)
return uids, nil return uids, errors.New("Not implemented yet")
} }
func (p *Process) Gids() ([]int32, error) { func (p *Process) Gids() ([]int32, error) {
gids := make([]int32, 0) gids := make([]int32, 0)
return gids, nil return gids, errors.New("Not implemented yet")
} }
func (p *Process) Terminal() (string, error) { func (p *Process) Terminal() (string, error) {
return "", nil return "", errors.New("Not implemented yet")
} }
func (p *Process) Nice() (int32, error) { func (p *Process) Nice() (int32, error) {
return 0, nil return 0, errors.New("Not implemented yet")
} }
func (p *Process) Ionice() (int32, error) { func (p *Process) Ionice() (int32, error) {
return 0, nil return 0, errors.New("Not implemented yet")
} }
func (p *Process) Rlimit() ([]RlimitStat, error) { func (p *Process) Rlimit() ([]RlimitStat, error) {
rlimit := make([]RlimitStat, 0) rlimit := make([]RlimitStat, 0)
return rlimit, nil return rlimit, errors.New("Not implemented yet")
} }
func (p *Process) Io_counters() (*Io_countersStat, error) { func (p *Process) Io_counters() (*Io_countersStat, error) {
return nil, nil return nil, errors.New("Not implemented yet")
} }
func (p *Process) Num_ctx_switches() (int32, error) { func (p *Process) Num_ctx_switches() (int32, error) {
return 0, nil return 0, errors.New("Not implemented yet")
} }
func (p *Process) Num_fds() (int32, error) { func (p *Process) Num_fds() (int32, error) {
return 0, nil return 0, errors.New("Not implemented yet")
} }
func (p *Process) Num_Threads() (int32, error) { func (p *Process) Num_Threads() (int32, error) {
return 0, nil return 0, errors.New("Not implemented yet")
} }
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, nil return ret, errors.New("Not implemented yet")
} }
func (p *Process) Cpu_times() (*CPU_TimesStat, error) { func (p *Process) Cpu_times() (*CPU_TimesStat, error) {
return nil, nil return nil, errors.New("Not implemented yet")
} }
func (p *Process) Cpu_percent() (int32, error) { func (p *Process) Cpu_percent() (int32, error) {
return 0, nil return 0, errors.New("Not implemented yet")
} }
func (p *Process) Cpu_affinity() ([]int32, error) { func (p *Process) Cpu_affinity() ([]int32, error) {
return nil, nil return nil, errors.New("Not implemented yet")
} }
func (p *Process) Memory_info() (*Memory_infoStat, error) { func (p *Process) Memory_info() (*Memory_infoStat, error) {
return nil, nil return nil, errors.New("Not implemented yet")
} }
func (p *Process) Memory_info_ex() (*Memory_info_exStat, error) { func (p *Process) Memory_info_ex() (*Memory_info_exStat, error) {
return nil, nil return nil, errors.New("Not implemented yet")
} }
func (p *Process) Memory_percent() (float32, error) { func (p *Process) Memory_percent() (float32, error) {
return 0, nil return 0, errors.New("Not implemented yet")
} }
func (p *Process) Children() ([]*Process, error) { func (p *Process) Children() ([]*Process, error) {
return nil, nil return nil, errors.New("Not implemented yet")
} }
func (p *Process) Open_files() ([]Open_filesStat, error) { func (p *Process) Open_files() ([]Open_filesStat, error) {
return nil, nil return nil, errors.New("Not implemented yet")
} }
func (p *Process) Connections() ([]Net_connectionStat, error) { func (p *Process) Connections() ([]Net_connectionStat, error) {
return nil, nil return nil, errors.New("Not implemented yet")
} }
func (p *Process) Is_running() (bool, error) { func (p *Process) Is_running() (bool, error) {
return true, nil return true, errors.New("Not implemented yet")
} }
func (p *Process) Memory_Maps() (*[]Memory_mapsStat, error) { func (p *Process) Memory_Maps() (*[]Memory_mapsStat, error) {
ret := make([]Memory_mapsStat, 0) ret := make([]Memory_mapsStat, 0)
return &ret, nil return &ret, errors.New("Not implemented yet")
} }
func copy_params(k *Kinfo_proc, p *Process) error { func copy_params(k *Kinfo_proc, p *Process) error {

@ -3,6 +3,7 @@
package gopsutil package gopsutil
import ( import (
"errors"
"io/ioutil" "io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
@ -51,7 +52,7 @@ func NewProcess(pid int32) (*Process, error) {
func (p *Process) Ppid() (int32, error) { func (p *Process) Ppid() (int32, error) {
_, ppid, _, _, _, err := p.fillFromStat() _, ppid, _, _, _, err := p.fillFromStat()
if err != nil{ if err != nil {
return -1, err return -1, err
} }
return ppid, nil return ppid, nil
@ -73,7 +74,7 @@ func (p *Process) Cwd() (string, error) {
return p.fillFromCwd() return p.fillFromCwd()
} }
func (p *Process) Parent() (*Process, error) { func (p *Process) Parent() (*Process, error) {
return nil, nil return nil, errors.New("Not implemented yet")
} }
func (p *Process) Status() (string, error) { func (p *Process) Status() (string, error) {
_, status, _, _, _, err := p.fillFromStatus() _, status, _, _, _, err := p.fillFromStatus()
@ -101,32 +102,32 @@ func (p *Process) Gids() ([]int32, error) {
} }
func (p *Process) Terminal() (string, error) { func (p *Process) Terminal() (string, error) {
terminal, _, _, _, _, err := p.fillFromStat() terminal, _, _, _, _, err := p.fillFromStat()
if err != nil{ if err != nil {
return "", err return "", err
} }
return terminal, nil return terminal, nil
} }
func (p *Process) Nice() (int32, error) { func (p *Process) Nice() (int32, error) {
_, _, _, _, nice, err := p.fillFromStat() _, _, _, _, nice, err := p.fillFromStat()
if err != nil{ if err != nil {
return 0, err return 0, err
} }
return nice, nil return nice, nil
} }
func (p *Process) Ionice() (int32, error) { func (p *Process) Ionice() (int32, error) {
return 0, nil return 0, errors.New("Not implemented yet")
} }
func (p *Process) Rlimit() ([]RlimitStat, error) { func (p *Process) Rlimit() ([]RlimitStat, error) {
return nil, nil return nil, errors.New("Not implemented yet")
} }
func (p *Process) Io_counters() (*Io_countersStat, error) { func (p *Process) Io_counters() (*Io_countersStat, error) {
return nil, nil return nil, errors.New("Not implemented yet")
} }
func (p *Process) Num_ctx_switches() (int32, error) { func (p *Process) Num_ctx_switches() (int32, error) {
return 0, nil return 0, errors.New("Not implemented yet")
} }
func (p *Process) Num_fds() (int32, error) { func (p *Process) Num_fds() (int32, error) {
return 0, nil return 0, errors.New("Not implemented yet")
} }
func (p *Process) Num_Threads() (int32, error) { func (p *Process) Num_Threads() (int32, error) {
_, _, _, _, num_threads, err := p.fillFromStatus() _, _, _, _, num_threads, err := p.fillFromStatus()
@ -141,16 +142,16 @@ func (p *Process) Threads() (map[string]string, error) {
} }
func (p *Process) Cpu_times() (*CPU_TimesStat, error) { func (p *Process) Cpu_times() (*CPU_TimesStat, error) {
_, _, cpu_times, _, _, err := p.fillFromStat() _, _, cpu_times, _, _, err := p.fillFromStat()
if err != nil{ if err != nil {
return nil, err return nil, err
} }
return cpu_times, nil return cpu_times, nil
} }
func (p *Process) Cpu_percent() (int32, error) { func (p *Process) Cpu_percent() (int32, error) {
return 0, nil return 0, errors.New("Not implemented yet")
} }
func (p *Process) Cpu_affinity() ([]int32, error) { func (p *Process) Cpu_affinity() ([]int32, error) {
return nil, nil return nil, errors.New("Not implemented yet")
} }
func (p *Process) Memory_info() (*Memory_infoStat, error) { func (p *Process) Memory_info() (*Memory_infoStat, error) {
mem_info, _, err := p.fillFromStatm() mem_info, _, err := p.fillFromStatm()
@ -167,23 +168,23 @@ func (p *Process) Memory_info_ex() (*Memory_info_exStat, error) {
return mem_info_ex, nil return mem_info_ex, nil
} }
func (p *Process) Memory_percent() (float32, error) { func (p *Process) Memory_percent() (float32, error) {
return 0, nil return 0, errors.New("Not implemented yet")
} }
func (p *Process) Children() ([]*Process, error) { func (p *Process) Children() ([]*Process, error) {
return nil, nil return nil, errors.New("Not implemented yet")
} }
func (p *Process) Open_files() ([]Open_filesStat, error) { func (p *Process) Open_files() ([]Open_filesStat, error) {
return nil, nil return nil, errors.New("Not implemented yet")
} }
func (p *Process) Connections() ([]Net_connectionStat, error) { func (p *Process) Connections() ([]Net_connectionStat, error) {
return nil, nil return nil, errors.New("Not implemented yet")
} }
func (p *Process) Is_running() (bool, error) { func (p *Process) Is_running() (bool, error) {
return true, nil return true, errors.New("Not implemented yet")
} }
// Get memory maps from /proc/(pid)/smaps // Get memory maps from /proc/(pid)/smaps

@ -60,7 +60,7 @@ func (p *Process) Ppid() (int32, error) {
} }
func (p *Process) Name() (string, error) { func (p *Process) Name() (string, error) {
name := "" name := ""
return name, nil return name, errors.New("Not implemented yet")
} }
func (p *Process) Exe() (string, error) { func (p *Process) Exe() (string, error) {
_, _, ret, err := p.getFromSnapProcess(p.Pid) _, _, ret, err := p.getFromSnapProcess(p.Pid)
@ -70,49 +70,49 @@ func (p *Process) Exe() (string, error) {
return ret, nil return ret, nil
} }
func (p *Process) Cmdline() (string, error) { func (p *Process) Cmdline() (string, error) {
return "", nil return "", errors.New("Not implemented yet")
} }
func (p *Process) Cwd() (string, error) { func (p *Process) Cwd() (string, error) {
return "", nil return "", errors.New("Not implemented yet")
} }
func (p *Process) Parent() (*Process, error) { func (p *Process) Parent() (*Process, error) {
return p, nil return p, errors.New("Not implemented yet")
} }
func (p *Process) Status() (string, error) { func (p *Process) Status() (string, error) {
return "", nil return "", errors.New("Not implemented yet")
} }
func (p *Process) Username() (string, error) { func (p *Process) Username() (string, error) {
return "", nil return "", errors.New("Not implemented yet")
} }
func (p *Process) Uids() ([]int32, error) { func (p *Process) Uids() ([]int32, error) {
uids := make([]int32, 0) uids := make([]int32, 0)
return uids, nil return uids, errors.New("Not implemented yet")
} }
func (p *Process) Gids() ([]int32, error) { func (p *Process) Gids() ([]int32, error) {
gids := make([]int32, 0) gids := make([]int32, 0)
return gids, nil return gids, errors.New("Not implemented yet")
} }
func (p *Process) Terminal() (string, error) { func (p *Process) Terminal() (string, error) {
return "", nil return "", errors.New("Not implemented yet")
} }
func (p *Process) Nice() (int32, error) { func (p *Process) Nice() (int32, error) {
return 0, nil return 0, errors.New("Not implemented yet")
} }
func (p *Process) Ionice() (int32, error) { func (p *Process) Ionice() (int32, error) {
return 0, nil return 0, errors.New("Not implemented yet")
} }
func (p *Process) Rlimit() ([]RlimitStat, error) { func (p *Process) Rlimit() ([]RlimitStat, error) {
rlimit := make([]RlimitStat, 0) rlimit := make([]RlimitStat, 0)
return rlimit, nil return rlimit, errors.New("Not implemented yet")
} }
func (p *Process) Io_counters() (*Io_countersStat, error) { func (p *Process) Io_counters() (*Io_countersStat, error) {
return nil, nil return nil, errors.New("Not implemented yet")
} }
func (p *Process) Num_ctx_switches() (int32, error) { func (p *Process) Num_ctx_switches() (int32, error) {
return 0, nil return 0, errors.New("Not implemented yet")
} }
func (p *Process) Num_fds() (int32, error) { func (p *Process) Num_fds() (int32, error) {
return 0, nil return 0, errors.New("Not implemented yet")
} }
func (p *Process) Num_Threads() (int32, error) { func (p *Process) Num_Threads() (int32, error) {
_, ret, _, err := p.getFromSnapProcess(p.Pid) _, ret, _, err := p.getFromSnapProcess(p.Pid)
@ -123,41 +123,41 @@ func (p *Process) Num_Threads() (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, nil return ret, errors.New("Not implemented yet")
} }
func (p *Process) Cpu_times() (*CPU_TimesStat, error) { func (p *Process) Cpu_times() (*CPU_TimesStat, error) {
return nil, nil return nil, errors.New("Not implemented yet")
} }
func (p *Process) Cpu_percent() (int32, error) { func (p *Process) Cpu_percent() (int32, error) {
return 0, nil return 0, errors.New("Not implemented yet")
} }
func (p *Process) Cpu_affinity() ([]int32, error) { func (p *Process) Cpu_affinity() ([]int32, error) {
return nil, nil return nil, errors.New("Not implemented yet")
} }
func (p *Process) Memory_info() (*Memory_infoStat, error) { func (p *Process) Memory_info() (*Memory_infoStat, error) {
return nil, nil return nil, errors.New("Not implemented yet")
} }
func (p *Process) Memory_info_ex() (*Memory_info_exStat, error) { func (p *Process) Memory_info_ex() (*Memory_info_exStat, error) {
return nil, nil return nil, errors.New("Not implemented yet")
} }
func (p *Process) Memory_percent() (float32, error) { func (p *Process) Memory_percent() (float32, error) {
return 0, nil return 0, errors.New("Not implemented yet")
} }
func (p *Process) Children() ([]*Process, error) { func (p *Process) Children() ([]*Process, error) {
return nil, nil return nil, errors.New("Not implemented yet")
} }
func (p *Process) Open_files() ([]Open_filesStat, error) { func (p *Process) Open_files() ([]Open_filesStat, error) {
return nil, nil return nil, errors.New("Not implemented yet")
} }
func (p *Process) Connections() ([]Net_connectionStat, error) { func (p *Process) Connections() ([]Net_connectionStat, error) {
return nil, nil return nil, errors.New("Not implemented yet")
} }
func (p *Process) Is_running() (bool, error) { func (p *Process) Is_running() (bool, error) {
return true, nil return true, errors.New("Not implemented yet")
} }
func (p *Process) Memory_Maps() (*[]Memory_mapsStat, error) { func (p *Process) Memory_Maps() (*[]Memory_mapsStat, error) {
@ -171,20 +171,20 @@ func NewProcess(pid int32) (*Process, error) {
} }
func (p *Process) Send_signal(sig syscall.Signal) error { func (p *Process) Send_signal(sig syscall.Signal) error {
return nil return errors.New("Not implemented yet")
} }
func (p *Process) Suspend() error { func (p *Process) Suspend() error {
return nil return errors.New("Not implemented yet")
} }
func (p *Process) Resume() error { func (p *Process) Resume() error {
return nil return errors.New("Not implemented yet")
} }
func (p *Process) Terminate() error { func (p *Process) Terminate() error {
return nil return errors.New("Not implemented yet")
} }
func (p *Process) Kill() error { func (p *Process) Kill() error {
return nil return errors.New("Not implemented yet")
} }
func (p *Process) getFromSnapProcess(pid int32) (int32, int32, string, error) { func (p *Process) getFromSnapProcess(pid int32) (int32, int32, string, error) {

Loading…
Cancel
Save