ping

package
v0.0.0-...-efb87f3 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2024 License: MIT Imports: 16 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrICMPServiceUnavailable will be returned if the process doesn't have
	// sufficient privileges.
	ErrICMPServiceUnavailable = errors.New("ICMP service unavailable")
)

Functions

func Available

func Available() bool

Available returns true if the ICMP service is available.

Types

type ICMPPayload

type ICMPPayload struct {
	Helo      string    `json:"h"`
	Timestamp time.Time `json:"t"`
}

ICMPPayload is capable of generating a signed ICMP payload.

func NewICMPPayload

func NewICMPPayload() *ICMPPayload

NewICMPPayload returns a new ICMPPayload set to current time.

func (*ICMPPayload) Bytes

func (p *ICMPPayload) Bytes() []byte

Bytes returns a signed payload.

func (*ICMPPayload) Read

func (p *ICMPPayload) Read(payload []byte) error

type ICMPService

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

ICMPService is a service capable of pinging remotes and listening for answers.

func NewICMPService

func NewICMPService() *ICMPService

NewICMPService instantiates a new ICMPService.

func (*ICMPService) Ping

func (i *ICMPService) Ping(target string, count int, timeout time.Duration) (*ICMPSummary, error)

Ping will ping the target using ICMP echo/reply.

func (*ICMPService) Start

func (i *ICMPService) Start() error

Start starts the ICMPService.

func (*ICMPService) Stop

func (i *ICMPService) Stop()

Stop stops the listening loop.

type ICMPSummary

type ICMPSummary struct {
	Sent    int
	Replies int
	Min     time.Duration
	Max     time.Duration
	Average time.Duration
}

ICMPSummary will be returned from Ping() to give a quick summary.

type Ping

type Ping struct {
	Target string `json:"target" description:"Target to ping"`
	Count  int    `json:"count" description:"Number of ICMP echo packets to send" default:"3"`
}

Ping will try to "ping" the host using ICMP echo.

func (*Ping) Check

func (p *Ping) Check(result plugins.AgentResult) error

Check implements plugins.Agent.

Jump to

Keyboard shortcuts

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