proc

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAllBinaryProcs

func GetAllBinaryProcs() (map[string][]uint32, error)

GetProcNS returns the namespace ID of a given namespace and process. To do so, it requires access to the /proc file system of the host, and CAP_SYS_PTRACE capability.

func GetMountNSFirstProcesses

func GetMountNSFirstProcesses() (map[int]int, error)

GetMountNSFirstProcesses return mapping between mount NS to its first process (aka, the process with the oldest start time in the mount NS)

func GetProcBinary

func GetProcBinary(pid uint) (string, error)

GetProcNS returns the namespace ID of a given namespace and process. To do so, it requires access to the /proc file system of the host, and CAP_SYS_PTRACE capability.

func GetProcNS

func GetProcNS(pid uint, nsName string) (int, error)

GetProcNS returns the namespace ID of a given namespace and process. To do so, it requires access to the /proc file system of the host, and CAP_SYS_PTRACE capability.

func GetProcessStartTime

func GetProcessStartTime(pid uint) (int, error)

GetProcessStartTime return the start time of the process using the procfs

Types

type ProcNS

type ProcNS struct {
	Cgroup          int
	Ipc             int
	Mnt             int
	Net             int
	Pid             int
	PidForChildren  int
	Time            int
	TimeForChildren int
	User            int
	Uts             int
}

func GetAllProcNS

func GetAllProcNS(pid uint) (*ProcNS, error)

GetAllProcNS return all the namespaces of a given process. To do so, it requires access to the /proc file system of the host, and CAP_SYS_PTRACE capability.

type ProcStat

type ProcStat struct {
	Pid                 int    // process id
	Comm                string // the filename of the executable
	State               byte   // process state
	Ppid                int    // parent process id
	Pgrp                int    // process group id
	Session             int    // session id
	TtyNr               int    // controlling terminal
	Tpgid               int    // foreground process group id of the controlling terminal
	Flags               uint   // process flags
	MinFlt              uint64 // number of minor faults
	CminFlt             uint64 // number of minor faults (all childs)
	MajFlt              uint64 // number of major faults
	CmajFlt             uint64 // number of major faults (all childs)
	Utime               int64  // user mode jiffies (clock ticks)
	Stime               int64  // kernel mode jiffies (clock ticks)
	Cutime              int64  // user mode jiffies (all childs)
	Cstime              int64  // kernel mode jiffies (all childs)
	Priority            int    // process priority
	Nice                int    // process nice value
	NumThreads          int    // number of threads in this process
	ItRealValue         int64  // (obsolete, always 0)
	StartTime           int64  // time the process started after system boot (in clock ticks)
	Vsize               int64  // virtual memory size
	Rss                 int64  // resident set memory size
	Rsslim              uint64 // current limit in bytes on the rss
	Startcode           int64  // address above which program text can run
	Endcode             int64  // address below which program text can run
	StartStack          int64  // address of the start of the main process stack
	Kstkesp             int64  // current value of stack pointer
	Kstkeip             int64  // current value of instruction pointer
	Signal              uint64 // bitmap of pending signals
	Blocked             uint64 // bitmap of blocked signals
	SigIgnore           uint64 // bitmap of ignored signals
	Sigcatch            uint64 // bitmap of catched signals
	Wchan               int64  // address of the syscall where process is in sleep mode
	Nswap               int64  // number of swapped pages
	Cnswap              int64  // cumulative nswap for child processes
	ExitSignal          int    // signal to be sent to parent when we die
	Processor           int    // current CPU
	RtPriority          int    // realtime priority
	Policy              int    // scheduling policy
	DelayacctBlkioTicks int64  // time spent waiting for block IO
	GuestTime           int64  // guest time of the process
	CguestTime          int64  // guest time of the process's children
	StartData           int64  // address above which program data+bss is placed
	EndData             int64  // address below which program data+bss is placed
	StartBrk            int64  // address above which program heap can be expanded with brk()
	ArgStart            int64  // address above which program command line is placed
	ArgEnd              int64  // address below which program command line is placed
	EnvStart            int64  // address above which program environment is placed
	EnvEnd              int64  // address below which program environment is placed
	ExitCode            int    // the thread's exit_code in the form reported by the waitpid system call
}

func NewProcStat

func NewProcStat(pid int) (*ProcStat, error)

func NewThreadProcStat

func NewThreadProcStat(pid, tid int) (*ProcStat, error)

type ProcStatus

type ProcStatus map[string]string

func NewProcStatus

func NewProcStatus(pid int) (*ProcStatus, error)

func NewThreadProcStatus

func NewThreadProcStatus(pid, tid int) (*ProcStatus, error)

func (ProcStatus) GetGid

func (ps ProcStatus) GetGid() [4]int

GetGid returns GID in the following order: real, effective, saved set, filesystem.

func (ProcStatus) GetName

func (ps ProcStatus) GetName() string

GetName returns name of the process.

func (ProcStatus) GetNsPPid

func (ps ProcStatus) GetNsPPid() int

GetNsPPid returns parent process ID in the namespace of the process.

func (ProcStatus) GetNsPid

func (ps ProcStatus) GetNsPid() int

GetNsPid returns process ID in the namespace of the process.

func (ProcStatus) GetNsTgid

func (ps ProcStatus) GetNsTgid() int

GetNsTgid returns thread group ID in the namespace of the process.

func (ProcStatus) GetPPid

func (ps ProcStatus) GetPPid() int

GetPPid returns parent process ID.

func (ProcStatus) GetPid

func (ps ProcStatus) GetPid() int

GetPid returns process ID.

func (ProcStatus) GetState

func (ps ProcStatus) GetState() string

GetState returns state of the process.

func (ProcStatus) GetTgid

func (ps ProcStatus) GetTgid() int

GetTgid returns thread group ID.

func (ProcStatus) GetThreads

func (ps ProcStatus) GetThreads() int

GetThreads returns number of threads in process.

func (ProcStatus) GetUid

func (ps ProcStatus) GetUid() [4]int

GetUid returns UID in the following order: real, effective, saved set, filesystem.

Jump to

Keyboard shortcuts

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