Documentation ¶
Index ¶
- func BootID() string
- func CommandLine(pid int) []string
- func ContainerID(pid int) (string, error)
- func DeriveUniqueID(pid, ppid int) string
- func MaxPid() uint
- func ReadFile(relativePath string) ([]byte, error)
- func UniqueID(pid int) string
- type Cgroup
- type FileSystem
- func (fs *FileSystem) Cgroups(pid int) ([]Cgroup, error)
- func (fs *FileSystem) CommandLine(pid int) []string
- func (fs *FileSystem) ContainerID(pid int) (string, error)
- func (fs *FileSystem) Open(relativePath string) (*os.File, error)
- func (fs *FileSystem) ReadFile(relativePath string) ([]byte, error)
- func (fs *FileSystem) ReadProcessStatus(tgid, pid int, i interface{}) error
- func (fs *FileSystem) Stat(pid int) *ProcessStatus
- func (fs *FileSystem) UniqueID(pid int) string
- type ProcessStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CommandLine ¶
CommandLine gets the full command-line arguments for the process indicated by the given PID.
func ContainerID ¶
ContainerID returns the container ID running the process indicated by the given PID. Returns the empty string if the process is not running within a container. Returns a non-nil error if the process indicated by the given PID wasn't found.
func DeriveUniqueID ¶
DeriveUniqueID returns a unique ID for thye process with the given PID and parent PID
Types ¶
type Cgroup ¶
type Cgroup struct { // Unique hierarchy ID ID int // Cgroup controllers (subsystems) bound to the hierarchy Controllers []string // Path is the pathname of the control group to which the process // belongs. It is relative to the mountpoint of the hierarchy. Path string }
Cgroup describes the cgroup membership of a process
type FileSystem ¶
type FileSystem struct {
MountPoint string
}
FileSystem represents data accessible through the proc pseudo-filesystem.
func FS ¶
func FS() *FileSystem
FS creates a FileSystem instance representing the default procfs mountpoint /proc. When running inside a container, this will contain information from the container's pid namespace.
func (*FileSystem) Cgroups ¶
func (fs *FileSystem) Cgroups(pid int) ([]Cgroup, error)
Cgroups returns the cgroup membership of the process indicated by the given PID.
func (*FileSystem) CommandLine ¶
func (fs *FileSystem) CommandLine(pid int) []string
CommandLine gets the full command-line arguments for the process indicated by the given PID.
func (*FileSystem) ContainerID ¶
func (fs *FileSystem) ContainerID(pid int) (string, error)
ContainerID returns the container ID running the process indicated by the given PID. Returns the empty string if the process is not running within a container. Returns a non-nil error if the process indicated by the given PID wasn't found.
func (*FileSystem) Open ¶
func (fs *FileSystem) Open(relativePath string) (*os.File, error)
Open opens the procfs file indicated by the given relative path.
func (*FileSystem) ReadFile ¶
func (fs *FileSystem) ReadFile(relativePath string) ([]byte, error)
ReadFile returns the contents of the procfs file indicated by the given relative path.
func (*FileSystem) ReadProcessStatus ¶
func (fs *FileSystem) ReadProcessStatus(tgid, pid int, i interface{}) error
ReadProcessStatus reads the status of a process from the proc filesystem, parsing each field and storing it in the supplied struct.
func (*FileSystem) Stat ¶
func (fs *FileSystem) Stat(pid int) *ProcessStatus
Stat reads the given process's status from the ProcFS receiver and returns a ProcessStatus with methods to parse and return information from that status as needed.
func (*FileSystem) UniqueID ¶
func (fs *FileSystem) UniqueID(pid int) string
UniqueID returns a reproducible namespace-independent unique identifier for the process indicated by the given PID.
type ProcessStatus ¶
type ProcessStatus struct {
// contains filtered or unexported fields
}
ProcessStatus represents process status available via /proc/[pid]/stat
func Stat ¶
func Stat(pid int) *ProcessStatus
Stat reads the given process's status and returns a ProcessStatus with methods to parse and return information from that status as needed.
func (*ProcessStatus) Command ¶
func (ps *ProcessStatus) Command() string
Command returns the command name associated with the process (this is typically referred to as the comm value in Linux kernel interfaces).
func (*ProcessStatus) ParentPID ¶
func (ps *ProcessStatus) ParentPID() int
ParentPID returns the PID of the parent of the process.
func (*ProcessStatus) StartStack ¶
func (ps *ProcessStatus) StartStack() uint64
StartStack returns the address of the start (i.e., bottom) of the stack.
func (*ProcessStatus) StartTime ¶
func (ps *ProcessStatus) StartTime() uint64
StartTime returns the time in jiffies (< 2.6) or clock ticks (>= 2.6) after system boot when the process started.
func (*ProcessStatus) UniqueID ¶
func (ps *ProcessStatus) UniqueID() string
UniqueID returns a reproducible unique identifier for the process indicated by the given PID.