proc

package
Version: v0.15.0-alpha Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2018 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BootID

func BootID() string

BootID gets the host system boot identifier

func CommandLine

func CommandLine(pid int) []string

CommandLine gets the full command-line arguments for the process indicated by the given PID.

func ContainerID

func 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 DeriveUniqueID

func DeriveUniqueID(pid int, startTime uint64) string

DeriveUniqueID returns a unique ID for thye process with the given PID and start time

func MaxPid

func MaxPid() uint

MaxPid returns the maximum PID

func ReadFile

func ReadFile(relativePath string) ([]byte, error)

ReadFile returns the contents of the procfs file indicated by the given relative path.

func UniqueID

func UniqueID(tgid, pid int) string

UniqueID returns a reproducible namespace-independent unique identifier for the process indicated by the given 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

func Cgroups

func Cgroups(pid int) ([]Cgroup, error)

Cgroups returns the cgroup membership of the process indicated by the given PID.

type FileSystem

type FileSystem struct {
	MountPoint string

	NCPU int
}

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

func (fs *FileSystem) CWD(tgid, pid int) (string, error)

CWD returns the current working directory for the specified task.

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

func (fs *FileSystem) NumCPU() (int, error)

NumCPU returns the number of CPUs on the system. This differs from runtime.NumCPU in that runtime.NumCPU returns the number of logical CPUs available to the calling process.

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(tgid, 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(tgid, 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(tgid, 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) PID

func (ps *ProcessStatus) PID() int

PID returns the PID of the process.

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.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL