agent

package
v0.0.0-...-c34bea4 Latest Latest
Warning

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

Go to latest
Published: May 20, 2022 License: Apache-2.0 Imports: 25 Imported by: 0

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

func NewAgent(ctx context.Context) *Agent

NewAgent starts a new monitor agent instance which distributes monitor events to registered listeners. Once the datapath is set up, AttachToEventsMap needs to be called to receive events from the perf ring buffer. Otherwise, only user space events received via SendEvent are distributed registered listeners. Internally, the agent 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) AttachToEventsMap

func (a *Agent) AttachToEventsMap(nPages int) error

AttachToEventsMap opens the events perf ring buffer and makes it ready for consumption, such that any subscribed consumers may receive events from it. This function is to be called once the events map has been set up.

func (*Agent) Context

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