pinger

package module
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: MIT Imports: 10 Imported by: 0

README

pinger

Go package for pinging multiple hosts

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrHostExists = errors.New("host already exists")
View Source
var ErrHostNotExist = errors.New("host does not exist")

Functions

This section is empty.

Types

type Host

type Host struct {
	Address         string
	IsUp            bool
	UpDown          int // >1 up <-1 down 0=unknown
	PacketsSent     int
	PacketsReceived int
	Changes         int           // number of up->down or down->up transitions
	UpTime          time.Duration // total amount of time host has been up
	DownTime        time.Duration // total amount of time host has been down
	Interval        time.Duration // time between pings
	MaxRTT          time.Duration // rtt greater than this value will declare a host down
	Timeout         time.Duration // wait this long at most for a pong
	LastRTT         time.Duration // latest RTT value
	Stats           f64stat.Stat  // RTT stats.  min/ave/max/sdev
	C               chan string   // channel to send command to the pinger go routine

	//ltDown           time.Time     // time of start of last DOWN
	//downCount       int           // number of missed pongs
	DownThreshold int    // number of missed pongs to declare host down
	History       []*Rtt // RTT and message history
	HistoryMax    int    // Maximum size of history
	// contains filtered or unexported fields
}

func (*Host) Close

func (h *Host) Close()

func (*Host) Command

func (h *Host) Command(cmd string)

func (*Host) Pause

func (h *Host) Pause()

func (*Host) PrintStats

func (h *Host) PrintStats()

func (*Host) RecordEvent added in v1.1.2

func (h *Host) RecordEvent(t time.Time, rtt time.Duration, updown int, err error, msg string, arg string)

func (*Host) ResetStats

func (h *Host) ResetStats()

func (*Host) Run

func (h *Host) Run()

func (*Host) SetInterval

func (h *Host) SetInterval(d time.Duration)

func (*Host) String

func (h *Host) String() string

type HostCallbackFunc

type HostCallbackFunc func(h *Host, msg string, arg string)

type Pinger

type Pinger struct {
	Bind4         string
	Bind6         string
	PayloadSize   uint16
	Interval      time.Duration // default ping interval
	MaxRTT        time.Duration // default host down threshold
	DownThreshold int           // number of missed pongs to declare host down
	HistoryMax    int           // maximum size of history.  0=off
	// contains filtered or unexported fields
}

func New

func New() *Pinger

func (*Pinger) AddHost

func (p *Pinger) AddHost(addr string, fx HostCallbackFunc) (h *Host, err error)

func (*Pinger) GetHosts added in v1.1.0

func (p *Pinger) GetHosts() (hosts []*Host)

func (*Pinger) RemoveHost

func (p *Pinger) RemoveHost(host string) (err error)

func (*Pinger) Start

func (p *Pinger) Start() (err error)

func (*Pinger) Stop

func (p *Pinger) Stop()

type Rtt added in v1.1.2

type Rtt struct {
	T      time.Time
	D      time.Duration
	UpDown int
	Err    error
	Msg    string
	Arg    string
}

func (*Rtt) String added in v1.1.2

func (r *Rtt) String() string

Jump to

Keyboard shortcuts

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