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 (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