Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FS ¶
type GroupCountMap ¶
type GroupCountMap map[string]GroupCounts
type GroupCounts ¶ added in v0.1.0
type Grouper ¶
type Grouper struct { // track how much was seen last time so we can report the delta GroupStats map[string]Counts // contains filtered or unexported fields }
func NewGrouper ¶
func NewGrouper(trackChildren bool, namer common.MatchNamer) *Grouper
func (*Grouper) Groups ¶
func (g *Grouper) Groups() GroupCountMap
Groups returns GroupCounts with Counts that never decrease in value from one call to the next. Even if processes exit, their CPU and IO contributions up to that point are included in the results. Even if no processes remain in a group it will still be included in the results.
type Proc ¶
type Proc interface { // GetPid() returns the POSIX PID (process id). They may be reused over time. GetPid() int // GetProcId() returns (pid,starttime), which can be considered a unique process id. // It may fail if the caller doesn't have permission to read /proc/<pid>/stat, or if // the process has disapeared. GetProcId() (ProcId, error) // GetStatic() returns various details read from files under /proc/<pid>/. Technically // name may not be static, but we'll pretend it is. // It may fail if the caller doesn't have permission to read those files, or if // the process has disapeared. GetStatic() (ProcStatic, error) // GetMetrics() returns various metrics read from files under /proc/<pid>/. // It may fail if the caller doesn't have permission to read those files, or if // the process has disapeared. GetMetrics() (ProcMetrics, error) }
Proc wraps the details of the underlying procfs-reading library.
type ProcId ¶
type ProcId struct { // UNIX process id Pid int // The time the process started after system boot, the value is expressed // in clock ticks. StartTimeRel uint64 }
ProcId uniquely identifies a process.
type ProcIdInfo ¶
type ProcIdInfo struct { ProcId ProcStatic ProcMetrics }
func Info ¶
func Info(p Proc) (ProcIdInfo, error)
func (ProcIdInfo) GetMetrics ¶
func (p ProcIdInfo) GetMetrics() (ProcMetrics, error)
func (ProcIdInfo) GetPid ¶
func (p ProcIdInfo) GetPid() int
func (ProcIdInfo) GetProcId ¶
func (p ProcIdInfo) GetProcId() (ProcId, error)
func (ProcIdInfo) GetStatic ¶
func (p ProcIdInfo) GetStatic() (ProcStatic, error)
type ProcIdStatic ¶
type ProcIdStatic struct { ProcId ProcStatic }
type ProcInfo ¶
type ProcInfo struct { ProcStatic ProcMetrics }
type ProcIter ¶
type ProcIter interface { // Next returns true if the iterator is not exhausted. Next() bool // Close releases any resources the iterator uses. Close() error // The iterator satisfies the Proc interface. Proc }
ProcIter is an iterator over a sequence of procs.
type ProcMetrics ¶
type ProcMetrics struct { CpuTime float64 ReadBytes uint64 WriteBytes uint64 ResidentBytes uint64 VirtualBytes uint64 }
ProcMetrics contains data read from /proc/pid/*
type ProcStatic ¶
ProcStatic contains data read from /proc/pid/*
type TrackedProc ¶
type TrackedProc struct { // GroupName is an optional tag for this proc. GroupName string // contains filtered or unexported fields }
TrackedProc accumulates metrics for a process, as well as remembering an optional GroupName tag associated with it.
func (*TrackedProc) GetCmdLine ¶
func (tp *TrackedProc) GetCmdLine() []string
func (*TrackedProc) GetName ¶
func (tp *TrackedProc) GetName() string
type Tracker ¶
type Tracker struct { // Tracked holds the processes are being monitored. Processes // may be blacklisted such that they no longer get tracked by // setting their value in the Tracked map to nil. Tracked map[ProcId]*TrackedProc // ProcIds is a map from pid to ProcId. This is a convenience // to allow finding the Tracked entry of a parent process. ProcIds map[int]ProcId }
Tracker tracks processes and records metrics.
func NewTracker ¶
func NewTracker() *Tracker
func (*Tracker) Track ¶
func (t *Tracker) Track(groupName string, idinfo ProcIdInfo)