Documentation ¶
Index ¶
- Constants
- Variables
- func CombinedOutputTimeout(c *exec.Cmd, timeout time.Duration) ([]byte, error)
- func MyHostPinger(binary string, timeout float64, args ...string) (string, error)
- func RunTimeout(c *exec.Cmd, timeout time.Duration) error
- func StdOutputTimeout(c *exec.Cmd, timeout time.Duration) ([]byte, error)
- func WaitTimeout(c *exec.Cmd, timeout time.Duration) error
- type HostPinger
- type NativePingFunc
- type Ping
Constants ¶
const KillGrace = 5 * time.Second
KillGrace is the amount of time we allow a process to shutdown before sending a SIGKILL.
Variables ¶
var ErrTimeout = errors.New("command timed out")
Functions ¶
func CombinedOutputTimeout ¶
CombinedOutputTimeout runs the given command with the given timeout and returns the combined output of stdout and stderr. If the command times out, it attempts to kill the process.
func MyHostPinger ¶
func RunTimeout ¶
RunTimeout runs the given command with the given timeout. If the command times out, it attempts to kill the process.
func StdOutputTimeout ¶
StdOutputTimeout runs the given command with the given timeout and returns the output of stdout. If the command times out, it attempts to kill the process.
Types ¶
type HostPinger ¶
HostPinger is a function that runs the "ping" function using a list of passed arguments. This can be easily switched with a mocked ping function for unit test purposes (see ping_test.go)
type NativePingFunc ¶
type Ping ¶
type Ping struct { Log telegraf.Logger `toml:"-"` // Interval at which to ping (ping -i <INTERVAL>) PingInterval float64 `toml:"ping_interval"` // Number of pings to send (ping -c <COUNT>) Count int // Per-ping timeout, in seconds. 0 means no timeout (ping -W <TIMEOUT>) Timeout float64 // Ping deadline, in seconds. 0 means no deadline. (ping -w <DEADLINE>) Deadline int // Interface or source address to send ping from (ping -I/-S <INTERFACE/SRC_ADDR>) Interface string // URLs to ping Urls []string // Method defines how to ping (native or exec) Method string // Ping executable binary Binary string // Arguments for ping command. When arguments is not empty, system binary will be used and // other options (ping_interval, timeout, etc) will be ignored Arguments []string // Whether to resolve addresses using ipv6 or not. IPv6 bool // host ping function PingHost HostPinger NativePingFunc NativePingFunc // Calculate the given percentiles when using native method Percentiles []int // contains filtered or unexported fields }