proc

package
v0.2.0-alpha Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2017 License: Apache-2.0 Imports: 13 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, ppid int) string

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

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(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
}

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

Jump to

Keyboard shortcuts

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