Documentation
¶
Index ¶
- Constants
- func CalculateCPUUsage(s1, s2 ProcSample, duration time.Duration) float64
- func GetCPUPriority(pid int) (int, int, error)
- func GetIOPriority(pid int) (int, int, error)
- func SetCPUPriority(pid, niceness int) error
- func SetIOPriority(pid, class, classdata int) error
- type MemInfo
- type MountInfo
- type ProcInfo
- type ProcSample
- type ProcessInfo
Constants ¶
const ( STATE_RUNNING = "R" STATE_SLEEPING = "S" STATE_DISK_WAIT = "D" STATE_ZOMBIE = "Z" STATE_STOPPED = "T" STATE_DEAD = "X" STATE_WAKEKILL = "K" STATE_WAKING = "W" STATE_PARKED = "P" )
❗ Process state flags
Variables ¶
This section is empty.
Functions ¶
func CalculateCPUUsage ¶
func CalculateCPUUsage(s1, s2 ProcSample, duration time.Duration) float64
❗ CalculateCPUUsage calculate CPU usage
func GetCPUPriority ¶
❗ GetCPUPriority returns process CPU scheduling priority (PR, NI, error)
func GetIOPriority ¶
❗ GetIOPriority returns process IO scheduling priority (class, classdata, error)
func SetCPUPriority ¶
❗ SetCPUPriority sets process CPU scheduling priority
func SetIOPriority ¶
❗ SetIOPriority sets process IO scheduling priority
Types ¶
type MemInfo ¶
type MemInfo struct { VmPeak uint64 `json:"peak"` // ❗ Peak virtual memory size VmSize uint64 `json:"size"` // ❗ Virtual memory size VmLck uint64 `json:"lck"` // ❗ Locked memory size VmPin uint64 `json:"pin"` // ❗ Pinned memory size (since Linux 3.2) VmHWM uint64 `json:"hwm"` // ❗ Peak resident set size ("high water mark") VmRSS uint64 `json:"rss"` // ❗ Resident set size VmData uint64 `json:"data"` // ❗ Size of data VmStk uint64 `json:"stk"` // ❗ Size of stack VmExe uint64 `json:"exe"` // ❗ Size of text segments VmLib uint64 `json:"lib"` // ❗ Shared library code size VmPTE uint64 `json:"pte"` // ❗ Page table entries size (since Linux 2.6.10) VmSwap uint64 `json:"swap"` // ❗ Swap size }
❗ MemInfo contains process memory usage stats
func GetMemInfo ¶
❗ GetMemInfo returns info about process memory usage
type MountInfo ¶
type MountInfo struct { MountID uint16 `json:"mount_id"` // ❗ Unique identifier of the mount (may be reused after umount) ParentID uint16 `json:"parent_id"` // ❗ ID of parent (or of self for the top of the mount tree) StDevMajor uint16 `json:"stdev_major"` // ❗ Major value of st_dev for files on filesystem StDevMinor uint16 `json:"stdev_minor"` // ❗ Minor value of st_dev for files on filesystem Root string `json:"root"` // ❗ Root of the mount within the filesystem MountPoint string `json:"mount_point"` // ❗ Mount point relative to the process's root MountOptions []string `json:"mount_options"` // ❗ Per mount options OptionalFields []string `json:"optional_fields"` // ❗ Zero or more fields of the form "tag[:value]" FSType string `json:"fs_type"` // ❗ Name of filesystem of the form "type[.subtype]" MountSource string `json:"mount_source"` // ❗ Filesystem specific information or "none" SuperOptions []string `json:"super_options"` // ❗ Per super block options }
❗ MountInfo contains information about mounts https://www.kernel.org/doc/Documentation/filesystems/proc.txt
func GetMountInfo ¶
❗ GetMountInfo returns info about process mounts
type ProcInfo ¶
type ProcInfo struct { PID int `json:"pid"` // ❗ The process ID Comm string `json:"comm"` // ❗ The filename of the executable, in parentheses State string `json:"state"` // ❗ Process state PPID int `json:"ppid"` // ❗ The PID of the parent of this process Session int `json:"session"` // ❗ The session ID of the process TTYNR int `json:"tty_nr"` // ❗ The controlling terminal of the process TPGid int `json:"tpgid"` // ❗ The ID of the foreground process group of the controlling terminal of the process UTime uint64 `json:"utime"` // ❗ Amount of time that this process has been scheduled in user mode, measured in clock ticks STime uint64 `json:"stime"` // ❗ Amount of time that this process has been scheduled in kernel mode, measured in clock ticks CUTime uint64 `json:"cutime"` // ❗ Amount of time that this process's waited-for children have been scheduled in user mode, measured in clock ticks CSTime uint64 `json:"cstime"` // ❗ Amount of time that this process's waited-for children have been scheduled in kernel mode, measured in clock ticks Priority int `json:"priority"` // ❗ Priority Nice int `json:"nice"` // ❗ The nice value NumThreads int `json:"num_threads"` // ❗ Number of threads in this process }
❗ ProcInfo contains partial info from /proc/[PID]/stat
func (*ProcInfo) ToSample ¶
func (pi *ProcInfo) ToSample() ProcSample
❗ ToSample converts ProcInfo to ProcSample for CPU usage calculation
type ProcSample ¶
type ProcSample uint
❗ ProcSample contains value for usage calculation
func GetSample ¶
func GetSample(pid int) (ProcSample, error)
❗ GetSample returns ProcSample for CPU usage calculation
type ProcessInfo ¶
type ProcessInfo struct { Command string // ❗ Full command User string // ❗ Username PID int // ❗ PID IsThread bool // ❗ True if process is thread Parent int // ❗ Parent process PID Childs []*ProcessInfo // ❗ Slice with child processes }
❗ ProcessInfo contains basic info about process
func GetList ¶
func GetList() ([]*ProcessInfo, error)
❗ GetList returns slice with all active processes on the system
func GetTree ¶
func GetTree(pid ...int) (*ProcessInfo, error)
❗ GetTree returns root process with all subprocesses on the system