Documentation
¶
Overview ¶
Package procscanner provides a shared process scanner for monitoring multiple types of processes with a single /proc scan.
Index ¶
Constants ¶
const ( // DefaultPollInterval is the default polling interval for process scanning. DefaultPollInterval = 2 * time.Second )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AndMatcher ¶
type AndMatcher struct {
// contains filtered or unexported fields
}
AndMatcher combines multiple matchers with AND logic.
func NewAndMatcher ¶
func NewAndMatcher(matchers ...Matcher) *AndMatcher
NewAndMatcher creates a matcher that requires all sub-matchers to match.
func (*AndMatcher) Match ¶
func (m *AndMatcher) Match(proc ProcessInfo) bool
Match returns true if all sub-matchers match.
type Callbacks ¶
type Callbacks struct {
// OnStart is called when a matching process is detected.
OnStart func(proc ProcessInfo)
// OnStop is called when a tracked process exits.
OnStop func(pid int)
}
Callbacks contains the callbacks for process lifecycle events.
type CmdlineContainsMatcher ¶
type CmdlineContainsMatcher struct {
// contains filtered or unexported fields
}
CmdlineContainsMatcher matches processes whose cmdline contains a substring.
func NewCmdlineContainsMatcher ¶
func NewCmdlineContainsMatcher(substring string) *CmdlineContainsMatcher
NewCmdlineContainsMatcher creates a matcher that checks if cmdline contains a substring.
func (*CmdlineContainsMatcher) Match ¶
func (m *CmdlineContainsMatcher) Match(proc ProcessInfo) bool
Match returns true if the process cmdline contains the substring.
type CommMatcher ¶
type CommMatcher struct {
// contains filtered or unexported fields
}
CommMatcher matches processes by their comm name (case-insensitive).
func NewCommMatcher ¶
func NewCommMatcher(names []string) *CommMatcher
NewCommMatcher creates a matcher that matches any of the given process names.
func (*CommMatcher) Match ¶
func (m *CommMatcher) Match(proc ProcessInfo) bool
Match returns true if the process comm matches any registered name.
type ExactCommMatcher ¶
type ExactCommMatcher struct {
// contains filtered or unexported fields
}
ExactCommMatcher matches processes by exact comm name (case-sensitive).
func NewExactCommMatcher ¶
func NewExactCommMatcher(name string) *ExactCommMatcher
NewExactCommMatcher creates a matcher for an exact process name.
func (*ExactCommMatcher) Match ¶
func (m *ExactCommMatcher) Match(proc ProcessInfo) bool
Match returns true if the process comm exactly matches.
type Matcher ¶
type Matcher interface {
// Match returns true if this process should be tracked.
Match(proc ProcessInfo) bool
}
Matcher determines if a process should be tracked.
type MatcherFunc ¶
type MatcherFunc func(proc ProcessInfo) bool
MatcherFunc is a function adapter for Matcher interface.
func (MatcherFunc) Match ¶
func (f MatcherFunc) Match(proc ProcessInfo) bool
Match implements Matcher.
type Option ¶
type Option func(*Scanner)
Option configures a Scanner.
func WithPollInterval ¶
WithPollInterval sets the polling interval for process scanning.
func WithProcPath ¶
WithProcPath sets a custom /proc path (for testing).
type OrMatcher ¶
type OrMatcher struct {
// contains filtered or unexported fields
}
OrMatcher combines multiple matchers with OR logic.
func NewOrMatcher ¶
NewOrMatcher creates a matcher that requires any sub-matcher to match.
func (*OrMatcher) Match ¶
func (m *OrMatcher) Match(proc ProcessInfo) bool
Match returns true if any sub-matcher matches.
type ProcessInfo ¶
ProcessInfo contains information about a running process.
type Scanner ¶
type Scanner struct {
// contains filtered or unexported fields
}
Scanner monitors /proc for processes and notifies registered watchers.
func (*Scanner) Stop ¶
func (s *Scanner) Stop()
Stop stops the scanner and waits for goroutines to finish.