Documentation ¶
Overview ¶
Package ping contains utility functions to wrap around the ping program.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(c *config)
Option is a function used to configure ping command.
func BindAddress ¶
BindAddress returns an Option that can be passed to Ping to disallow ping from changing source address.
func SaveOutput ¶
SaveOutput returns an Option that can be passed to Ping to save the output of ping command to filePath under OutDir.
func SourceIface ¶
SourceIface returns an Option that can be passed to Ping to set source interface.
type Result ¶
type Result struct { Sent int Received int Loss float64 MinLatency float64 AvgLatency float64 MaxLatency float64 DevLatency float64 }
Result is a struct that contains a successful ping's statistics.
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runner is the object contains ping utilities.
func (*Runner) Ping ¶
Ping performs a shell ping with parameters specified in Options. If no Option is specified, default config (count=10, interval=0.5s) is used. Notice that when no reply is received, this function will try to parse the output and return a valid result instead of returning the error of non-zero return code of ping.