Documentation
¶
Overview ¶
Package processlist holds process context
Package processlist holds process context ¶
Package processlist holds process context
Index ¶
- type ExecNode
- type Owner
- type ProcessList
- func (pl *ProcessList) AppendChild(node *ProcessNode, currentParrent bool)
- func (pl *ProcessList) Contains(event *model.Event, insertMissingProcesses bool, imageTag string) (newEntryAdded bool, err error)
- func (pl *ProcessList) Debug(w io.Writer)
- func (pl *ProcessList) DeleteCachedProcess(key interface{}, imageTag string) (entryDeleted bool, err error)
- func (pl *ProcessList) GetCacheExec(key interface{}) *ExecNode
- func (pl *ProcessList) GetCacheProcess(key interface{}) *ProcessNode
- func (pl *ProcessList) GetChildren() *[]*ProcessNode
- func (pl *ProcessList) GetCurrentParent() ProcessNodeIface
- func (pl *ProcessList) GetCurrentSiblings() *[]*ProcessNode
- func (pl *ProcessList) GetExecCacheSize() int
- func (pl *ProcessList) GetPossibleParents() []ProcessNodeIface
- func (pl *ProcessList) GetProcessCacheSize() int
- func (pl *ProcessList) Insert(event *model.Event, insertMissingProcesses bool, imageTag string) (newEntryAdded bool, err error)
- func (pl *ProcessList) MatchesSelector(event *model.Event) bool
- func (pl *ProcessList) SaveToFile(filePath, format string) error
- func (pl *ProcessList) ToDOT() ([]byte, error)
- func (pl *ProcessList) ToJSON() ([]byte, error)
- func (pl *ProcessList) UnlinkChild(_ Owner, child *ProcessNode) bool
- func (pl *ProcessList) Walk(f func(node *ProcessNode) (stop bool)) (stop bool)
- type ProcessNode
- func (pn *ProcessNode) AppendChild(child *ProcessNode, currentParent bool)
- func (pn *ProcessNode) AppendExec(exec *ExecNode, currentExec bool)
- func (pn *ProcessNode) Debug(w io.Writer, prefix string)
- func (pn *ProcessNode) GetChildren() *[]*ProcessNode
- func (pn *ProcessNode) GetCurrentParent() ProcessNodeIface
- func (pn *ProcessNode) GetCurrentSiblings() *[]*ProcessNode
- func (pn *ProcessNode) GetPossibleParents() []ProcessNodeIface
- func (pn *ProcessNode) UnlinkChild(owner Owner, child *ProcessNode) bool
- func (pn *ProcessNode) Walk(f func(node *ProcessNode) (stop bool)) (stop bool)
- type ProcessNodeIface
- type ProcessStats
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ExecNode ¶
type ExecNode struct {
sync.Mutex
model.Process
// Key represents the key used to retrieve the exec from the cache
// if the owner is able to define a key we use it, otherwise we'll put
// a random generated uint64 cookie
Key interface{}
ProcessLink *ProcessNode
MatchedRules []*model.MatchedRule
}
ExecNode defines an exec
func NewEmptyExecNode ¶
func NewEmptyExecNode() *ExecNode
NewEmptyExecNode returns a new empty ExecNode instance
func NewExecNodeFromEvent ¶
NewExecNodeFromEvent returns a new exec node from a given event, and if any, use the provided key to assign it (otherwise it will choose a random one)
type Owner ¶
type Owner interface {
// is valid root node
IsAValidRootNode(event *model.Process) bool
// matches
ExecMatches(e1, e2 *ExecNode) bool
ProcessMatches(p1, p2 *ProcessNode) bool
// send custom stats
SendStats(client statsd.ClientInterface) error
// returns the key related to an exec
GetExecCacheKey(process *model.Process) interface{}
// returns the key related to a process
GetProcessCacheKey(process *model.Process) interface{}
// returns the keys related to a process parent, given an event
GetParentProcessCacheKey(event *model.Event) interface{}
}
Owner defines the interface to implement prior to use ProcessList
type ProcessList ¶
type ProcessList struct {
sync.Mutex
// internals
Stats ProcessStats
// contains filtered or unexported fields
}
ProcessList defines a process graph/cache of processes and their related execs
func NewProcessList ¶
func NewProcessList(selector cgroupModel.WorkloadSelector, validEventTypes []model.EventType, owner Owner, statsdClient statsd.ClientInterface, scrubber *procutil.DataScrubber) *ProcessList
NewProcessList returns a new process list
func NewProcessListFromFile ¶
func NewProcessListFromFile(owner Owner) (*ProcessList, error)
NewProcessListFromFile returns a new process list from a file nolint: all
func (*ProcessList) AppendChild ¶
func (pl *ProcessList) AppendChild(node *ProcessNode, currentParrent bool)
AppendChild appends a new root node in the ProcessList
func (*ProcessList) Contains ¶
func (pl *ProcessList) Contains(event *model.Event, insertMissingProcesses bool, imageTag string) (newEntryAdded bool, err error)
nolint: all
func (*ProcessList) Debug ¶
func (pl *ProcessList) Debug(w io.Writer)
Debug prints out recursively content of each node
func (*ProcessList) DeleteCachedProcess ¶
func (pl *ProcessList) DeleteCachedProcess(key interface{}, imageTag string) (entryDeleted bool, err error)
DeleteCachedProcess deletes the process matching the provided key, and all its children
func (*ProcessList) GetCacheExec ¶
func (pl *ProcessList) GetCacheExec(key interface{}) *ExecNode
GetCacheExec retrieve the cached exec matching the given key
func (*ProcessList) GetCacheProcess ¶
func (pl *ProcessList) GetCacheProcess(key interface{}) *ProcessNode
GetCacheProcess retrieve the cached process matching the given key
func (*ProcessList) GetChildren ¶
func (pl *ProcessList) GetChildren() *[]*ProcessNode
GetChildren returns the root nodes
func (*ProcessList) GetCurrentParent ¶
func (pl *ProcessList) GetCurrentParent() ProcessNodeIface
GetCurrentParent returns nil (process list don't have parent)
func (*ProcessList) GetCurrentSiblings ¶
func (pl *ProcessList) GetCurrentSiblings() *[]*ProcessNode
GetCurrentSiblings returns nil (process list don't have siblings)
func (*ProcessList) GetExecCacheSize ¶
func (pl *ProcessList) GetExecCacheSize() int
GetExecCacheSize returns the exec cache size
func (*ProcessList) GetPossibleParents ¶
func (pl *ProcessList) GetPossibleParents() []ProcessNodeIface
GetPossibleParents returns nil (process list don't have parent)
func (*ProcessList) GetProcessCacheSize ¶
func (pl *ProcessList) GetProcessCacheSize() int
GetProcessCacheSize returns the process cache size
func (*ProcessList) Insert ¶
func (pl *ProcessList) Insert(event *model.Event, insertMissingProcesses bool, imageTag string) (newEntryAdded bool, err error)
Insert tries to insert (or delete) the given event ot the process list graph, using cache if possible
func (*ProcessList) MatchesSelector ¶
func (pl *ProcessList) MatchesSelector(event *model.Event) bool
nolint: all
func (*ProcessList) SaveToFile ¶
func (pl *ProcessList) SaveToFile(filePath, format string) error
marshall and save processes to the given file nolint: all
func (*ProcessList) UnlinkChild ¶
func (pl *ProcessList) UnlinkChild(_ Owner, child *ProcessNode) bool
UnlinkChild unlinks a root node
func (*ProcessList) Walk ¶
func (pl *ProcessList) Walk(f func(node *ProcessNode) (stop bool)) (stop bool)
Walk walks recursively the process nodes
type ProcessNode ¶
type ProcessNode struct {
sync.Mutex
// represent the key used to retrieve the process from the cache
// if the owner is able to define a key we use it, otherwise we'll put
// a random generated uint64 cookie
Key interface{}
// mainly used by dump/profiles
ImageTags []string
// for runtime cache: possible parents represents an agregated view of what we saw at runtime (ex: if a process
// loose its parent and being attached to the closest sub-reaper, it would have 1 current parrent but
// 2 possible ones).
// for AD: same logic as for runtime
CurrentParent ProcessNodeIface
PossibleParents []ProcessNodeIface
// for runtime cache: possible execs represents the ancestors, in a unsorted way
// for AD: possible execs represents, after a fork, what exec we already seen (and so,
// possible ones)
CurrentExec *ExecNode
PossibleExecs []*ExecNode
Children []*ProcessNode
// Used to store custom fields, depending on the owner, basically:
// == Fields used by process resolver:
// refCount?
// onRelase CB?
// (would be great if we finally can get rid of it!)
UserData interface{}
}
ProcessNode holds the activity of a process
func NewProcessExecNodeFromEvent ¶
func NewProcessExecNodeFromEvent(event *model.Event, processKey, execKey interface{}) *ProcessNode
NewProcessExecNodeFromEvent returns a process node filled with an exec node corresponding to the given event
func (*ProcessNode) AppendChild ¶
func (pn *ProcessNode) AppendChild(child *ProcessNode, currentParent bool)
AppendChild appends a new node in the process node
func (*ProcessNode) AppendExec ¶
func (pn *ProcessNode) AppendExec(exec *ExecNode, currentExec bool)
AppendExec adds a new exec to the process node, and mark it as current if currentExec is specified
func (*ProcessNode) Debug ¶
func (pn *ProcessNode) Debug(w io.Writer, prefix string)
Debug prints out recursively content of each node
func (*ProcessNode) GetChildren ¶
func (pn *ProcessNode) GetChildren() *[]*ProcessNode
GetChildren returns the list of children of the ProcessNode
func (*ProcessNode) GetCurrentParent ¶
func (pn *ProcessNode) GetCurrentParent() ProcessNodeIface
GetCurrentParent returns the current parent
func (*ProcessNode) GetCurrentSiblings ¶
func (pn *ProcessNode) GetCurrentSiblings() *[]*ProcessNode
GetCurrentSiblings returns the list of siblings of the current node
func (*ProcessNode) GetPossibleParents ¶
func (pn *ProcessNode) GetPossibleParents() []ProcessNodeIface
GetPossibleParents returns the possible parents
func (*ProcessNode) UnlinkChild ¶
func (pn *ProcessNode) UnlinkChild(owner Owner, child *ProcessNode) bool
UnlinkChild unlinks a child from the children list
func (*ProcessNode) Walk ¶
func (pn *ProcessNode) Walk(f func(node *ProcessNode) (stop bool)) (stop bool)
Walk walks the process node and children recursively
type ProcessNodeIface ¶
type ProcessNodeIface interface {
GetCurrentParent() ProcessNodeIface
GetPossibleParents() []ProcessNodeIface
GetChildren() *[]*ProcessNode
GetCurrentSiblings() *[]*ProcessNode
AppendChild(child *ProcessNode, currentParent bool)
UnlinkChild(owner Owner, child *ProcessNode) bool
}
ProcessNodeIface is an interface used to identify the parent of a process context
Directories
¶
| Path | Synopsis |
|---|---|
|
Package activitytree holds activitytree related files
|
Package activitytree holds activitytree related files |
|
Package processresolver holds processresolver related files
|
Package processresolver holds processresolver related files |