process

package
v6.2.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2018 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NumCPU = runtime.NumCPU()

NumCPU is the number of CPUs of the host

Functions

func GetOwnResourceUsageTimeInMillis

func GetOwnResourceUsageTimeInMillis() (int64, int64, error)

GetOwnResourceUsageTimeInMillis return the user and system CPU usage time in milliseconds

func GetProcCPUPercentage

func GetProcCPUPercentage(s0, s1 *Process) (normalizedPct, pct, totalPct float64)

GetProcCPUPercentage returns the percentage of total CPU time consumed by the process during the period between the given samples. Two percentages are returned (these must be multiplied by 100). The first is a normalized based on the number of cores such that the value ranges on [0, 1]. The second is not normalized and the value ranges on [0, number_of_cores].

Implementation note: The total system CPU time (including idle) is not provided so this method will resort to using the difference in wall-clock time multiplied by the number of cores as the total amount of CPU time available between samples. This could result in incorrect percentages if the wall-clock is adjusted (prior to Go 1.9) or the machine is suspended.

func GetProcMemPercentage

func GetProcMemPercentage(proc *Process, totalPhyMem uint64) float64

func Pids

func Pids() ([]int, error)

Types

type IncludeTopConfig

type IncludeTopConfig struct {
	Enabled  bool `config:"enabled"`
	ByCPU    int  `config:"by_cpu"`
	ByMemory int  `config:"by_memory"`
}

IncludeTopConfig is the configuration for the "top N processes filtering" feature

type Process

type Process struct {
	Pid        int    `json:"pid"`
	Ppid       int    `json:"ppid"`
	Pgid       int    `json:"pgid"`
	Name       string `json:"name"`
	Username   string `json:"username"`
	State      string `json:"state"`
	CmdLine    string `json:"cmdline"`
	Cwd        string `json:"cwd"`
	Mem        sigar.ProcMem
	Cpu        sigar.ProcTime
	SampleTime time.Time
	FD         sigar.ProcFDUsage
	Env        common.MapStr
	// contains filtered or unexported fields
}

Process is the structure which holds the information of a process running on the host. It includes pid, gid and it interacts with gosigar to fetch process data from the host.

type ProcsMap

type ProcsMap map[int]*Process

ProcsMap is a map where the keys are the names of processes and the value is the Process with that name

type Stats

type Stats struct {
	Procs        []string
	ProcsMap     ProcsMap
	CpuTicks     bool
	EnvWhitelist []string
	CacheCmdLine bool
	IncludeTop   IncludeTopConfig
	// contains filtered or unexported fields
}

Stats stores the stats of preocesses on the host.

func (*Stats) Get

func (procStats *Stats) Get() ([]common.MapStr, error)

Get fetches process data which matches the provided regexes from the host.

func (*Stats) GetOne

func (procStats *Stats) GetOne(pid int) (common.MapStr, error)

GetOne fetches process data for a given PID if its name matches the regexes provided from the host.

func (*Stats) Init

func (procStats *Stats) Init() error

Init initizalizes a Stats instance. It returns erros if the provided process regexes cannot be compiled.

type Ticks

type Ticks struct {
	User   uint64
	System uint64
	Total  uint64
}

Ticks of CPU for a process

Jump to

Keyboard shortcuts

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