process

package
v0.0.0-...-62195f8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 23, 2016 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Pids

func Pids() ([]int, error)

func StateString

func StateString(state string) string

Types

type Cmdline

type Cmdline struct {
	// contains filtered or unexported fields
}

read from /proc/[pid]/cmdline

func NewCmdline

func NewCmdline(reader io.Reader) (*Cmdline, error)

func NewCmdlineByPid

func NewCmdlineByPid(pid int) (*Cmdline, error)

func NewCommByPid

func NewCommByPid(pid int) (*Cmdline, error)

func (*Cmdline) CombinedString

func (self *Cmdline) CombinedString(kernelThread bool, short bool, dirstrip bool) string

func (*Cmdline) ShortString

func (self *Cmdline) ShortString(n int) string

func (*Cmdline) Slice

func (self *Cmdline) Slice() []string

func (*Cmdline) String

func (self *Cmdline) String() string

type Process

type Process struct {
	Pid          int
	Cmdline      *Cmdline
	Stat         *ProcessStat
	TimeStamp    time.Time
	KernelThread bool
}

func NewProcess

func NewProcess(pid int) (*Process, error)

func (*Process) Equal

func (self *Process) Equal(other *Process) bool

type ProcessList

type ProcessList []*Process

func (ProcessList) Map

func (self ProcessList) Map() ProcessMap

return process list

type ProcessMap

type ProcessMap map[int]*Process

func Processes

func Processes() (ProcessMap, error)

func (ProcessMap) List

func (self ProcessMap) List() ProcessList

return processes map

type ProcessStat

type ProcessStat struct {
	Pid                 int    //0
	Comm                string //1
	State               string //2
	PPid                int    //3
	UserTime            uint64 //13, device by sysconf(_SC_CLK_TCK)
	SystemTime          uint64 //14, device by sysconf(_SC_CLK_TCK)
	ChildUserTime       uint64 //15, device by sysconf(_SC_CLK_TCK)
	ChildSystemTime     uint64 //16, device by sysconf(_SC_CLK_TCK)
	Threads             int    //19
	StartTime           uint64 //21, device by sysconf(_SC_CLK_TCK)
	VmSize              uint64 //22
	VmRSS               uint64 //23
	DelayAcctBlkioTicks uint64 //41, delayacct_blkio_ticks, device by sysconf(_SC_CLK_TCK)
}

read from /proc/[pid]/stat

func NewProcessStat

func NewProcessStat(reader io.Reader) (*ProcessStat, error)

func NewProcessStatByPid

func NewProcessStatByPid(pid int) (*ProcessStat, error)

func (*ProcessStat) Equal

func (self *ProcessStat) Equal(other *ProcessStat) bool

func (*ProcessStat) StateString

func (self *ProcessStat) StateString() string

func (*ProcessStat) TotalCputime

func (self *ProcessStat) TotalCputime() uint64

type ProcessTable

type ProcessTable struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewProcessTable

func NewProcessTable() (*ProcessTable, error)

func (*ProcessTable) Add

func (self *ProcessTable) Add(pid int) error

func (*ProcessTable) Clone

func (self *ProcessTable) Clone() (*ProcessTable, error)

func (*ProcessTable) Delete

func (self *ProcessTable) Delete(pid int)

func (*ProcessTable) Get

func (self *ProcessTable) Get(pid int) (*Process, error)

func (*ProcessTable) GetOrDefault

func (self *ProcessTable) GetOrDefault(pid int) *Process

func (*ProcessTable) Sync

func (self *ProcessTable) Sync() error

Load All process from /proc/*

func (*ProcessTable) Update

func (self *ProcessTable) Update(pid int) error

동일한 프로세스가 이미 존재할 경우에만 update 를 수행한다.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL