agent

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2017 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MIN_LOG_LEVEL = proto.LOG_ERROR
	MAX_LOG_LEVEL = proto.LOG_DEBUG
)
View Source
const LOG_BUF_SIZE = 10

Variables

This section is empty.

Functions

func SaveLog

func SaveLog(wsConn ws.Connector, agentId uint, tickChan <-chan time.Time, logHandler *LogHandler, stats *stats.Stats) error

Types

type ByTs

type ByTs []proto.LogEntry

func (ByTs) Len

func (s ByTs) Len() int

func (ByTs) Less

func (s ByTs) Less(i, j int) bool

func (ByTs) Swap

func (s ByTs) Swap(i, j int)

type DbHandler

type DbHandler interface {
	Create(agent proto.Agent) (string, error)
	Get(uuid string) (uint, *proto.Agent, error)
	GetAll() ([]proto.Agent, error)
	SetConfig(agentId uint, service, otheUUID string, set, running []byte) error
	RemoveConfig(agentId uint, service, otherUUID string) error
	Update(agentId uint, agent proto.Agent) error
	UpdateConfigs(agentId uint, configs []proto.AgentConfig, reset bool) error
	UpdateVersion(agentId uint, version proto.Version) error
}

type LocalAgent

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

A LocalAgent is a Communicator for an agent connected to this API. It uses a ws.Multiplexer to serialize commands to and replies from the agent. The comm processor updates oN tables as necessary. This allows processes (controllers, services, etc.) in this API to communicate with this agent. A LocalAgent should only be created in the agent comm websocket controller, which registers it with the LocalDirectory.

func NewLocalAgent

func NewLocalAgent(agentId uint, mx ws.Multiplexer) *LocalAgent

func (*LocalAgent) Done

func (a *LocalAgent) Done() chan bool

func (*LocalAgent) IsAlive

func (a *LocalAgent) IsAlive() bool

func (*LocalAgent) Send

func (a *LocalAgent) Send(cmd *proto.Cmd) (*proto.Reply, error)

func (*LocalAgent) Start

func (a *LocalAgent) Start() error

func (*LocalAgent) Stop

func (a *LocalAgent) Stop()

type LocalDirectory

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

func NewLocalDirectory

func NewLocalDirectory() *LocalDirectory

func (*LocalDirectory) Add

func (d *LocalDirectory) Add(agentId uint, comm shared.AgentCommunicator) error

Used by agent comm controller to register local agent

func (*LocalDirectory) Get

func (d *LocalDirectory) Get(agentId uint) shared.AgentCommunicator

func (*LocalDirectory) Refresh

func (d *LocalDirectory) Refresh(timeLimit time.Duration)

func (*LocalDirectory) Remove

func (d *LocalDirectory) Remove(agentId uint)

Used by agent comm controller to unregister local agent.

type LogFilter

type LogFilter struct {
	Begin       time.Time
	End         time.Time
	MinLevel    byte // inclusive
	MaxLevel    byte // inclusive
	ServiceLike string
}

type LogHandler

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

func NewLogHandler

func NewLogHandler(dbm db.Manager, stats *stats.Stats) *LogHandler

func (*LogHandler) GetLog

func (lh *LogHandler) GetLog(agentId uint, f LogFilter) ([]proto.LogEntry, error)

func (*LogHandler) WriteLog

func (lh *LogHandler) WriteLog(agentId uint, logEntries []proto.LogEntry) error

type MySQLHandler

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

func NewMySQLHandler

func NewMySQLHandler(dbm db.Manager, ih instance.DbHandler) *MySQLHandler

func (*MySQLHandler) Create

func (h *MySQLHandler) Create(agent proto.Agent) (string, error)

func (*MySQLHandler) Get

func (h *MySQLHandler) Get(uuid string) (uint, *proto.Agent, error)

func (*MySQLHandler) GetAll

func (h *MySQLHandler) GetAll() ([]proto.Agent, error)

func (*MySQLHandler) GetConfigs

func (h *MySQLHandler) GetConfigs(agentId uint) ([]proto.AgentConfig, error)

func (*MySQLHandler) RemoveConfig

func (h *MySQLHandler) RemoveConfig(agentId uint, service, otherUUID string) error

func (*MySQLHandler) SetConfig

func (h *MySQLHandler) SetConfig(agentId uint, service, otherUUID string, set, running []byte) error

func (*MySQLHandler) Update

func (h *MySQLHandler) Update(agentId uint, agent proto.Agent) error

func (*MySQLHandler) UpdateConfigs

func (h *MySQLHandler) UpdateConfigs(agentId uint, configs []proto.AgentConfig, reset bool) error

func (*MySQLHandler) UpdateVersion

func (h *MySQLHandler) UpdateVersion(agentId uint, version proto.Version) error

type Processor

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

A Processor updates oN tables for certain commands and replies. It is per-agent and NOT concurrent[1], so cmds is not guarded with a mutex, because cmds to agent must be serialized (including cmd=Status; agent parallelizes these internally).

[1] Be sure ws.NewConcurrentMultiplexer(..., concurrency=0) in NewLocalAgent()!

Else the multiplexer will call AfterRecv() concurrently.

func NewProcessor

func NewProcessor(agentId uint, dbh DbHandler) *Processor

func (*Processor) AfterRecv

func (p *Processor) AfterRecv(bytes []byte) (string, interface{}, error)

func (*Processor) BeforeSend

func (p *Processor) BeforeSend(data interface{}) (string, []byte, error)

func (*Processor) Timeout

func (p *Processor) Timeout(id string)

Jump to

Keyboard shortcuts

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