collector

package
v0.2.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 6, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const SocketPath = "/tmp/lda.socket"

TODO move this to /var/run or other appropriate location based on OS, TODO /var/run has issues with permisisons os have to explore a bit more.

Variables

This section is empty.

Functions

func DeleteCommandsByDays

func DeleteCommandsByDays(days int) error

DeleteCommandsByDays deletes records older than n days

func InsertCommand

func InsertCommand(command Command) error

InsertCommand inserts a command into the database

func IsCommandAcceptable

func IsCommandAcceptable(command string, excludeRegex string) bool

IsCommandAcceptable checks if a command string matches a configured regex pattern. Commands that match the regex are considered unacceptable, and it returns false. If the regex is empty or the command does not match, it returns true.

func MapCommandToProto

func MapCommandToProto(command Command) *gen.Command

func ParseCommand

func ParseCommand(command string) string

ParseCommand extracts the command name from a command string.

Types

type AuthConfig

type AuthConfig struct {
	TeamID      string
	UserID      string
	WorkspaceID string
	UserEmail   string
}

AuthConfig contains the configuration for the command processing and authentication

type Collector

type Collector struct {
	// contains filtered or unexported fields
}

Collector collects command and system information

func NewCollector

func NewCollector(socketPath string, client *client.Client, logger zerolog.Logger, config IntervalConfig, auth AuthConfig, excludeRegex string, process process.SystemProcess) *Collector

NewCollector creates a new collector instance

func (*Collector) Collect

func (c *Collector) Collect()

Collect starts the collection of command and system information

type Command

type Command struct {
	Id            int64  `json:"id" db:"id"`
	Category      string `json:"category" db:"category"`
	Command       string `json:"command" db:"command"`
	User          string `json:"user" db:"user"`
	Directory     string `json:"directory" db:"directory"`
	ExecutionTime int64  `json:"execution_time" db:"execution_time"`
	StartTime     int64  `json:"start_time" db:"start_time"`
	EndTime       int64  `json:"end_time" db:"end_time"`
	Status        string `json:"status" db:"status"`
	Result        string `json:"result" db:"result"`
	Repository    string `json:"repository" db:"repository"`
}

Command is the model for command

func GetAllCommandsForCategoryForPeriod

func GetAllCommandsForCategoryForPeriod(category string, start int64, end int64) ([]Command, error)

GetAllCommandsForCategoryForPeriod fetches all commands for a given category and period

func GetAllCommandsForPeriod

func GetAllCommandsForPeriod(start int64, end int64) ([]*Command, error)

GetAllCommandsForPeriod fetches all commands for a given period

func GetCommandById

func GetCommandById(id int64) (*Command, error)

GetCommandById fetches a command by its ID

type IntervalConfig

type IntervalConfig struct {
	ProcessInterval           time.Duration
	CommandInterval           time.Duration
	CommandIntervalMultiplier float64
	MaxConcurrentCommands     int
	MaxDuration               time.Duration
}

IntervalConfig contains the configuration for the collection intervals

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL