process

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2022 License: BSD-3-Clause Imports: 21 Imported by: 26

Documentation

Index

Constants

View Source
const (
	CTLKern          = 1  // "high kernel": proc, limits
	KernProc         = 14 // struct: process entries
	KernProcPID      = 1  // by process id
	KernProcProc     = 8  // only return procs
	KernProcAll      = 0  // everything
	KernProcPathname = 12 // path to executable
)

copied from sys/sysctl.h

View Source
const (
	ClockTicks = 100 // C.sysconf(C._SC_CLK_TCK)
)

Variables

This section is empty.

Functions

func AllProcesses

func AllProcesses() (map[int32]*FilledProcess, error)

func PidExists

func PidExists(pid int32) (bool, error)

func Pids

func Pids() ([]int32, error)

Types

type AuMask

type AuMask struct {
	Success uint32
	Failure uint32
}

type AuTidAddr

type AuTidAddr struct {
	Port int32
	Type uint32
	Addr [4]uint32
}

type Au_session

type Au_session struct {
	Aia_p *AuditinfoAddr
	Mask  AuMask
}

type AuditinfoAddr

type AuditinfoAddr struct {
	Auid   uint32
	Mask   AuMask
	Termid AuTidAddr
	Asid   int32
	Flags  uint64
}

type Eproc

type Eproc struct {
	Paddr     *uint64
	Sess      *Session
	Pcred     Upcred
	Ucred     Uucred
	Pad_cgo_0 [4]byte
	Vm        Vmspace
	Ppid      int32
	Pgid      int32
	Jobc      int16
	Pad_cgo_1 [2]byte
	Tdev      int32
	Tpgid     int32
	Pad_cgo_2 [4]byte
	Tsess     *Session
	Wmesg     [8]int8
	Xsize     int32
	Xrssize   int16
	Xccount   int16
	Xswrss    int16
	Pad_cgo_3 [2]byte
	Flag      int32
	Login     [12]int8
	Spare     [4]int32
	Pad_cgo_4 [4]byte
}

type ExternProc

type ExternProc struct {
	P_un        [16]byte
	P_vmspace   uint64
	P_sigacts   uint64
	Pad_cgo_0   [3]byte
	P_flag      int32
	P_stat      int8
	P_pid       int32
	P_oppid     int32
	P_dupfd     int32
	Pad_cgo_1   [4]byte
	User_stack  uint64
	Exit_thread uint64
	P_debugger  int32
	Sigwait     int32
	P_estcpu    uint32
	P_cpticks   int32
	P_pctcpu    uint32
	Pad_cgo_2   [4]byte
	P_wchan     uint64
	P_wmesg     uint64
	P_swtime    uint32
	P_slptime   uint32
	P_realtimer Itimerval
	P_rtime     Timeval
	P_uticks    uint64
	P_sticks    uint64
	P_iticks    uint64
	P_traceflag int32
	Pad_cgo_3   [4]byte
	P_tracep    uint64
	P_siglist   int32
	Pad_cgo_4   [4]byte
	P_textvp    uint64
	P_holdcnt   int32
	P_sigmask   uint32
	P_sigignore uint32
	P_sigcatch  uint32
	P_priority  uint8
	P_usrpri    uint8
	P_nice      int8
	P_comm      [17]int8
	Pad_cgo_5   [4]byte
	P_pgrp      uint64
	P_addr      uint64
	P_xstat     uint16
	P_acflag    uint16
	Pad_cgo_6   [4]byte
	P_ru        uint64
}

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 Itimerval

type Itimerval struct {
	Interval Timeval
	Value    Timeval
}

type KinfoProc

type KinfoProc struct {
	Proc  ExternProc
	Eproc Eproc
}

type Label

type Label struct{}

type MemoryInfoExStat

type MemoryInfoExStat struct {
	RSS    uint64 `json:"rss"`    // bytes
	VMS    uint64 `json:"vms"`    // bytes
	Shared uint64 `json:"shared"` // 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 MemoryMapsStat

type MemoryMapsStat struct {
}

type NumCtxSwitchesStat

type NumCtxSwitchesStat struct {
	Voluntary   int64 `json:"voluntary"`
	Involuntary int64 `json:"involuntary"`
}

func (NumCtxSwitchesStat) String

func (p NumCtxSwitchesStat) String() string

type OpenFilesStat

type OpenFilesStat struct {
	Path string `json:"path"`
	Fd   uint64 `json:"fd"`
}

func (OpenFilesStat) String

func (o OpenFilesStat) String() string

type Pgrp

type Pgrp struct{}

type Posix_cred

type Posix_cred struct {
	UID       uint32
	Ruid      uint32
	Svuid     uint32
	Ngroups   int16
	Pad_cgo_0 [2]byte
	Groups    [16]uint32
	Rgid      uint32
	Svgid     uint32
	Gmuid     uint32
	Flags     int32
}

type Proc

type Proc struct{}

type Process

type Process struct {
	Pid   int32 `json:"pid"`
	NsPid int32 `json:"nspid"`
	// contains filtered or unexported fields
}

func NewProcess

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

func (*Process) CPUAffinity

func (p *Process) CPUAffinity() ([]int32, error)

func (*Process) Children

func (p *Process) Children() ([]*Process, error)

func (*Process) Cmdline

func (p *Process) Cmdline() (string, error)

Cmdline returns the command line arguments of the process as a string with each argument separated by 0x20 ascii character.

func (*Process) CmdlineSlice

func (p *Process) CmdlineSlice() ([]string, error)

CmdlineSlice returns the command line arguments of the process as a slice with each element being an argument. Because of current deficiencies in the way that the command line arguments are found, single arguments that have spaces in the will actually be reported as two separate items. In order to do something better CGO would be needed to use the native darwin functions.

func (*Process) Connections

func (p *Process) Connections() ([]net.ConnectionStat, error)

func (*Process) CreateTime

func (p *Process) CreateTime() (int64, error)

func (*Process) Cwd

func (p *Process) Cwd() (string, error)

func (*Process) Exe

func (p *Process) Exe() (string, error)

func (*Process) Gids

func (p *Process) Gids() ([]int32, error)

func (*Process) IOCounters

func (p *Process) IOCounters() (*IOCountersStat, error)

func (*Process) IOnice

func (p *Process) IOnice() (int32, error)

func (*Process) IsRunning

func (p *Process) IsRunning() (bool, error)

func (*Process) Kill

func (p *Process) Kill() error

Kill sends SIGKILL to the process.

func (*Process) MemoryInfo

func (p *Process) MemoryInfo() (*MemoryInfoStat, error)

func (*Process) MemoryInfoEx

func (p *Process) MemoryInfoEx() (*MemoryInfoExStat, error)

func (*Process) MemoryMaps

func (p *Process) MemoryMaps(grouped bool) (*[]MemoryMapsStat, error)

func (*Process) MemoryPercent

func (p *Process) MemoryPercent() (float32, error)

MemoryPercent returns how many percent of the total RAM this process uses

func (*Process) Name

func (p *Process) Name() (string, error)

func (*Process) NetIOCounters

func (p *Process) NetIOCounters(pernic bool) ([]net.IOCountersStat, error)

func (*Process) Nice

func (p *Process) Nice() (int32, error)

func (*Process) NumCtxSwitches

func (p *Process) NumCtxSwitches() (*NumCtxSwitchesStat, error)

func (*Process) NumFDs

func (p *Process) NumFDs() (int32, error)

func (*Process) NumThreads

func (p *Process) NumThreads() (int32, error)

func (*Process) OpenFiles

func (p *Process) OpenFiles() ([]OpenFilesStat, error)

func (*Process) Parent

func (p *Process) Parent() (*Process, error)

func (*Process) Percent

func (p *Process) Percent(interval time.Duration) (float64, error)

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) Ppid

func (p *Process) Ppid() (int32, error)

func (*Process) Resume

func (p *Process) Resume() error

Resume sends SIGCONT to the process.

func (*Process) Rlimit

func (p *Process) Rlimit() ([]RlimitStat, error)

func (*Process) SendSignal

func (p *Process) SendSignal(sig syscall.Signal) error

SendSignal sends a syscall.Signal to the process. Currently, SIGSTOP, SIGCONT, SIGTERM and SIGKILL are supported.

func (*Process) Status

func (p *Process) Status() (string, error)

func (Process) String

func (p Process) String() string

func (*Process) Suspend

func (p *Process) Suspend() error

Suspend sends SIGSTOP to the process.

func (*Process) Terminal

func (p *Process) Terminal() (string, error)

func (*Process) Terminate

func (p *Process) Terminate() error

Terminate sends SIGTERM to the process.

func (*Process) Threads

func (p *Process) Threads() (map[string]string, error)

func (*Process) Times

func (p *Process) Times() (*cpu.TimesStat, error)

func (*Process) Uids

func (p *Process) Uids() ([]int32, error)

func (*Process) Username

func (p *Process) Username() (string, error)

Username returns a username of the process.

type Rlimit

type Rlimit struct {
	Cur uint64
	Max uint64
}

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

type Rusage

type Rusage struct {
	Utime    Timeval
	Stime    Timeval
	Maxrss   int64
	Ixrss    int64
	Idrss    int64
	Isrss    int64
	Minflt   int64
	Majflt   int64
	Nswap    int64
	Inblock  int64
	Oublock  int64
	Msgsnd   int64
	Msgrcv   int64
	Nsignals int64
	Nvcsw    int64
	Nivcsw   int64
}

type Session

type Session struct{}

type Sigacts

type Sigacts struct{}

type Timespec

type Timespec struct {
	Sec  int64
	Nsec int64
}

type Timeval

type Timeval struct {
	Sec       int64
	Usec      int32
	Pad_cgo_0 [4]byte
}

type UGid_t

type UGid_t uint32

type UcredQueue

type UcredQueue struct {
	Next *ucred
	Prev **ucred
}

type Upcred

type Upcred struct {
	Pc_lock   [72]int8
	Pc_ucred  *ucred
	P_ruid    uint32
	P_svuid   uint32
	P_rgid    uint32
	P_svgid   uint32
	P_refcnt  int32
	Pad_cgo_0 [4]byte
}

type UserStruct

type UserStruct struct{}

type Uucred

type Uucred struct {
	Ref       int32
	UID       uint32
	Ngroups   int16
	Pad_cgo_0 [2]byte
	Groups    [16]uint32
}

type Vmspace

type Vmspace struct {
	Dummy     int32
	Pad_cgo_0 [4]byte
	Dummy2    *int8
	Dummy3    [5]int32
	Pad_cgo_1 [4]byte
	Dummy4    [3]*int8
}

type Vnode

type Vnode struct{}

Directories

Path Synopsis
so

Jump to

Keyboard shortcuts

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