service

package
v0.0.0-...-7a5fecb Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultAnomalyDetectInterval is the default interval to detect anomaly.
	DefaultAnomalyDetectInterval = 30 * time.Second

	// DefaultThreshold is the default threshold to detect anomaly.
	DefaultThreshold = 1.5

	// DefaultSuspendTimes is the default times to suspend when dump trace file.
	DefaultSuspendTimes = 10
)
View Source
const (
	DefaultTimeout       = 30
	DefaultTraceFilePath = "./trace"
)
View Source
const (
	PendingState = "pending"
	RunningState = "running"
)
View Source
const (
	DefaultAlpha = 0.3
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Collector

type Collector func() map[string]interface{}

type Connection

type Connection struct {
	SourceIP   string `json:"sourceIP"`
	SourcePort int    `json:"sourcePort"`
	DestIP     string `json:"destIP"`
	DestPort   int    `json:"destPort"`
	State      string `json:"state"`
}

Connection is the information of a connection.

type EMA

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

EMA is the Exponential Moving Average.

func NewEMA

func NewEMA(alpha, thread float64) *EMA

NewEMA creates an EMA.

func (*EMA) IsAnomaly

func (e *EMA) IsAnomaly(value EMAValue) bool

IsAnomaly returns if the value is anomaly.

func (*EMA) Update

func (e *EMA) Update(value EMAValue)

Update updates the EMA.

func (*EMA) Value

func (e *EMA) Value() EMAValue

Value returns the value of EMA.

type EMAValue

type EMAValue struct {
	CPUPercent    float64 `json:"cpu_percent"`
	MemoryPercent float64 `json:"memory_percent"`
	Connections   float64 `json:"connections"`
}

type ProcessInfo

type ProcessInfo struct {
	Name       string   `json:"name"`
	PID        int      `json:"pid"`
	Ppid       int32    `json:"ppid"`
	Cmd        string   `json:"cmd"`
	Pwd        string   `json:"pwd"`
	Envs       []string `json:"envs"`
	NumFDs     int32    `json:"numFDs"`
	NumThreads int32    `json:"numThreads"`
	UserName   string   `json:"userName"`
	Path       string   `json:"path"`
	GoVersion  string   `json:"goVersion"`
}

ProcessInfo is the information of a process.

type ProcessTask

type ProcessTask struct {
	Command   *exec.Cmd `json:"-"`
	FilePath  string    `json:"-"`
	StartTime time.Time `json:"startTime"`
	Port      int       `json:"-"`
	PID       int       `json:"-"`
	FileName  string    `json:"fileName"`
	State     string    `json:"state"`
}

type Service

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

Service is the service.

func NewService

func NewService(config *ServiceConfig) *Service

NewService creates a service.

func (*Service) Close

func (s *Service) Close()

func (*Service) DeleteProfile

func (s *Service) DeleteProfile(ctx echo.Context) error

func (*Service) GetConnections

func (s *Service) GetConnections(ctx echo.Context) error

func (*Service) GetCustomMetrics

func (s *Service) GetCustomMetrics(ctx echo.Context) error

func (*Service) GetOpenFiles

func (s *Service) GetOpenFiles(ctx echo.Context) error

func (*Service) GetProcessInfo

func (s *Service) GetProcessInfo(ctx echo.Context) error

func (*Service) GetProfile

func (s *Service) GetProfile(ctx echo.Context) error

func (*Service) GetProfileList

func (s *Service) GetProfileList(ctx echo.Context) error

func (*Service) GetUsage

func (s *Service) GetUsage(ctx echo.Context) error

func (*Service) Register

func (s *Service) Register(name string, collector Collector)

func (*Service) StartProfile

func (s *Service) StartProfile(ctx echo.Context) error

func (*Service) StopProfile

func (s *Service) StopProfile(ctx echo.Context) error

func (*Service) TraceReverseProxy

func (s *Service) TraceReverseProxy(ctx echo.Context) error

func (*Service) Unregister

func (s *Service) Unregister(name string)

type ServiceConfig

type ServiceConfig struct {
	ProcessID   int  `yaml:"processID" json:"processID"`
	Persist     bool `yaml:"persist" json:"persist"`
	ServicePort int
}

ServiceConfig is the configuration for service.

Jump to

Keyboard shortcuts

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