Documentation ¶
Index ¶
- func ServeMonitorAPI(monitor *Agent) error
- type Agent
- func (a *Agent) AttachToEventsMap(nPages int) error
- func (a *Agent) Context() context.Context
- func (a *Agent) RegisterNewConsumer(newConsumer consumer.MonitorConsumer)
- func (a *Agent) RegisterNewListener(newListener listener.MonitorListener)
- func (a *Agent) RemoveConsumer(mc consumer.MonitorConsumer)
- func (a *Agent) RemoveListener(ml listener.MonitorListener)
- func (a *Agent) SendEvent(typ int, event interface{}) error
- func (a *Agent) State() *models.MonitorStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ServeMonitorAPI ¶
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
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 ¶
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 ¶ added in v1.9.0
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) State ¶
func (a *Agent) State() *models.MonitorStatus
State returns the current status of the monitor