icmp

package
v0.1.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package icmp implements the ICMP checker and prober.

The ICMP prober sends an ICMP ECHO request and receives a reply from the address the request was sent to.

Valid check format is described as following:

Interval and Timeout should be greater than 0.

Input:

  Type          Value                  Description
-------- -------------------- ------------------------------
 "ICMP"   "", "PING", "ECHO"   Sends and receives ICMP ECHO

Output:

   Type           Value             Description
----------- ----------------- ------------------------
 "TIMEOUT"   <not validated>   Success is not-timeout

Target:

   Type                    Value                          Description
----------- ----------------------------------- --------------------------------
 "ADDRESS"   <valid address (can be hostname)>   Address to send the request to

Payload is not required and hence not validated.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Checker

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

Checker sends an ICMP ECHO request and checks if a reply is returned.

func (*Checker) Execute

func (c *Checker) Execute(ctx context.Context) (*checker.Result, error)

Execute executes the check.

func (*Checker) Provision

func (c *Checker) Provision(check checker.Check) (err error)

Provision initializes required fields for c's execution.

func (*Checker) Validate

func (c *Checker) Validate(check checker.Check) error

Validate validates the check configuration.

type ProbeResult

type ProbeResult struct {
	Timeout          bool
	StartTime        time.Time
	Duration         time.Duration
	NumBytesSent     int
	NumBytesReceived int
	TTL              int
}

ProbeResult is the result of an ICMP probe.

type Prober

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

Prober sends an ICMP ECHO request to the given address.

func NewProber

func NewProber(addr string, timeout time.Duration) (*Prober, error)

NewProber creates a prober to send an ICMP ECHO ping to the provided address.

func (*Prober) Probe

func (p *Prober) Probe(ctx context.Context) (*ProbeResult, error)

Probe sends an ICMP ECHO request to the given address and returns the result.

Jump to

Keyboard shortcuts

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