agent

package
v1.9.4 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2021 License: Apache-2.0 Imports: 24 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ServeMonitorAPI

func ServeMonitorAPI(monitor *Agent) error

ServeMonitorAPI serves the Cilium 1.2 monitor API on a unix domain socket. This method starts the server in the background. The server is stopped when monitor.Context() is cancelled. Each incoming connection registers a new listener on monitor.

Types

type Agent

type Agent struct {
	lock.Mutex
	models.MonitorStatus
	// contains filtered or unexported fields
}

Agent structure for centralizing the responsibilities of the main events reader. There is some racey-ness around perfReaderCancel since it replaces on every perf reader start. In the event that a MonitorListener from a previous generation calls its cleanup after the start of the new perf reader, we might call the new, and incorrect, cancel function. We guard for this by checking the number of listeners during the cleanup call. The perf reader must have at least one MonitorListener (since it started) so no cancel is called. If it doesn't, the cancel is the correct behavior (the older generation cancel must have been called for us to get this far anyway).

func NewAgent added in v1.6.0

func NewAgent(ctx context.Context, nPages int) (a *Agent, err error)

NewAgent starts a new monitor agent instance which distributes monitor events to registered listeners. It spawns a singleton goroutine reading events from the BPF perf ring buffer and provides an interface to pass in non-BPF events. The instance can be stopped by cancelling ctx, which will stop the perf reader go routine and close all registered listeners. Note that the perf buffer reader is started only when listeners are connected.

func (*Agent) Context added in v1.9.0

func (a *Agent) Context() context.Context

Context returns the underlying context of this monitor instance. It can be used to derive other contexts which should be stopped when the monitor is stopped.

func (*Agent) RegisterNewConsumer

func (a *Agent) RegisterNewConsumer(newConsumer consumer.MonitorConsumer)

RegisterNewConsumer adds the new MonitorConsumer to the global list. It also spawns a singleton goroutine to read and distribute the events.

func (*Agent) RegisterNewListener

func (a *Agent) RegisterNewListener(newListener listener.MonitorListener)

RegisterNewListener adds the new MonitorListener to the global list. It also spawns a singleton goroutine to read and distribute the events.

func (*Agent) RemoveConsumer

func (a *Agent) RemoveConsumer(mc consumer.MonitorConsumer)

RemoveConsumer deletes the MonitorConsumer from the list, closes its queue, and stops perfReader if this is the last subscriber

func (*Agent) RemoveListener

func (a *Agent) RemoveListener(ml listener.MonitorListener)

RemoveListener deletes the MonitorListener from the list, closes its queue, and stops perfReader if this is the last subscriber

func (*Agent) SendEvent

func (a *Agent) SendEvent(typ int, event interface{}) error

SendEvent distributes an event to all monitor listeners

func (*Agent) State

func (a *Agent) State() *models.MonitorStatus

State returns the current status of the monitor

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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