Documentation ¶
Index ¶
- Constants
- type DataSource
- type ExecFeed
- type ExitFeed
- type FileInfo
- func (fi *FileInfo) GetCtime() int
- func (fi *FileInfo) GetCtimeAt(targetTime time.Time) int
- func (fi *FileInfo) GetDev() int
- func (fi *FileInfo) GetDevAt(targetTime time.Time) int
- func (fi *FileInfo) GetFeed() FileInfoFeed
- func (fi *FileInfo) GetFeedAt(targetTime time.Time) FileInfoFeed
- func (fi *FileInfo) GetInode() int
- func (fi *FileInfo) GetInodeAt(targetTime time.Time) int
- func (fi *FileInfo) GetInodeMode() int
- func (fi *FileInfo) GetInodeModeAt(targetTime time.Time) int
- func (fi *FileInfo) GetPath() string
- func (fi *FileInfo) GetPathAt(targetTime time.Time) string
- func (fi *FileInfo) SetCtime(ctime int)
- func (fi *FileInfo) SetCtimeAt(ctime int, targetTime time.Time)
- func (fi *FileInfo) SetDev(dev int)
- func (fi *FileInfo) SetDevAt(dev int, targetTime time.Time)
- func (fi *FileInfo) SetFeed(feed FileInfoFeed)
- func (fi *FileInfo) SetFeedAt(feed FileInfoFeed, targetTime time.Time)
- func (fi *FileInfo) SetInode(inode int)
- func (fi *FileInfo) SetInodeAt(inode int, targetTime time.Time)
- func (fi *FileInfo) SetInodeMode(inodeMode int)
- func (fi *FileInfo) SetInodeModeAt(inodeMode int, targetTime time.Time)
- func (fi *FileInfo) SetPath(path string)
- func (fi *FileInfo) SetPathAt(path string, targetTime time.Time)
- type FileInfoFeed
- type ForkFeed
- type ProcTreeConfig
- type Process
- func (p *Process) AddChild(childHash uint32)
- func (p *Process) AddThread(threadHash uint32)
- func (p *Process) DelChild(childHash uint32)
- func (p *Process) DelThread(threadHash uint32)
- func (p *Process) GetChildren() []uint32
- func (p *Process) GetExecutable() *FileInfo
- func (p *Process) GetHash() uint32
- func (p *Process) GetInfo() *TaskInfo
- func (p *Process) GetInterp() *FileInfo
- func (p *Process) GetInterpreter() *FileInfo
- func (p *Process) GetParentHash() uint32
- func (p *Process) GetThreads() []uint32
- func (p *Process) SetParentHash(parentHash uint32)
- type ProcessTree
- func (pt *ProcessTree) FeedFromExec(feed ExecFeed) error
- func (pt *ProcessTree) FeedFromExit(feed ExitFeed) error
- func (pt *ProcessTree) FeedFromFork(feed ForkFeed) error
- func (pt *ProcessTree) FeedFromProcFS(givenPid int) error
- func (pt *ProcessTree) FeedFromProcFSAsync(givenPid int)
- func (pt *ProcessTree) GetOrCreateProcessByHash(hash uint32) *Process
- func (pt *ProcessTree) GetOrCreateThreadByHash(hash uint32) *Thread
- func (pt *ProcessTree) GetProcessByHash(hash uint32) (*Process, bool)
- func (pt *ProcessTree) GetThreadByHash(hash uint32) (*Thread, bool)
- func (pt *ProcessTree) String() string
- type SourceType
- type TaskInfo
- func (ti *TaskInfo) GetExitTime() time.Time
- func (ti *TaskInfo) GetExitTimeNS() uint64
- func (ti *TaskInfo) GetFeed() TaskInfoFeed
- func (ti *TaskInfo) GetFeedAt(targetTime time.Time) TaskInfoFeed
- func (ti *TaskInfo) GetGid() int
- func (ti *TaskInfo) GetGidAt(targetTime time.Time) int
- func (ti *TaskInfo) GetName() string
- func (ti *TaskInfo) GetNameAt(targetTime time.Time) string
- func (ti *TaskInfo) GetNsPPid() int
- func (ti *TaskInfo) GetNsPPidAt(targetTime time.Time) int
- func (ti *TaskInfo) GetNsPid() int
- func (ti *TaskInfo) GetNsTid() int
- func (ti *TaskInfo) GetPPid() int
- func (ti *TaskInfo) GetPPidAt(targetTime time.Time) int
- func (ti *TaskInfo) GetPid() int
- func (ti *TaskInfo) GetStartTime() time.Time
- func (ti *TaskInfo) GetStartTimeNS() uint64
- func (ti *TaskInfo) GetTid() int
- func (ti *TaskInfo) GetUid() int
- func (ti *TaskInfo) GetUidAt(targetTime time.Time) int
- func (ti *TaskInfo) IsAlive() bool
- func (ti *TaskInfo) IsAliveAt(targetTime time.Time) bool
- func (ti *TaskInfo) SetExitTime(exitTime uint64)
- func (ti *TaskInfo) SetFeed(feed TaskInfoFeed)
- func (ti *TaskInfo) SetFeedAt(feed TaskInfoFeed, targetTime time.Time)
- func (ti *TaskInfo) SetGid(gid int)
- func (ti *TaskInfo) SetGidAt(gid int, targetTime time.Time)
- func (ti *TaskInfo) SetName(name string)
- func (ti *TaskInfo) SetNameAt(name string, targetTime time.Time)
- func (ti *TaskInfo) SetNsPPid(nsPPid int)
- func (ti *TaskInfo) SetNsPPidAt(nsPPid int, targetTime time.Time)
- func (ti *TaskInfo) SetNsPid(nsPid int)
- func (ti *TaskInfo) SetNsTid(nsTid int)
- func (ti *TaskInfo) SetPPid(pPid int)
- func (ti *TaskInfo) SetPPidAt(pPid int, targetTime time.Time)
- func (ti *TaskInfo) SetPid(pid int)
- func (ti *TaskInfo) SetStartTimeNS(startTimeNS uint64)
- func (ti *TaskInfo) SetTid(tid int)
- func (ti *TaskInfo) SetUid(uid int)
- func (ti *TaskInfo) SetUidAt(uid int, targetTime time.Time)
- type TaskInfoFeed
- type Thread
Constants ¶
const ( DefaultProcessCacheSize = 32768 DefaultThreadCacheSize = 32768 )
const (
AllPIDs = 0
)
const COMM_LEN = 16
const MaxPathLen = 1024
Paths theoretically has no limit, but we do need to set a limit for the sake of managing memory more responsibly.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DataSource ¶
type DataSource struct {
// contains filtered or unexported fields
}
DataSource is an implementation to detect.Datasource interface, enveloping the ProcessTree type.
func NewDataSource ¶
func NewDataSource(processTree *ProcessTree) *DataSource
func (*DataSource) Get ¶
func (ptds *DataSource) Get(key interface{}) (map[string]interface{}, error)
Get retrieves information from DataSource based on the provided key. It supports keys of the following types:
- datasource.ProcKey (for process information retrieval) - datasource.ThreadKey (for thread information retrieval) - datasource.LineageKey (for process lineage information retrieval)
and returns an error if the data isn't found.
func (*DataSource) Keys ¶
func (ptds *DataSource) Keys() []string
Keys returns a list of supported keys by the DataSource.
func (*DataSource) Namespace ¶
func (ptds *DataSource) Namespace() string
Namespace returns the namespace of the DataSource.
func (*DataSource) Schema ¶
func (ptds *DataSource) Schema() string
Schema returns the schema of the DataSource.
func (*DataSource) Version ¶
func (ptds *DataSource) Version() uint
Version returns the version of the DataSource.
type ExecFeed ¶
type ExecFeed struct { TimeStamp uint64 TaskHash uint32 ParentHash uint32 LeaderHash uint32 CmdPath string PathName string Dev uint32 Inode uint64 Ctime uint64 InodeMode uint16 InterpreterPath string InterpreterDev uint32 InterpreterInode uint64 InterpreterCtime uint64 Interp string StdinType uint16 StdinPath string InvokedFromKernel int32 }
type FileInfo ¶
type FileInfo struct {
// contains filtered or unexported fields
}
FileInfo represents a file.
func NewFileInfoFeed ¶
func NewFileInfoFeed(maxLogSize int, feed FileInfoFeed) *FileInfo
NewFileInfoFeed creates a new file with values from the given feed.
func (*FileInfo) GetCtimeAt ¶
GetCtimeAt returns the creation time of the file at the given time.
func (*FileInfo) GetFeed ¶
func (fi *FileInfo) GetFeed() FileInfoFeed
GetFeed returns the values of the file as a feed.
func (*FileInfo) GetFeedAt ¶
func (fi *FileInfo) GetFeedAt(targetTime time.Time) FileInfoFeed
GetFeedAt returns the values of the file as a feed at the given time.
func (*FileInfo) GetInodeAt ¶
GetInodeAt returns the inode number of the file at the given time.
func (*FileInfo) GetInodeMode ¶
GetInodeMode returns the inode mode of the file.
func (*FileInfo) GetInodeModeAt ¶
GetInodeModeAt returns the inode mode of the file at the given time.
func (*FileInfo) SetCtimeAt ¶
SetCtimeAt sets the creation time of the file at the given time.
func (*FileInfo) SetFeed ¶
func (fi *FileInfo) SetFeed(feed FileInfoFeed)
SetFeed sets the values of the file from a feed.
func (*FileInfo) SetFeedAt ¶
func (fi *FileInfo) SetFeedAt(feed FileInfoFeed, targetTime time.Time)
SetFeedAt sets the values of the file from a feed at the given time.
func (*FileInfo) SetInodeAt ¶
SetInodeAt sets the inode number of the file at the given time.
func (*FileInfo) SetInodeMode ¶
SetInodeMode sets the inode mode of the file.
func (*FileInfo) SetInodeModeAt ¶
SetInodeModeAt sets the inode mode of the file at the given time.
type FileInfoFeed ¶
FileInfoFeed allows external packages to set/get multiple values of a task at once.
type ForkFeed ¶
type ForkFeed struct { TimeStamp uint64 ChildHash uint32 ParentHash uint32 LeaderHash uint32 ParentTid int32 ParentNsTid int32 ParentPid int32 ParentNsPid int32 ParentStartTime uint64 LeaderTid int32 LeaderNsTid int32 LeaderPid int32 LeaderNsPid int32 LeaderStartTime uint64 ChildTid int32 ChildNsTid int32 ChildPid int32 ChildNsPid int32 ChildStartTime uint64 }
type ProcTreeConfig ¶
type ProcTreeConfig struct { Source SourceType ProcessCacheSize int ThreadCacheSize int ProcfsInitialization bool // Determine whether to scan procfs data for process tree initialization ProcfsQuerying bool // Determine whether to query procfs for missing information during runtime }
type Process ¶
type Process struct {
// contains filtered or unexported fields
}
Process represents a process.
func NewProcessWithInfo ¶
NewProcessWithInfo creates a new thread with an initialized task info.
func (*Process) GetChildren ¶
GetChildren returns the children of the process.
func (*Process) GetExecutable ¶
GetExecutable returns a instanced executable info.
func (*Process) GetInterpreter ¶
GetInterpreter returns a instanced interpreter info.
func (*Process) GetParentHash ¶
GetParentHash returns the hash of the parent.
func (*Process) GetThreads ¶
GetThreads returns the threads of the process.
func (*Process) SetParentHash ¶
SetParentHash sets the hash of the parent.
type ProcessTree ¶
type ProcessTree struct {
// contains filtered or unexported fields
}
ProcessTree is a tree of processes and threads.
func NewProcessTree ¶
func NewProcessTree(ctx context.Context, config ProcTreeConfig) (*ProcessTree, error)
NewProcessTree creates a new process tree.
func (*ProcessTree) FeedFromExec ¶
func (pt *ProcessTree) FeedFromExec(feed ExecFeed) error
FeedFromExec feeds the process tree with an exec event.
func (*ProcessTree) FeedFromExit ¶
func (pt *ProcessTree) FeedFromExit(feed ExitFeed) error
FeedFromExit feeds the process tree with an exit event.
func (*ProcessTree) FeedFromFork ¶
func (pt *ProcessTree) FeedFromFork(feed ForkFeed) error
FeedFromFork feeds the process tree with a fork event.
func (*ProcessTree) FeedFromProcFS ¶
func (pt *ProcessTree) FeedFromProcFS(givenPid int) error
FeedFromProcFS feeds the process tree with data from procfs.
func (*ProcessTree) FeedFromProcFSAsync ¶
func (pt *ProcessTree) FeedFromProcFSAsync(givenPid int)
FeedFromProcFSAsync feeds the process tree with data from procfs asynchronously.
func (*ProcessTree) GetOrCreateProcessByHash ¶
func (pt *ProcessTree) GetOrCreateProcessByHash(hash uint32) *Process
GetOrCreateProcessByHash returns a process by its hash, or creates a new one if it doesn't exist.
func (*ProcessTree) GetOrCreateThreadByHash ¶
func (pt *ProcessTree) GetOrCreateThreadByHash(hash uint32) *Thread
GetOrCreateThreadByHash returns a thread by its hash, or creates a new one if it doesn't exist.
func (*ProcessTree) GetProcessByHash ¶
func (pt *ProcessTree) GetProcessByHash(hash uint32) (*Process, bool)
GetProcessByHash returns a process by its hash.
func (*ProcessTree) GetThreadByHash ¶
func (pt *ProcessTree) GetThreadByHash(hash uint32) (*Thread, bool)
GetThreadByHash returns a thread by its hash.
func (*ProcessTree) String ¶
func (pt *ProcessTree) String() string
String returns a string representation of the process tree.
type SourceType ¶
type SourceType int
const ( SourceNone SourceType = iota // disabled SourceSignals // event from control plane enrich the process tree SourceEvents // event from pipeline enrich the process tree SourceBoth // events from both pipelines enrich the process tree )
func (SourceType) String ¶
func (s SourceType) String() string
type TaskInfo ¶
type TaskInfo struct {
// contains filtered or unexported fields
}
TaskInfo represents a task.
func NewTaskInfoFromFeed ¶
func NewTaskInfoFromFeed(feed TaskInfoFeed) *TaskInfo
NewTaskInfoFromFeed creates a new task with values from the given feed.
func (*TaskInfo) GetExitTime ¶
GetExitTime returns the "real" exit time of the task.
func (*TaskInfo) GetExitTimeNS ¶
GetExitTimeNS returns the exitTime of the task.
func (*TaskInfo) GetFeed ¶
func (ti *TaskInfo) GetFeed() TaskInfoFeed
GetFeed returns the values of the task as a feed.
func (*TaskInfo) GetFeedAt ¶
func (ti *TaskInfo) GetFeedAt(targetTime time.Time) TaskInfoFeed
GetFeedAt returns the values of the task as a feed at the given time.
func (*TaskInfo) GetNsPPidAt ¶
GetNsPPidAt returns the nsPPid of the task at the given time.
func (*TaskInfo) GetStartTime ¶
GetStartTime returns the "real" start time of the task.
func (*TaskInfo) GetStartTimeNS ¶
GetStartTimeNS returns the startTimeNS of the task.
func (*TaskInfo) IsAliveAt ¶
IsAliveAt return whether the task is alive in the given time, either because it didn't start yet or it has exited.
func (*TaskInfo) SetExitTime ¶
SetExitTime sets the exitTime of the task.
func (*TaskInfo) SetFeed ¶
func (ti *TaskInfo) SetFeed(feed TaskInfoFeed)
SetFeed sets the values of the task from the given feed.
func (*TaskInfo) SetFeedAt ¶
func (ti *TaskInfo) SetFeedAt(feed TaskInfoFeed, targetTime time.Time)
SetFeedAt sets the values of the task from the given feed at the given time.
func (*TaskInfo) SetNsPPidAt ¶
SetNsPPidAt sets the nsppid of the task at the given time.
func (*TaskInfo) SetStartTimeNS ¶
SetStartTimeNS sets the startTimeNS of the task.
type TaskInfoFeed ¶
type TaskInfoFeed struct { Name string Tid int Pid int PPid int NsTid int NsPid int NsPPid int Uid int Gid int StartTimeNS uint64 ExitTimeNS uint64 }
TaskInfoFeed allows external packages to set/get multiple values of a task at once.
type Thread ¶
type Thread struct {
// contains filtered or unexported fields
}
Thread represents a thread.
func NewThreadWithInfo ¶
NewThreadWithInfo creates a new thread with an initialized task info.
func (*Thread) GetLeaderHash ¶
GEtLeaderHash returns the hash of the thread group leader.
func (*Thread) GetParentHash ¶
GetParentHash returns the hash of the parent.
func (*Thread) SetLeaderHash ¶
SetLeaderHash sets the hash of the thread group leader.
func (*Thread) SetParentHash ¶
SetParentHash sets the hash of the parent.