traceroute

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// IPv4HeaderSize is the size of an IPv4 header in bytes
	IPv4HeaderSize = 20
	// IPv6HeaderSize is the size of an IPv6 header in bytes
	IPv6HeaderSize = 40
)
View Source
const CheckName = "traceroute"

Variables

This section is empty.

Functions

func NewCheck

func NewCheck() checks.Check

func TraceRoute added in v0.5.0

func TraceRoute(ctx context.Context, cfg tracerouteConfig) (map[int][]Hop, error)

TraceRoute performs a traceroute to the specified host using TCP and listens for ICMP Time Exceeded messages using ICMP.

Types

type Config

type Config struct {
	// Targets is a list of targets to traceroute to
	Targets []Target `json:"targets" yaml:"targets" mapstructure:"targets"`
	// Retry defines if and how to retry a target
	Retry helper.RetryConfig `json:"retry" yaml:"retry" mapstructure:"retry"`
	// MaxHops is the maximum number of hops to try before giving up
	MaxHops int `json:"maxHops" yaml:"maxHops" mapstructure:"maxHops"`
	// Interval is the time to wait between check iterations
	Interval time.Duration `json:"interval" yaml:"interval" mapstructure:"interval"`
	// Timeout is the maximum time to wait for a response from a hop
	Timeout time.Duration `json:"timeout" yaml:"timeout" mapstructure:"timeout"`
}

Config is the configuration for the traceroute check

func (*Config) For

func (c *Config) For() string

func (*Config) Validate

func (c *Config) Validate() error

type Hop added in v0.5.0

type Hop struct {
	Latency time.Duration `json:"latency" yaml:"latency" mapstructure:"latency"`
	Addr    HopAddress    `json:"addr" yaml:"addr" mapstructure:"addr"`
	Name    string        `json:"name" yaml:"name" mapstructure:"name"`
	Ttl     int           `json:"ttl" yaml:"ttl" mapstructure:"ttl"`
	Reached bool          `json:"reached" yaml:"reached" mapstructure:"reached"`
}

Hop represents a single hop in a traceroute

type HopAddress added in v0.5.0

type HopAddress struct {
	IP   string `json:"ip" yaml:"ip" mapstructure:"ip"`
	Port int    `json:"port" yaml:"port" mapstructure:"port"`
}

HopAddress represents an IP address and port

func (HopAddress) String added in v0.5.0

func (a HopAddress) String() string

String returns the string representation of the HopAddress.

type Target

type Target struct {
	// The address of the target to traceroute to. Can be a DNS name or an IP address
	Addr string `json:"addr" yaml:"addr" mapstructure:"addr"`
	// The port to traceroute to
	Port int `json:"port" yaml:"port" mapstructure:"port"`
}

func (Target) String added in v0.5.0

func (t Target) String() string

type Traceroute

type Traceroute struct {
	checks.CheckBase
	// contains filtered or unexported fields
}

func (*Traceroute) GetConfig

func (tr *Traceroute) GetConfig() checks.Runtime

GetConfig returns the current configuration of the check

func (*Traceroute) GetMetricCollectors

func (tr *Traceroute) GetMetricCollectors() []prometheus.Collector

GetMetricCollectors allows the check to provide prometheus metric collectors

func (*Traceroute) Name

func (tr *Traceroute) Name() string

Name returns the name of the check

func (*Traceroute) RemoveLabelledMetrics added in v0.5.0

func (tr *Traceroute) RemoveLabelledMetrics(target string) error

RemoveLabelledMetrics removes the metrics which have the passed target as a label

func (*Traceroute) Run

func (tr *Traceroute) Run(ctx context.Context, cResult chan checks.ResultDTO) error

Run runs the check in a loop sending results to the provided channel

func (*Traceroute) Schema

func (tr *Traceroute) Schema() (*openapi3.SchemaRef, error)

Schema returns an openapi3.SchemaRef of the result type returned by the check

func (*Traceroute) Shutdown

func (tr *Traceroute) Shutdown()

Shutdown is called once when the check is unregistered or sparrow shuts down

func (*Traceroute) UpdateConfig added in v0.5.0

func (tr *Traceroute) UpdateConfig(cfg checks.Runtime) error

UpdateConfig is called once when the check is registered This is also called while the check is running, if the remote config is updated This should return an error if the config is invalid

Jump to

Keyboard shortcuts

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