Documentation ¶
Index ¶
- type History
- type Metrics
- type Monitor
- func (p *Monitor) AddTarget(key string, addr net.IPAddr) (err error)
- func (p *Monitor) AddTargetDelayed(key string, addr net.IPAddr, startupDelay time.Duration) (err error)
- func (p *Monitor) Export() map[string]*Metrics
- func (p *Monitor) ExportAndClear() map[string]*Metrics
- func (p *Monitor) RemoveTarget(key string)
- func (p *Monitor) Stop()
- type Result
- type Target
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type History ¶
History represents the ping history for a single node/device.
func NewHistory ¶
NewHistory creates a new History object with a specific capacity
func (*History) ComputeAndClear ¶
ComputeAndClear aggregates the result history into a single data point and clears the result set.
type Metrics ¶
type Metrics struct { PacketsSent int // number of packets sent PacketsLost int // number of packets lost Best float32 // best rtt in ms Worst float32 // worst rtt in ms Median float32 // median rtt in ms Mean float32 // mean rtt in ms StdDev float32 // std deviation in ms }
Metrics is a dumb data point computed from a history of Results.
type Monitor ¶
type Monitor struct { HistorySize int // Number of results per target to keep // contains filtered or unexported fields }
Monitor manages the goroutines responsible for collecting Ping RTT data.
func New ¶
New creates and configures a new Ping instance. You need to call AddTarget()/RemoveTarget() to manage monitored targets.
func (*Monitor) AddTarget ¶
AddTarget adds a target to the monitored list. If the target with the given ID already exists, it is removed first and then readded. This allows the easy restart of the monitoring.
func (*Monitor) AddTargetDelayed ¶
func (p *Monitor) AddTargetDelayed(key string, addr net.IPAddr, startupDelay time.Duration) (err error)
AddTargetDelayed is AddTarget with a startup delay
func (*Monitor) Export ¶
Export calculates the metrics for each monitored target and returns it as a simple map.
func (*Monitor) ExportAndClear ¶
ExportAndClear calculates the metrics for each monitored target, cleans the result set and returns it as a simple map.
func (*Monitor) RemoveTarget ¶
RemoveTarget removes a target from the monitoring list.
type Result ¶
Result stores the information about a single ping, in particular the round-trip time or whether the packet was lost.