mtrparser

package module
v0.0.0-...-576a258 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2017 License: MIT Imports: 10 Imported by: 3

README

mtrparser

Parsing raw mtr output in Go

GoDoc

This library was primarily created to parse output of mtr command for TurboBytes Pulse. This parses the output of mtr with --raw argument into Go structures. From there one can format it however they want... regardless of the mtr version running. Also included in the struct is the timing details of each ping received.

See the reference command in cmd/mtrparser.go for usage.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MTROutPut

type MTROutPut struct {
	Hops     []*MtrHop
	Target   string //Saving this FYI
	HopCount int
}

func ExecuteMTR

func ExecuteMTR(target string, IPv string) (*MTROutPut, error)

Execute mtr command and return parsed output

func ExecuteMTRContext

func ExecuteMTRContext(ctx context.Context, target string, IPv string) (*MTROutPut, error)

Execute mtr command and return parsed output, killing the process if context becomes done before command completes.

func NewMTROutPut

func NewMTROutPut(raw, target string, count int) (*MTROutPut, error)

NewMTROutPut can be used to parse output of mtr --raw <target ip> . raw is the output from mtr command, count is the -c argument, default 10 in mtr

func (*MTROutPut) String

func (result *MTROutPut) String() string

String returns output similar to --report option in mtr

func (*MTROutPut) Summarize

func (result *MTROutPut) Summarize(count int)

Summarize calls Summarize on each Hop

type MtrHop

type MtrHop struct {
	IP       []string
	Host     []string
	ASN      []string
	Timings  []time.Duration //In Json they become nanosecond
	Avg      time.Duration
	Loss     int
	SD       time.Duration
	Sent     int
	Received int
	Last     time.Duration
	Best     time.Duration
	Worst    time.Duration
}

func (*MtrHop) ResolveIPs

func (hop *MtrHop) ResolveIPs()

ResolveIPs populates the DNS hostnames of the IP in each Hop.

func (*MtrHop) Summarize

func (hop *MtrHop) Summarize(count int)

Summarize calculates various statistics for each Hop

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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