process

package
v0.0.8 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	PsutilType = "psutil"
	PsType     = "ps"
)

Variables

This section is empty.

Functions

func DeleteProcessesByDays

func DeleteProcessesByDays(days int) error

DeleteProcessesByDays deletes records older than n days

func GetTopProcessesAndMetrics

func GetTopProcessesAndMetrics(start int64, end int64) (map[int64][]*Process, error)

GetTopProcessesAndMetrics fetches the top processes based on a criterion like average CPU usage, and then fetches detailed time-series data for each top process.

func InsertProcesses

func InsertProcesses(processes []Process) error

InsertProcesses inserts multiple processes into the database in bulk

func MapProcessToProto

func MapProcessToProto(process Process) *gen.Process

Types

type Factory

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

Factory implementation for proc providers

func NewFactory

func NewFactory(logger zerolog.Logger) *Factory

NewFactory init Factory implementation for proc providers

func (*Factory) Create

func (f *Factory) Create(pType string) (SystemProcess, error)

Create creates a new system process collector from the factory

type Process

type Process struct {
	Id   int64  `json:"id" db:"id"`
	PID  int64  `json:"pid" db:"pid"`
	PPID int64  `json:"ppid" db:"ppid"`
	Name string `json:"name" db:"name"`
	// R: Running; S: Sleep; T: Stop; I: Idle; Z: Zombie; W: Wait; L: Lock;
	Status         string  `json:"status" db:"status"`
	CreatedTime    int64   `json:"created_time" db:"created_time"`
	StoredTime     int64   `json:"stored_time" db:"stored_time"`
	OS             string  `json:"os" db:"os"`
	Platform       string  `json:"platform" db:"platform"`
	PlatformFamily string  `json:"platform_family" db:"platform_family"`
	CPUUsage       float64 `json:"cpu_usage" db:"cpu_usage"`
	MemoryUsage    float64 `json:"memory_usage" db:"memory_usage"`
}

Process is the model for process

func GetAllProcessesForPeriod

func GetAllProcessesForPeriod(start int64, end int64) ([]*Process, error)

GetAllProcessesForPeriod fetches all processes for a given period

type Ps

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

Ps is the type for the ps process collector

func NewPs

func NewPs(logger zerolog.Logger) *Ps

NewPs creates a new Ps instance

func (*Ps) Collect

func (p *Ps) Collect() ([]Process, error)

Collect collects the process information using the ps command

type Psutil

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

Psutil is the type for the psutil process collector

func NewPsutil

func NewPsutil(logger zerolog.Logger) *Psutil

NewPsutil creates a new Psutil instance

func (*Psutil) Collect

func (p *Psutil) Collect() ([]Process, error)

Collect collects the process information using the psutil library

type SystemProcess

type SystemProcess interface {
	Collect() ([]Process, error)
}

SystemProcess interface for process collection

Jump to

Keyboard shortcuts

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