process

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2021 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

build +linux

Index

Constants

View Source
const (
	IOPRIO_CLASS_NONE = iota
	IOPRIO_CLASS_RT
	IOPRIO_CLASS_BE
	IOPRIO_CLASS_IDLE
)
View Source
const (
	IOPRIO_WHO_PROCESS
	IOPRIO_WHO_PGRP
	IOPRIO_WHO_USER
)
View Source
const (
	NONE = iota
	REALTIME
	BEST_EFFORT
	IDLE
)
View Source
const (
	SCHED_OTHER = iota
	SCHED_FIFO
	SCHED_RR
	SCHED_BATCH
	SCHED_ISO
	SCHED_IDLE
	SCHED_DEADLINE
)
View Source
const IOPRIO_CLASS_SHIFT = 13

Variables

This section is empty.

Functions

func GetCgroup

func GetCgroup(pid int) (cgroup string, err error)

func GetOomScoreAdj

func GetOomScoreAdj(pid int) (score int, err error)

func GetUid

func GetUid(pid int) int

func GetUser

func GetUser(pid int) (*user.User, error)

func IOPrio_Get

func IOPrio_Get(pid int) (int, error)

func IOPrio_Split

func IOPrio_Split(ioprio int, class, data *int)

func Sched_GetParam

func Sched_GetParam(pid int) (int, error)

func Sched_GetScheduler

func Sched_GetScheduler(pid int) (int, error)

func Stat

func Stat(stat string) string

Types

type ByPid

type ByPid []Proc

ByPid implements sort.Interface for []Proc based on Pid field

func (ByPid) Len

func (s ByPid) Len() int

func (ByPid) Less

func (s ByPid) Less(i, j int) bool

func (ByPid) Swap

func (s ByPid) Swap(i, j int)

type Filter

type Filter func(p *Proc, err error) bool

func GetFilter

func GetFilter(what string) Filter

type Formatter

type Formatter func(p *Proc) string

func GetFormatter

func GetFormatter(format string) Formatter

type MainProperties

type MainProperties struct {
	Nice        int    `json:"nice"`
	Sched       string `json:"sched"`
	RTPrio      int    `json:"rtprio"`
	IOClass     string `json:"ioclass"`
	IONice      int    `json:"ionice"`
	OomScoreAdj int    `json:"oom_score_adj"`
}

type Proc

type Proc struct {
	Pid         int    `json:"pid"`
	Ppid        int    `json:"ppid"`
	Pgrp        int    `json:"pgrp"`
	Uid         int    `json:"uid"`
	User        string `json:"user"`
	State       string `json:"state"`
	Comm        string `json:"comm"`
	Cgroup      string `json:"cgroup"`
	Priority    int    `json:"priority"`
	Nice        int    `json:"nice"`
	NumThreads  int    `json:"num_threads"`
	RTPrio      int    `json:"rtprio"`
	Policy      int    `json:"policy"`
	OomScoreAdj int    `json:"oom_score_adj"`
	IOPrioClass int    `json:"ioprio_class"`
	IOPrioData  int    `json:"ionice"`
}

func AllProcs

func AllProcs(filterFunc Filter) (result []Proc)

AllProcs returns a list of all currently available processes. Filters result with filterFunc, if not nil.

func GetCalling

func GetCalling() *Proc

func NewProc

func NewProc(pid int) *Proc

func NewProcFromStat

func NewProcFromStat(stat string) (p *Proc, err error)

func (*Proc) CPUSchedInfo

func (p *Proc) CPUSchedInfo() string

func (*Proc) IOClass

func (p *Proc) IOClass() string

func (*Proc) IOSchedInfo

func (p *Proc) IOSchedInfo() string

func (*Proc) InSystemSlice

func (p *Proc) InSystemSlice() bool

func (*Proc) InUserSlice

func (p *Proc) InUserSlice() bool

func (*Proc) Json

func (p *Proc) Json() string

func (*Proc) LoadStat

func (p *Proc) LoadStat() (err error)

func (*Proc) Map

func (p *Proc) Map() map[string]interface{}

func (*Proc) Raw

func (p *Proc) Raw() string

func (*Proc) ReadStat

func (p *Proc) ReadStat(stat string) (err error)

func (*Proc) RuntimeProperties

func (p *Proc) RuntimeProperties() map[string]interface{}

func (*Proc) Sched

func (p *Proc) Sched() string

func (*Proc) String

func (p *Proc) String() string

func (*Proc) Values

func (p *Proc) Values() string

type ProcMap

type ProcMap struct {
	Pid        int            `json:"pid"`
	Ppid       int            `json:"ppid"`
	Pgrp       int            `json:"pgrp"`
	Uid        int            `json:"uid"`
	User       string         `json:"user"`
	State      string         `json:"state"`
	Slice      string         `json:"slice"`
	Unit       string         `json:"unit"`
	Comm       string         `json:"comm"`
	Cgroup     string         `json:"cgroup"`
	Priority   int            `json:"priority"`
	NumThreads int            `json:"num_threads"`
	Runtime    MainProperties `json:"runtime"`
}

func NewProcMap

func NewProcMap(p *Proc) *ProcMap

func (*ProcMap) Map

func (pm *ProcMap) Map() map[string]interface{}

type Sched_Param

type Sched_Param struct {
	Sched_Priority int
}

type SchedulingPolicy

type SchedulingPolicy struct {
	Class           map[int]string
	NeedPriority    []int
	NeedCredentials []int
	Low             int
	High            int
	None            int
}
var CPU SchedulingPolicy = SchedulingPolicy{
	Class: map[int]string{
		0: "SCHED_OTHER",
		1: "SCHED_FIFO",
		2: "SCHED_RR",
		3: "SCHED_BATCH",

		5: "SCHED_IDLE",
		6: "SCHED_DEADLINE",
	},
	NeedPriority:    []int{1, 2},
	NeedCredentials: []int{1, 2},
	Low:             1,
	High:            99,
	None:            0,
}
var IO SchedulingPolicy = SchedulingPolicy{
	Class: map[int]string{
		0: "none",
		1: "realtime",
		2: "best-effort",
		3: "idle",
	},
	NeedPriority:    []int{1, 2},
	NeedCredentials: []int{1},
	Low:             7,
	High:            0,
	None:            4,
}

Jump to

Keyboard shortcuts

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