source

package
v0.0.0-...-31e8ef2 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClosableSource

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

ClosableSource wraps a pcap.Handle and gopacket.PacketSource together into one unit which can deliver packets via Packets() and expose a Close() method to cleanly shut down.

func NewPCAP

func NewPCAP(iface string, filter string) (*ClosableSource, error)

NewPCAP creates a ClosableSource with pcap configured for live capture with the appropriate filter.

func (*ClosableSource) Close

func (c *ClosableSource) Close()

Close stops the pcap handle which should in turn close the source.Packets() channel.

func (ClosableSource) Metrics

func (c ClosableSource) Metrics() []prometheus.Collector

Metrics returns a slice of prometheus.Collector items for exposing the interface and filter options via Prometheus.

func (*ClosableSource) Packets

func (c *ClosableSource) Packets() chan gopacket.Packet

Packets returns a channel of gopacket.Packets from the pcap source.

type Metrics

type Metrics struct {
	CapSource *prometheus.GaugeVec
}

Metrics contains a Prometheus metric recording a packet source descriptor and BPF filter as labels on a constant gauge.

func NewMetrics

func NewMetrics() *Metrics

NewMetrics creates a new Metrics object.

func (Metrics) List

func (m Metrics) List() []prometheus.Collector

List the items contained with a Metrics so that they can be exposed via a prometheus.Registry

Jump to

Keyboard shortcuts

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