Documentation ¶
Index ¶
- Constants
- Variables
- func AllProcesses() (map[int32]*FilledProcess, error)
- func PidExists(pid int32) (bool, error)
- func Pids() ([]int32, error)
- type FilledProcess
- type IOCountersStat
- type MemoryInfoExStat
- type MemoryInfoStat
- type MemoryMapSectionHeader
- type MemoryMapSectionPermissions
- type MemoryMapsStat
- type NumCtxSwitchesStat
- type OpenFilesStat
- type Process
- func (p *Process) CPUAffinity() ([]int32, error)
- func (p *Process) Children() ([]*Process, error)
- func (p *Process) Cmdline() (string, error)
- func (p *Process) CmdlineSlice() ([]string, error)
- func (p *Process) Connections() ([]net.ConnectionStat, error)
- func (p *Process) CreateTime() (int64, error)
- func (p *Process) Cwd() (string, error)
- func (p *Process) Exe() (string, error)
- func (p *Process) Gids() ([]int32, error)
- func (p *Process) IOCounters() (*IOCountersStat, error)
- func (p *Process) IOnice() (int32, error)
- func (p *Process) IsRunning() (bool, error)
- func (p *Process) Kill() error
- func (p *Process) MemoryInfo() (*MemoryInfoStat, error)
- func (p *Process) MemoryInfoEx() (*MemoryInfoExStat, error)
- func (p *Process) MemoryMaps(grouped bool) (*[]MemoryMapsStat, error)
- func (p *Process) MemoryPercent() (float32, error)
- func (p *Process) Name() (string, error)
- func (p *Process) NetIOCounters(pernic bool) ([]net.IOCountersStat, error)
- func (p *Process) Nice() (int32, error)
- func (p *Process) NumCtxSwitches() (*NumCtxSwitchesStat, error)
- func (p *Process) NumFDs() (int32, error)
- func (p *Process) NumThreads() (int32, error)
- func (p *Process) OpenFiles() ([]OpenFilesStat, error)
- func (p *Process) Parent() (*Process, error)
- func (p *Process) Percent(interval time.Duration) (float64, error)
- func (p *Process) Ppid() (int32, error)
- func (p *Process) Resume() error
- func (p *Process) Rlimit() ([]RlimitStat, error)
- func (p *Process) SendSignal(sig syscall.Signal) error
- func (p *Process) Status() (string, error)
- func (p Process) String() string
- func (p *Process) Suspend() error
- func (p *Process) Terminal() (string, error)
- func (p *Process) Terminate() error
- func (p *Process) Threads() (map[string]string, error)
- func (p *Process) Times() (*cpu.TimesStat, error)
- func (p *Process) Uids() ([]int32, error)
- func (p *Process) Username() (string, error)
- type RlimitStat
Constants ¶
const ( PrioProcess = 0 // linux/resource.h ClockTicks = 100 // C.sysconf(C._SC_CLK_TCK) WorldReadable os.FileMode = 4 )
Variables ¶
var ( CachedBootTime = uint64(0) ErrorNoChildren = errors.New("process does not have children") PageSize = uint64(os.Getpagesize()) )
Functions ¶
func AllProcesses ¶
func AllProcesses() (map[int32]*FilledProcess, error)
Types ¶
type FilledProcess ¶
type FilledProcess struct { Pid int32 Ppid int32 // process namespaced PID NsPid int32 Cmdline []string // stat CpuTime cpu.TimesStat Nice int32 CreateTime int64 OpenFdCount int32 // status Name string Status string Uids []int32 Gids []int32 NumThreads int32 CtxSwitches *NumCtxSwitchesStat // statm MemInfo *MemoryInfoStat MemInfoEx *MemoryInfoExStat // cwd Cwd string // exe Exe string // IO IOStat *IOCountersStat // Username (windows only) Username string }
type IOCountersStat ¶
type IOCountersStat struct { ReadCount uint64 `json:"readCount"` WriteCount uint64 `json:"writeCount"` ReadBytes uint64 `json:"readBytes"` WriteBytes uint64 `json:"writeBytes"` }
func (IOCountersStat) String ¶
func (i IOCountersStat) String() string
type MemoryInfoExStat ¶
type MemoryInfoExStat struct { RSS uint64 `json:"rss"` // bytes VMS uint64 `json:"vms"` // bytes Text uint64 `json:"text"` // bytes Lib uint64 `json:"lib"` // bytes Data uint64 `json:"data"` // bytes Dirty uint64 `json:"dirty"` // bytes }
MemoryInfoExStat is different between OSes
type MemoryInfoStat ¶
type MemoryInfoStat struct { RSS uint64 `json:"rss"` // bytes VMS uint64 `json:"vms"` // bytes Swap uint64 `json:"swap"` // bytes }
func (MemoryInfoStat) String ¶
func (m MemoryInfoStat) String() string
type MemoryMapSectionHeader ¶
type MemoryMapsStat ¶
type MemoryMapsStat struct { MemoryMapSectionHeader Path string `json:"path"` Rss uint64 `json:"rss"` Size uint64 `json:"size"` Pss uint64 `json:"pss"` PrivateClean uint64 `json:"privateClean"` PrivateDirty uint64 `json:"privateDirty"` Referenced uint64 `json:"referenced"` Anonymous uint64 `json:"anonymous"` Swap uint64 `json:"swap"` }
func (*MemoryMapsStat) IsAnonymous ¶
func (ms *MemoryMapsStat) IsAnonymous() bool
func (MemoryMapsStat) String ¶
func (m MemoryMapsStat) String() string
String returns JSON value of the process.
type NumCtxSwitchesStat ¶
type NumCtxSwitchesStat struct { Voluntary int64 `json:"voluntary"` Involuntary int64 `json:"involuntary"` }
func (NumCtxSwitchesStat) String ¶
func (p NumCtxSwitchesStat) String() string
type OpenFilesStat ¶
func (OpenFilesStat) String ¶
func (o OpenFilesStat) String() string
type Process ¶
type Process struct { Pid int32 `json:"pid"` NsPid int32 `json:"nspid"` // contains filtered or unexported fields }
func NewProcess ¶
NewProcess creates a new Process instance, it only stores the pid and checks that the process exists. Other method on Process can be used to get more information about the process. An error will be returned if the process does not exist.
func (*Process) CPUAffinity ¶
CPUAffinity returns CPU affinity of the process.
Notice: Not implemented yet.
func (*Process) Cmdline ¶
Cmdline returns the command line arguments of the process as a string with each argument separated by 0x20 ascii character.
func (*Process) CmdlineSlice ¶
CmdlineSlice returns the command line arguments of the process as a slice with each element being an argument.
func (*Process) Connections ¶
func (p *Process) Connections() ([]net.ConnectionStat, error)
Connections returns a slice of net.ConnectionStat used by the process. This returns all kind of the connection. This measn TCP, UDP or UNIX.
func (*Process) CreateTime ¶
CreateTime returns created time of the process in seconds since the epoch, in UTC.
func (*Process) IOCounters ¶
func (p *Process) IOCounters() (*IOCountersStat, error)
IOCounters returns IO Counters.
func (*Process) IsRunning ¶
IsRunning returns whether the process is running or not. Not implemented yet.
func (*Process) MemoryInfo ¶
func (p *Process) MemoryInfo() (*MemoryInfoStat, error)
MemoryInfo returns platform in-dependend memory information, such as RSS, VMS and Swap
func (*Process) MemoryInfoEx ¶
func (p *Process) MemoryInfoEx() (*MemoryInfoExStat, error)
MemoryInfoEx returns platform dependend memory information.
func (*Process) MemoryMaps ¶
func (p *Process) MemoryMaps(grouped bool) (*[]MemoryMapsStat, error)
MemoryMaps get memory maps from /proc/(pid)/smaps
func (*Process) MemoryPercent ¶
MemoryPercent returns how many percent of the total RAM this process uses
func (*Process) NetIOCounters ¶
func (p *Process) NetIOCounters(pernic bool) ([]net.IOCountersStat, error)
NetIOCounters returns NetIOCounters of the process.
func (*Process) Nice ¶
Nice returns a nice value (priority). Notice: gopsutil can not set nice value.
func (*Process) NumCtxSwitches ¶
func (p *Process) NumCtxSwitches() (*NumCtxSwitchesStat, error)
NumCtxSwitches returns the number of the context switches of the process.
func (*Process) NumThreads ¶
NumThreads returns the number of threads used by the process.
func (*Process) OpenFiles ¶
func (p *Process) OpenFiles() ([]OpenFilesStat, error)
OpenFiles returns a slice of OpenFilesStat opend by the process. OpenFilesStat includes a file path and file descriptor.
func (*Process) Percent ¶
If interval is 0, return difference from last call(non-blocking). If interval > 0, wait interval sec and return diffrence between start and end.
func (*Process) Rlimit ¶
func (p *Process) Rlimit() ([]RlimitStat, error)
Rlimit returns Resource Limits.
func (*Process) SendSignal ¶
SendSignal sends a syscall.Signal to the process. Currently, SIGSTOP, SIGCONT, SIGTERM and SIGKILL are supported.
func (*Process) Status ¶
Status returns the process status. Return value could be one of these. R: Running S: Sleep T: Stop I: Idle Z: Zombie W: Wait L: Lock The charactor is same within all supported platforms.
func (*Process) Threads ¶
Threads returns a map of threads
Notice: Not implemented yet. always returns empty map.
type RlimitStat ¶
type RlimitStat struct { Resource int32 `json:"resource"` Soft int32 `json:"soft"` Hard int32 `json:"hard"` }
func (RlimitStat) String ¶
func (r RlimitStat) String() string