status

package
v2.2.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2019 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Those are common process statuses, defined as reference
	Sleeping = "sleeping"
	Running  = "running"
	Idle     = "idle"
	Zombie   = "zombie" // If child process is terminated with parent still running. Needs to be cleaned up.

	// Plugin-defined process statuses (as addition to other process statuses)
	Initial     = "initial"     // Only for newly created/attached processes
	Unavailable = "unavailable" // If process status cannot be obtained
	Terminated  = "terminated"  // If process is not running (while tested by zero signal)
)

Plugin states which require special handling

Variables

This section is empty.

Functions

This section is empty.

Types

type File

type File struct {
	Name                     string        // Name of the executable
	UMask                    int           // Mode creation mask
	State                    ProcessStatus // State (running, sleeping, uninterruptible wait, zombie, etc...)
	LState                   string        // Proces state label (single letter)
	Tgid                     int           // Thread group ID
	Ngid                     int           // NUMA group ID
	Pid                      int           // Process id
	PPid                     int           // Process id of the parent process
	TracerPid                int           // PID of process tracing this process
	UID                      *GUID         // Set of UIDs
	GID                      *GUID         // Set of GIDs
	FDSize                   int           // Number of file descriptor slots currently allocated
	Groups                   []int         // Supplementary group list
	NStgid                   int           // Descendant namespace thread group ID hierarchy
	NSpid                    int           // Descendant namespace process ID hierarchy
	NSpgid                   int           // Descendant namespace process group ID hierarchy
	NSsid                    int           // Descendant namespace session ID hierarchy
	VMPeak                   string        // Peak virtual memory size
	VMSize                   string        // Total program size
	VMLck                    string        // Locked memory size
	VMPin                    string        // Pinned memory size
	VMHWM                    string        // Peak resident set size
	VMRSS                    string        // Size of memory portions (RssAnon + RssFile + RssShmem)
	RssAnon                  string        // Size of resident anonymous memory
	RssFile                  string        // Size of resident file mappings
	RssShmem                 string        // Size of resident shmem memory
	VMData                   string        // Size of private data segments
	VMStk                    string        // Size of stack segments
	VMExe                    string        // Size of text segment
	VMLib                    string        // Size of shared library code
	VMPTE                    string        // Size of page table entries
	VMSwap                   string        // Amount of swap used by anonymous private data
	HugetlbPages             string        // Size of hugetlb memory portions
	CoreDumping              int           // Process's memory is currently being dumped
	Threads                  int           // Number of threads
	SigQueued                int           // Number of signals queued/
	SigMax                   int           // Max. number for queue
	SigPnd                   []byte        // Bitmap of pending signals for the thread
	ShdPnd                   []byte        // Bitmap of shared pending signals for the process
	SigBlk                   []byte        // Bitmap of blocked signals
	SigIgn                   []byte        // Bitmap of ignored signals
	SigCgt                   []byte        // Bitmap of caught signals
	CapInh                   []byte        // Bitmap of inheritable capabilities
	CapPrm                   []byte        // Bitmap of permitted capabilities
	CapEff                   []byte        // Bitmap of effective capabilities
	CapBnd                   []byte        // Bitmap of capabilities bounding set
	Seccomp                  int           // Seccomp mode
	CpusAllowed              string        // Mask of CPUs on which this process may run
	MemsAllowedList          int           // Mask of memory nodes allowed to this process
	VoluntaryCtxtSwitches    int           // Number of voluntary context switches
	NonvoluntaryCtxtSwitches int           // Number of non voluntary context switches
}

File mirrors process status file

type GUID

type GUID struct {
	Real       int
	Effective  int
	SavedSet   int
	FileSystem int
}

GUID helper struct for process UID and GID

type ProcessStatus

type ProcessStatus string

ProcessStatus is string representation of process status

type Reader

type Reader struct {
	sync.Mutex
	Log logging.Logger
}

Reader provides safe process status manipulation

func (*Reader) ReadStatusFromFile

func (r *Reader) ReadStatusFromFile(file *os.File) *File

ReadStatusFromFile allows to eventually read status from custom location and parse it directly

func (*Reader) ReadStatusFromPID

func (r *Reader) ReadStatusFromPID(pid int) (*File, error)

ReadStatusFromPID returns status file object. Data are read from /proc and process ID of existing process is required. Error is returned if file (process) does not exist

Jump to

Keyboard shortcuts

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