Documentation
¶
Index ¶
- Constants
- Variables
- func ConvertAllFilledProcesses(processes map[int32]*process.FilledProcess) map[int32]*Process
- func ConvertAllFilledProcessesToStats(processes map[int32]*process.FilledProcess) map[int32]*Stats
- func IsSameProcess(a, b *Process) bool
- func ProcessIdentity(pid int32, createTime int64, cmdline []string) string
- type CPUPercentStat
- type CPUTimesStat
- type DataScrubber
- type DataScrubberPattern
- type IOCountersRateStat
- type IOCountersStat
- type InjectionState
- type MemoryInfoExStat
- type MemoryInfoStat
- type NumCtxSwitchesStat
- type Option
- type Probe
- type Process
- type Service
- type Stats
- type StatsWithPerm
Constants ¶
const ( // WorldReadable represents file permission that's world readable WorldReadable os.FileMode = 4 // DefaultClockTicks is the default number of clock ticks per second // C.sysconf(C._SC_CLK_TCK) DefaultClockTicks = float64(100) )
Variables ¶
var ( // PageSize is the system's memory page size PageSize = uint64(os.Getpagesize()) )
Functions ¶
func ConvertAllFilledProcesses ¶
func ConvertAllFilledProcesses(processes map[int32]*process.FilledProcess) map[int32]*Process
ConvertAllFilledProcesses takes a group of FilledProcess objects and convert them into Process
func ConvertAllFilledProcessesToStats ¶
func ConvertAllFilledProcessesToStats(processes map[int32]*process.FilledProcess) map[int32]*Stats
ConvertAllFilledProcessesToStats takes a group of FilledProcess objects and convert them into Stats
func IsSameProcess ¶
IsSameProcess returns true if two processes have the same identity (PID, create time, and cmdline).
IMPORTANT: This function uses the same identity fields as ProcessIdentity (pid, createTime, cmdline). If you modify the identity fields here, update ProcessIdentity as well. See TestProcessIdentityAndIsSameProcessInSync for enforcement.
func ProcessIdentity ¶
ProcessIdentity generates a unique identity string for a process based on PID, creation time, and command line hash. This allows detection of exec scenarios where the PID and creation time remain the same but the command line changes.
IMPORTANT: This function uses the same identity fields as IsSameProcess (pid, createTime, cmdline). If you modify the identity fields here, update IsSameProcess as well. See TestProcessIdentityAndIsSameProcessInSync for enforcement.
Types ¶
type CPUPercentStat ¶
CPUPercentStat holds CPU stat metrics of a process as CPU usage percent
type CPUTimesStat ¶
type CPUTimesStat struct {
User float64
System float64
Idle float64
Nice float64
Iowait float64
Irq float64
Softirq float64
Steal float64
Guest float64
GuestNice float64
Stolen float64
Timestamp int64
}
CPUTimesStat holds CPU stat metrics of a process
func ConvertFromCPUStat ¶
func ConvertFromCPUStat(s cpu.TimesStat) *CPUTimesStat
ConvertFromCPUStat converts gopsutil TimesStat object to CPUTimesStat in procutil
func (*CPUTimesStat) Total ¶
func (c *CPUTimesStat) Total() float64
Total returns the total number of seconds in a CPUTimesStat
type DataScrubber ¶
type DataScrubber struct {
Enabled bool
StripAllArguments bool
SensitivePatterns []DataScrubberPattern
// contains filtered or unexported fields
}
DataScrubber allows the agent to disallow-list cmdline arguments that match a list of predefined and custom words
func NewDefaultDataScrubber ¶
func NewDefaultDataScrubber() *DataScrubber
NewDefaultDataScrubber creates a DataScrubber with the default behavior: enabled and matching the default sensitive words
func (*DataScrubber) AddCustomSensitiveWords ¶
func (ds *DataScrubber) AddCustomSensitiveWords(words []string)
AddCustomSensitiveWords adds custom sensitive words on the DataScrubber object
func (*DataScrubber) IncrementCacheAge ¶
func (ds *DataScrubber) IncrementCacheAge()
IncrementCacheAge increments one cycle of cache memory age. If it reaches cacheMaxCycles, the cache is restarted
func (*DataScrubber) ScrubCommand ¶
func (ds *DataScrubber) ScrubCommand(cmdline []string) ([]string, bool)
ScrubCommand hides the argument value for any key which matches a "sensitive word" pattern. It returns the updated cmdline, as well as a boolean representing whether it was scrubbed
func (*DataScrubber) ScrubProcessCommand ¶
func (ds *DataScrubber) ScrubProcessCommand(p *Process) []string
ScrubProcessCommand uses a cache memory to avoid scrubbing already known process' cmdlines
type DataScrubberPattern ¶
func CompileStringsToRegex ¶
func CompileStringsToRegex(words []string) []DataScrubberPattern
CompileStringsToRegex compile each word in the slice into a regex pattern to match against the cmdline arguments The word must contain only word characters ([a-zA-z0-9_]) or wildcards *
type IOCountersRateStat ¶
type IOCountersRateStat struct {
ReadRate float64
WriteRate float64
ReadBytesRate float64
WriteBytesRate float64
}
IOCountersRateStat holds IO metrics for a process represented as rates (/sec)
type IOCountersStat ¶
IOCountersStat holds IO metrics for a process
func ConvertFromIOStats ¶
func ConvertFromIOStats(s *process.IOCountersStat) *IOCountersStat
ConvertFromIOStats converts gopsutil IOCountersStat object to IOCounterStat in procutil
func (*IOCountersStat) IsZeroValue ¶
func (i *IOCountersStat) IsZeroValue() bool
IsZeroValue checks whether all fields are 0 in value for IOCountersStat
type InjectionState ¶
type InjectionState int
InjectionState represents the APM injection state of a process
const ( // InjectionUnknown means we haven't determined the injection status yet InjectionUnknown InjectionState = 0 // InjectionInjected means the process has APM auto-injection enabled InjectionInjected InjectionState = 1 // InjectionNotInjected means the process does not have APM auto-injection InjectionNotInjected InjectionState = 2 )
type MemoryInfoExStat ¶
type MemoryInfoExStat struct {
RSS uint64 // bytes
VMS uint64 // bytes
Text uint64 // bytes
Lib uint64 // bytes
Data uint64 // bytes
Dirty uint64 // bytes
}
MemoryInfoExStat holds all memory metrics for a process
func ConvertFromMemInfoEx ¶
func ConvertFromMemInfoEx(s *process.MemoryInfoExStat) *MemoryInfoExStat
ConvertFromMemInfoEx converts gopsutil MemoryInfoExStat object to MemoryInfoExStat in procutil
type MemoryInfoStat ¶
MemoryInfoStat holds commonly used memory metrics for a process
func ConvertFromMemInfo ¶
func ConvertFromMemInfo(s *process.MemoryInfoStat) *MemoryInfoStat
ConvertFromMemInfo converts gopsutil MemoryInfoStat object to MemoryInfoStat in procutil
type NumCtxSwitchesStat ¶
NumCtxSwitchesStat holds context switch metrics for a process
func ConvertFromCtxSwitches ¶
func ConvertFromCtxSwitches(s *process.NumCtxSwitchesStat) *NumCtxSwitchesStat
ConvertFromCtxSwitches converts gopsutil NumCtxSwitchesStat object to NumCtxSwitchesStat in procutil
type Option ¶
type Option func(p Probe)
Option is config options callback for system-probe
func WithBootTimeRefreshInterval ¶
WithBootTimeRefreshInterval configures the boot time refresh interval
func WithIgnoreZombieProcesses ¶
WithIgnoreZombieProcesses configures if process collection should ignore zombie processes or not
func WithPermission ¶
WithPermission configures if process collection should fetch fields that require elevated permission or not
func WithProcFSRoot ¶
WithProcFSRoot confiugres the procfs directory that the probe reads from
func WithReturnZeroPermStats ¶
WithReturnZeroPermStats configures whether StatsWithPermByPID() returns StatsWithPerm that has zero values on all fields
type Probe ¶
type Probe interface {
Close()
StatsForPIDs(pids []int32, now time.Time) (map[int32]*Stats, error)
ProcessesByPID(now time.Time, collectStats bool) (map[int32]*Process, error)
StatsWithPermByPID(pids []int32) (map[int32]*StatsWithPerm, error)
}
Probe fetches process related info on current host
func NewProcessProbe ¶
NewProcessProbe initializes a new Probe object
type Process ¶
type Process struct {
Pid int32
Ppid int32
NsPid int32 // process namespaced PID
Name string
Cwd string
Exe string
Comm string
Cmdline []string
Username string // (Windows only)
Uids []int32
Gids []int32
Language *languagemodels.Language
// ports are stored on the process because they may/should be collected by default in the future
// however, currently this data is collected by service discovery collection
PortsCollected bool
TCPPorts []uint16
UDPPorts []uint16
Stats *Stats
Service *Service
InjectionState InjectionState // APM auto-injector detection status
}
Process holds all relevant metadata and metrics for a process
func ConvertFromFilledProcess ¶
func ConvertFromFilledProcess(p *process.FilledProcess) *Process
ConvertFromFilledProcess takes a FilledProcess object and convert it into Process
func (*Process) GetCmdline ¶
func (*Process) GetCommand ¶
type Service ¶
type Service struct {
// GeneratedName is the name generated from the process info
GeneratedName string
// GeneratedNameSource indicates the source of the generated name
GeneratedNameSource string
// AdditionalGeneratedNames contains other potential names for the service
AdditionalGeneratedNames []string
// TracerMetadata contains APM tracer metadata
TracerMetadata []tracermetadata.TracerMetadata
// DDService is the value from DD_SERVICE environment variable
DDService string
// APMInstrumentation indicates the APM instrumentation status
APMInstrumentation bool
// LogFiles contains paths to log files associated with this service
LogFiles []string
}
Service holds service discovery data for a process
type Stats ¶
type Stats struct {
CreateTime int64 // milliseconds
// Status returns the process status. https://man7.org/linux/man-pages/man5/proc_pid_stat.5.html
// Supported return values:
// U: unknown state
// D: uninterruptible sleep
// R: running
// S: interruptible sleep
// T: stopped
// W: waiting (todo: potentially removable, W = paging only before Linux 2.6.0, waking Linux 2.6.33 to 3.13 only)
// Z: zombie
// The character is the same within all supported platforms.
Status string
Nice int32
OpenFdCount int32
NumThreads int32
CPUPercent *CPUPercentStat
CPUTime *CPUTimesStat
MemInfo *MemoryInfoStat
MemInfoEx *MemoryInfoExStat
IOStat *IOCountersStat
IORateStat *IOCountersRateStat
CtxSwitches *NumCtxSwitchesStat
}
Stats holds all relevant stats metrics of a process
func ConvertFilledProcessesToStats ¶
func ConvertFilledProcessesToStats(p *process.FilledProcess) *Stats
ConvertFilledProcessesToStats takes a group of FilledProcess objects and convert them into Stats
type StatsWithPerm ¶
type StatsWithPerm struct {
OpenFdCount int32
IOStat *IOCountersStat
}
StatsWithPerm is a collection of stats that require elevated permission to collect in linux