ping

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2021 License: GPL-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package ping provides a test ICMPv4 implementation using the `ping` Unix command.

Index

Constants

View Source
const (
	// ConnectInvalidArgumentRegex is a regex which matches when an invalid IP address or hostname is provided as input.
	ConnectInvalidArgumentRegex = `(?m)connect: Invalid argument$`
	// SuccessfulOutputRegex matches a successfully run "ping" command.  That does not mean that no errors or drops
	// occurred during the test.
	SuccessfulOutputRegex = `(?m)(\d+) packets transmitted, (\d+)( packets){0,1} received, (?:\+(\d+) errors)?.*$`
)

Variables

This section is empty.

Functions

func Command

func Command(host string, count int) []string

Command returns command line args for pinging `host` with `count` requests, or indefinitely if `count` is not positive.

Types

type Ping

type Ping struct {
	// contains filtered or unexported fields
}

Ping provides a ping test implemented using command line tool `ping`.

func NewPing

func NewPing(timeout time.Duration, host string, count int) *Ping

NewPing creates a new `Ping` test which pings `hosts` with `count` requests, or indefinitely if `count` is not positive, and executes within `timeout` seconds.

func (*Ping) Args

func (p *Ping) Args() []string

Args returns the command line args for the test.

func (*Ping) GetIdentifier

func (p *Ping) GetIdentifier() identifier.Identifier

GetIdentifier returns the tnf.Test specific identifier.

func (*Ping) GetReelFirstRegularExpressions

func (p *Ping) GetReelFirstRegularExpressions() []string

GetReelFirstRegularExpressions returns the regular expressions used for matching in ReelFirst.

func (*Ping) GetStats

func (p *Ping) GetStats() (transmitted, received, errors int)

GetStats returns the transmitted, received and error counts.

func (*Ping) ReelEOF

func (p *Ping) ReelEOF()

ReelEOF does nothing; ping requires no intervention on eof.

func (*Ping) ReelFirst

func (p *Ping) ReelFirst() *reel.Step

ReelFirst returns a step which expects the ping statistics within the test timeout.

func (*Ping) ReelMatch

func (p *Ping) ReelMatch(_, _, match string) *reel.Step

ReelMatch parses the ping statistics and set the test result on match. The result is success if at least one response was received and the number of responses received is at most one less than the number received (the "missing" response may be in flight). The result is error if ping reported a protocol error (e.g. destination host unreachable), no requests were sent or there was some test execution error. Otherwise the result is failure. Returns no step; the test is complete.

func (*Ping) ReelTimeout

func (p *Ping) ReelTimeout() *reel.Step

ReelTimeout returns a step which kills the ping test by sending it ^C.

func (*Ping) Result

func (p *Ping) Result() int

Result returns the test result.

func (*Ping) Timeout

func (p *Ping) Timeout() time.Duration

Timeout returns the timeout in seconds for the test.

Jump to

Keyboard shortcuts

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