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 PidExists(pid int) bool
- type CPUPercentStat
- type CPUTimesStat
- type DataScrubber
- type DataScrubberPattern
- type IOCountersRateStat
- type IOCountersStat
- type MemoryInfoExStat
- type MemoryInfoStat
- type NumCtxSwitchesStat
- type Option
- type Probe
- type Process
- 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
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 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 Stats *Stats }
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 Stats ¶
type Stats struct { CreateTime int64 // Status returns the process status. // Return value could be one of these. // R: Running S: Sleep T: Stop I: Idle // Z: Zombie W: Wait L: Lock // 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