core

package
v2.20.0 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2022 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MessageQueueSize = 100
	MaxPlugins       = 100
)
View Source
const (
	UNKNOWN                              = "unknown"
	RegistrationPrefix                   = "registration."
	RegistrationCompletedTopic           = RegistrationPrefix + "completed"
	RegisterWithDataplaneSoftwareDetails = RegistrationPrefix + "with.dataplane.software.details"
	CommNginxConfig                      = "nginx.config"
	NginxConfigUpload                    = "nginx.config.upload"
	NginxReload                          = "nginx.reload"
	NginxReloadComplete                  = "nginx.reload.complete"
	NginxStart                           = "nginx.start"
	NginxStop                            = "nginx.stop"
	NginxPluginConfigured                = "nginx.plugin.config"
	NginxStatusAPIUpdate                 = "nginx.status.api.update"
	NginxInstancesFound                  = "nginx.instances.found"
	NginxMasterProcCreated               = "nginx.master.created"
	NginxMasterProcKilled                = "nginx.master.killed"
	NginxWorkerProcCreated               = "nginx.worker.created"
	NginxWorkerProcKilled                = "nginx.worker.killed"
	NginxDetailProcUpdate                = "nginx.proc.update"
	NginxConfigValidationPending         = "nginx.config.validation.pending"
	NginxConfigValidationFailed          = "nginx.config.validation.failed"
	NginxConfigValidationSucceeded       = "nginx.config.validation.succeeded"
	NginxConfigApplyFailed               = "nginx.config.apply.failed"
	NginxConfigApplySucceeded            = "nginx.config.apply.succeeded"
	CommPrefix                           = "comms."
	CommStatus                           = CommPrefix + "status"
	CommMetrics                          = CommPrefix + "metrics"
	CommRegister                         = CommPrefix + "register"
	CommResponse                         = CommPrefix + "response"
	AgentStarted                         = "agent.started"
	AgentConnected                       = "agent.connected"
	AgentConfig                          = "agent.config"
	AgentConfigChanged                   = "agent.config.changed"
	AgentCollectorsUpdate                = "agent.collectors.update"
	MetricReport                         = "metrics.report"
	LoggerPrefix                         = "logger."
	LoggerLevel                          = LoggerPrefix + "level"
	LoggerPath                           = LoggerPrefix + "path"
	DataplaneChanged                     = "dataplane.changed"
	DataplaneFilesChanged                = "dataplane.fileschanged"
	Events                               = "events"
	FileWatcherEnabled                   = "file.watcher.enabled"
	ConfigRollbackResponse               = "config.rollback.response"
	DataplaneSoftwareDetailsUpdated      = "dataplane.software.details.updated"
	EnableExtension                      = "enable.extension"
)

Variables

This section is empty.

Functions

func AccessLogs

func AccessLogs(p *proto.NginxConfig) map[string]string

AccessLogs returns a list of access logs in the config

func CheckForProcesses

func CheckForProcesses(processesToCheck []string) ([]string, error)

CheckForProcesses takes in a slice of strings that represents the process names to check for then returns a slice of strings of the processes that were checked for and NOT found.

func ErrorLogs

func ErrorLogs(p *proto.NginxConfig) map[string]string

ErrorLogs returns a list of error logs in the config

func FileExists

func FileExists(filePath string) (bool, error)

FileExists determines if the specified file given by the file path exists on the system. If the file does NOT exist on the system the bool will be false and the error will be nil, if the error is not nil then it's possible the file might exist but an error verifying it's existence has occurred.

func FilesExists

func FilesExists(filePaths []string) (bool, error)

FilesExists determines if the specified set of files exists on the system. If any of the files do NOT exist on the system the bool will be false and the error will be nil, if the error is not nil then it's possible the files might exist but an error verifying their existence has occurred.

func GenerateNginxID

func GenerateNginxID(format string, a ...interface{}) string

GenerateNginxID used to get the NGINX ID

func SliceContainsString

func SliceContainsString(slice []string, toFind string) (bool, int)

SliceContainsString takes in a slice of strings and a string to check for within the supplied slice of strings, then returns a bool indicating if the the specified string was found and the index where it was found. If the specified string was not found then the index returned is -1.

func ValidateMessages

func ValidateMessages(t *testing.T, messagePipe *MockMessagePipe, msgTopics []string)

Types

type ConfigApplyMarker

type ConfigApplyMarker interface {
	MarkAndSave(string) error
	RemoveFromNotExists(string)
}

type Environment

type Environment interface {
	NewHostInfo(agentVersion string, tags *[]string, configDirs string, clearCache bool) *proto.HostInfo
	GetHostname() (hostname string)
	GetSystemUUID() (hostId string)
	ReadDirectory(dir string, ext string) ([]string, error)
	WriteFiles(backup ConfigApplyMarker, files []*proto.File, prefix string, allowedDirs map[string]struct{}) error
	Processes() (result []Process)
	FileStat(path string) (os.FileInfo, error)
	DiskDevices() ([]string, error)
	GetContainerID() (string, error)
	GetNetOverflow() (float64, error)
	IsContainer() bool
}

type EnvironmentType

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

func (*EnvironmentType) DiskDevices

func (env *EnvironmentType) DiskDevices() ([]string, error)

DiskDevices returns a list of Disk Devices known by the system. Loop and other virtual devices are filtered out

func (*EnvironmentType) FileStat

func (env *EnvironmentType) FileStat(path string) (os.FileInfo, error)

func (*EnvironmentType) GetContainerID

func (env *EnvironmentType) GetContainerID() (string, error)

GetContainerID returns the ID of the current environment if running in a container

func (*EnvironmentType) GetHostname

func (env *EnvironmentType) GetHostname() string

func (*EnvironmentType) GetNetOverflow

func (env *EnvironmentType) GetNetOverflow() (float64, error)

func (*EnvironmentType) GetSystemUUID

func (env *EnvironmentType) GetSystemUUID() string

func (*EnvironmentType) IsContainer

func (env *EnvironmentType) IsContainer() bool

func (*EnvironmentType) NewHostInfo

func (env *EnvironmentType) NewHostInfo(agentVersion string, tags *[]string, configDirs string, clearCache bool) *proto.HostInfo

func (*EnvironmentType) Processes

func (env *EnvironmentType) Processes() (result []Process)

Processes returns a slice of nginx master and nginx worker processes currently running

func (*EnvironmentType) ReadDirectory

func (env *EnvironmentType) ReadDirectory(dir string, ext string) ([]string, error)

func (*EnvironmentType) WriteFiles

func (env *EnvironmentType) WriteFiles(backup ConfigApplyMarker, files []*proto.File, confPath string, allowedDirs map[string]struct{}) error

type Info

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

func NewInfo

func NewInfo(name string, version string) *Info

func (*Info) Name

func (info *Info) Name() string

func (*Info) Version

func (info *Info) Version() string

type Message

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

func NewMessage

func NewMessage(topic string, data Payload) *Message

func (*Message) Data

func (m *Message) Data() Payload

func (*Message) Exact

func (m *Message) Exact(topic string) bool

func (*Message) Match

func (m *Message) Match(topic string) bool

func (*Message) Topic

func (m *Message) Topic() string

type MessagePipe

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

func NewMessagePipe

func NewMessagePipe(ctx context.Context) *MessagePipe

func (*MessagePipe) Cancel

func (p *MessagePipe) Cancel() context.CancelFunc

func (*MessagePipe) Context

func (p *MessagePipe) Context() context.Context

func (*MessagePipe) GetPlugins

func (p *MessagePipe) GetPlugins() []Plugin

func (*MessagePipe) Process

func (p *MessagePipe) Process(messages ...*Message)

func (*MessagePipe) Register

func (p *MessagePipe) Register(size int, plugins ...Plugin) error

func (*MessagePipe) Run

func (p *MessagePipe) Run()

type MessagePipeInterface

type MessagePipeInterface interface {
	Register(int, ...Plugin) error
	Process(...*Message)
	Run()
	Context() context.Context
	GetPlugins() []Plugin
}

type MockMessagePipe

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

MockMessagePipe is a mock message pipe

func NewMockMessagePipe

func NewMockMessagePipe(ctx context.Context) *MockMessagePipe

func SetupMockMessagePipe

func SetupMockMessagePipe(t *testing.T, ctx context.Context, plugin ...Plugin) *MockMessagePipe

func (*MockMessagePipe) ClearMessages

func (p *MockMessagePipe) ClearMessages()

func (*MockMessagePipe) Context

func (p *MockMessagePipe) Context() context.Context

func (*MockMessagePipe) GetMessages

func (p *MockMessagePipe) GetMessages() []*Message

func (*MockMessagePipe) GetPlugins

func (p *MockMessagePipe) GetPlugins() []Plugin

func (*MockMessagePipe) GetProcessedMessages

func (p *MockMessagePipe) GetProcessedMessages() []*Message

func (*MockMessagePipe) Process

func (p *MockMessagePipe) Process(msgs ...*Message)

func (*MockMessagePipe) Register

func (p *MockMessagePipe) Register(size int, plugin ...Plugin) error

func (*MockMessagePipe) Run

func (p *MockMessagePipe) Run()

func (*MockMessagePipe) RunWithoutInit

func (p *MockMessagePipe) RunWithoutInit()

type NginxBinary

type NginxBinary interface {
	Start(nginxId, bin string) error
	Stop(processId, bin string) error
	Reload(processId, bin string) error
	ValidateConfig(processId, bin, configLocation string, config *proto.NginxConfig, configApply *sdk.ConfigApply) error
	GetNginxDetailsFromProcess(nginxProcess Process) *proto.NginxDetails
	GetNginxDetailsByID(nginxID string) *proto.NginxDetails
	GetNginxIDForProcess(nginxProcess Process) string
	GetNginxDetailsMapFromProcesses(nginxProcesses []Process) map[string]*proto.NginxDetails
	UpdateNginxDetailsFromProcesses(nginxProcesses []Process)
	WriteConfig(config *proto.NginxConfig) (*sdk.ConfigApply, error)
	ReadConfig(path, nginxId, systemId string) (*proto.NginxConfig, error)
	UpdateLogs(existingLogs map[string]string, newLogs map[string]string) bool
	GetAccessLogs() map[string]string
	GetErrorLogs() map[string]string
	GetChildProcesses() map[string][]*proto.NginxDetails
}

type NginxBinaryType

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

func NewNginxBinary

func NewNginxBinary(env Environment, config *config.Config) *NginxBinaryType

func (*NginxBinaryType) GetAccessLogs added in v2.20.0

func (n *NginxBinaryType) GetAccessLogs() map[string]string

func (*NginxBinaryType) GetChildProcesses

func (n *NginxBinaryType) GetChildProcesses() map[string][]*proto.NginxDetails

func (*NginxBinaryType) GetErrorLogs added in v2.20.0

func (n *NginxBinaryType) GetErrorLogs() map[string]string

func (*NginxBinaryType) GetNginxDetailsByID

func (n *NginxBinaryType) GetNginxDetailsByID(nginxID string) *proto.NginxDetails

func (*NginxBinaryType) GetNginxDetailsFromProcess

func (n *NginxBinaryType) GetNginxDetailsFromProcess(nginxProcess Process) *proto.NginxDetails

func (*NginxBinaryType) GetNginxDetailsMapFromProcesses

func (n *NginxBinaryType) GetNginxDetailsMapFromProcesses(nginxProcesses []Process) map[string]*proto.NginxDetails

func (*NginxBinaryType) GetNginxIDForProcess

func (n *NginxBinaryType) GetNginxIDForProcess(nginxProcess Process) string

func (*NginxBinaryType) ReadConfig

func (n *NginxBinaryType) ReadConfig(confFile, nginxId, systemId string) (*proto.NginxConfig, error)

func (*NginxBinaryType) Reload

func (n *NginxBinaryType) Reload(processId, bin string) error

Reload NGINX.

func (*NginxBinaryType) SkipLog

func (n *NginxBinaryType) SkipLog(filename string) bool

SkipLog checks if a logfile should be omitted from analysis

func (*NginxBinaryType) Start

func (n *NginxBinaryType) Start(nginxId, bin string) error

Start starts NGINX.

func (*NginxBinaryType) Stop

func (n *NginxBinaryType) Stop(processId, bin string) error

Stop stops an instance of NGINX.

func (*NginxBinaryType) UpdateLogs

func (n *NginxBinaryType) UpdateLogs(existingLogs map[string]string, newLogs map[string]string) bool

func (*NginxBinaryType) UpdateNginxDetailsFromProcesses

func (n *NginxBinaryType) UpdateNginxDetailsFromProcesses(nginxProcesses []Process)

func (*NginxBinaryType) ValidateConfig

func (n *NginxBinaryType) ValidateConfig(processId, bin, configLocation string, config *proto.NginxConfig, configApply *sdk.ConfigApply) error

ValidateConfig tests the config with nginx -t -c configLocation.

func (*NginxBinaryType) WriteConfig

func (n *NginxBinaryType) WriteConfig(config *proto.NginxConfig) (*sdk.ConfigApply, error)

type Payload

type Payload interface {
}

type Plugin

type Plugin interface {
	Init(MessagePipeInterface)
	Close()
	Process(*Message)
	Info() *Info
	Subscriptions() []string
}

type Process

type Process struct {
	Pid        int32
	Name       string
	CreateTime int64
	Status     string
	IsRunning  bool
	IsMaster   bool
	Path       string
	User       string
	ParentPid  int32
	Command    string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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