awsping

package module
v1.9.999999 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2021 License: MIT Imports: 11 Imported by: 0

README

awsping

Console tool to check the latency to each AWS region

Go Report Card codecov

ToC

Usage

Test via TCP

➥ ./awsping
Europe (Frankfurt)                    51.86 ms
Europe (Ireland)                      62.86 ms
US-East (Virginia)                   126.39 ms
US-East (Ohio)                       154.81 ms
Asia Pacific (Mumbai)                181.09 ms
US-West (California)                 194.27 ms
US-West (Oregon)                     211.87 ms
South America (São Paulo)            246.20 ms
Asia Pacific (Tokyo)                 309.27 ms
Asia Pacific (Seoul)                 322.76 ms
Asia Pacific (Sydney)                346.37 ms
Asia Pacific (Singapore)             407.91 ms

Test via HTTP

➥ ./awsping -http
Europe (Frankfurt)                   222.56 ms
Europe (Ireland)                     226.76 ms
US-East (Virginia)                   349.17 ms
US-West (California)                 488.12 ms
US-East (Ohio)                       513.69 ms
Asia Pacific (Mumbai)                528.51 ms
US-West (Oregon)                     532.05 ms
South America (São Paulo)            599.36 ms
Asia Pacific (Seoul)                 715.92 ms
Asia Pacific (Sydney)                721.47 ms
Asia Pacific (Tokyo)                 745.24 ms
Asia Pacific (Singapore)             847.36 ms

Test via HTTPS

➥ ./awsping -https
Europe (Stockholm)                   216.67 ms
Europe (Frankfurt)                   263.20 ms
Europe (Paris)                       284.32 ms
Europe (Milan)                       305.63 ms
Europe (Ireland)                     327.34 ms
Europe (London)                      332.17 ms
Middle East (Bahrain)                590.74 ms
US-East (N. Virginia)                595.13 ms
Canada (Central)                     628.44 ms
US-East (Ohio)                       635.32 ms
Asia Pacific (Mumbai)                755.56 ms
Asia Pacific (Hong Kong)             843.90 ms
US-West (N. California)              870.65 ms
Asia Pacific (Singapore)             899.50 ms
Africa (Cape Town)                   912.06 ms
US-West (Oregon)                     919.34 ms
South America (São Paulo)            985.93 ms
Asia Pacific (Tokyo)                1122.67 ms
Asia Pacific (Seoul)                1138.76 ms
Asia Pacific (Osaka)                1167.40 ms
Asia Pacific (Sydney)               1328.90 ms

Test several times

➥ ./awsping -repeats 3
Europe (Frankfurt)                    50.13 ms
Europe (Ireland)                      62.67 ms
US-East (Virginia)                   126.88 ms
US-East (Ohio)                       155.37 ms
US-West (California)                 195.75 ms
US-West (Oregon)                     206.19 ms
Asia Pacific (Mumbai)                222.34 ms
South America (São Paulo)            254.28 ms
Asia Pacific (Tokyo)                 308.52 ms
Asia Pacific (Seoul)                 325.93 ms
Asia Pacific (Sydney)                349.62 ms
Asia Pacific (Singapore)             378.53 ms

Verbose mode

➥ ./awsping -repeats 3 -verbose 1
      Code            Region                                      Latency
    0 eu-central-1    Europe (Frankfurt)                         47.39 ms
    1 eu-west-1       Europe (Ireland)                           62.28 ms
    2 us-east-1       US-East (Virginia)                        128.45 ms
    3 us-east-2       US-East (Ohio)                            155.53 ms
    4 us-west-1       US-West (California)                      194.37 ms
    5 us-west-2       US-West (Oregon)                          208.91 ms
    6 ap-south-1      Asia Pacific (Mumbai)                     226.59 ms
    7 sa-east-1       South America (São Paulo)                 254.67 ms
    8 ap-northeast-1  Asia Pacific (Tokyo)                      301.97 ms
    9 ap-northeast-2  Asia Pacific (Seoul)                      323.10 ms
   10 ap-southeast-2  Asia Pacific (Sydney)                     341.26 ms
   11 ap-southeast-1  Asia Pacific (Singapore)                  397.47 ms
➥ ./awsping -repeats 3 -verbose 2
      Code            Region                             Try #1          Try #2          Try #3     Avg Latency
    0 eu-central-1    Europe (Frankfurt)               45.18 ms        45.46 ms        45.68 ms        45.44 ms
    1 eu-west-1       Europe (Ireland)                 61.89 ms        62.99 ms        62.98 ms        62.62 ms
    2 us-east-1       US-East (Virginia)              125.15 ms       126.75 ms       126.49 ms       126.13 ms
    3 us-east-2       US-East (Ohio)                  154.05 ms       154.28 ms       153.53 ms       153.96 ms
    4 us-west-1       US-West (California)            196.20 ms       195.05 ms       193.76 ms       195.00 ms
    5 us-west-2       US-West (Oregon)                204.04 ms       203.97 ms       203.84 ms       203.95 ms
    6 ap-south-1      Asia Pacific (Mumbai)           175.27 ms       300.68 ms       172.18 ms       216.05 ms
    7 sa-east-1       South America (São Paulo)       243.48 ms       247.12 ms       248.32 ms       246.31 ms
    8 ap-northeast-1  Asia Pacific (Tokyo)            324.78 ms       312.70 ms       319.02 ms       318.83 ms
    9 ap-northeast-2  Asia Pacific (Seoul)            328.96 ms       327.65 ms       326.17 ms       327.59 ms
   10 ap-southeast-2  Asia Pacific (Sydney)           388.17 ms       347.74 ms       393.58 ms       376.50 ms
   11 ap-southeast-1  Asia Pacific (Singapore)        409.53 ms       403.61 ms       405.84 ms       406.33 ms

Get Help

➜ ./awsping -h
Usage of ./awsping:
  -http
    	Use http transport (default is tcp)
  -https
    	Use https transport (default is tcp)
  -list-regions
    	Show list of regions
  -repeats int
    	Number of repeats (default 1)
  -service string
    	AWS Service: ec2, sdb, sns, sqs, ... (default "dynamodb")
  -v	Show version
  -verbose int
    	Verbosity level

Get binary file

$ wget https://github.com/ekalinin/awsping/releases/download/0.5.2/awsping.linux.amd64.tgz
$ tar xzvf awsping.linux.amd64.tgz
$ chmod +x awsping
$ ./awsping -v
0.5.2

Build from sources

➥ make build

Use with Docker

Build a Docker image

$ docker build -t awsping .

Run the Docker image

$ docker run --rm awsping

Arguments can be used as mentioned in the Usage section.

i.e.:

$ docker run --rm awsping -repeats 3 -verbose 2

Documentation

Index

Constants

View Source
const (
	// ShowOnlyRegions describes a type of output when only region's name and code printed out
	ShowOnlyRegions = -1
)

Variables

View Source
var (
	// Version describes application version
	Version = "2.0.0"
)

Functions

func CalcLatency

func CalcLatency(regions AWSRegions, repeats int, useHTTP bool, useHTTPS bool, service string)

CalcLatency returns list of aws regions sorted by Latency

func Duration2ms

func Duration2ms(d time.Duration) float64

Duration2ms converts time.Duration to ms (float64)

Types

type AWSHTTPRequester

type AWSHTTPRequester interface {
	Do(req *http.Request) (*http.Response, error)
}

AWSHTTPRequester is an interface for HTTP requests

type AWSRegion

type AWSRegion struct {
	Name      string
	Code      string
	Service   string
	Latencies []time.Duration
	Error     error
	CheckType CheckType

	Target  Targetter
	Request Requester
}

AWSRegion description of the AWS EC2 region

func NewRegion

func NewRegion(name, code string) AWSRegion

NewRegion creates a new region with a name and code

func (*AWSRegion) CheckLatency

func (r *AWSRegion) CheckLatency(wg *sync.WaitGroup)

CheckLatency does a latency check for a region

func (*AWSRegion) GetLatency

func (r *AWSRegion) GetLatency() float64

GetLatency returns Latency in ms

func (*AWSRegion) GetLatencyStr

func (r *AWSRegion) GetLatencyStr() string

GetLatencyStr returns Latency in string

type AWSRegions

type AWSRegions []AWSRegion

AWSRegions slice of the AWSRegion

func GetRegions

func GetRegions() AWSRegions

GetRegions returns a list of regions

func (AWSRegions) Len

func (rs AWSRegions) Len() int

Len returns a count of regions

func (AWSRegions) Less

func (rs AWSRegions) Less(i, j int) bool

Less return a result of latency compare between two regions

func (AWSRegions) SetCheckType

func (rs AWSRegions) SetCheckType(checkType CheckType)

SetCheckType sets Check Type for all regions

func (AWSRegions) SetDefaultTarget

func (rs AWSRegions) SetDefaultTarget()

SetDefaultTarget sets default target instance

func (AWSRegions) SetService

func (rs AWSRegions) SetService(service string)

SetService sets service for all regions

func (AWSRegions) SetTarget

func (rs AWSRegions) SetTarget(fn func(r *AWSRegion))

SetTarget sets default target instance for all regions

func (AWSRegions) Swap

func (rs AWSRegions) Swap(i, j int)

Swap two regions by index

type AWSRequest

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

AWSRequest implements Requester interface

func NewAWSRequest

func NewAWSRequest() *AWSRequest

NewAWSRequest creates a new instance of AWSRequest

func (*AWSRequest) Do

func (r *AWSRequest) Do(ua, url string, reqType RequestType) (time.Duration, error)

Do does a request. Type of request depends on reqType

func (*AWSRequest) DoHTTP

func (r *AWSRequest) DoHTTP(ua, url string) (time.Duration, error)

DoHTTP does HTTP request for a URL by User-Agent (ua)

func (*AWSRequest) DoTCP

func (r *AWSRequest) DoTCP(_, addr string) (time.Duration, error)

DoTCP does TCP request to the Addr

type AWSTCPRequester

type AWSTCPRequester interface {
	Dial(network, address string) (net.Conn, error)
}

AWSTCPRequester is an interface for TCP requests

type AWSTarget

type AWSTarget struct {
	HTTPS   bool
	Code    string
	Service string
	Rnd     string
}

AWSTarget implements Targetter for AWS

func (*AWSTarget) GetIP

func (r *AWSTarget) GetIP() (*net.TCPAddr, error)

GetIP return IP for AWS target

func (*AWSTarget) GetURL

func (r *AWSTarget) GetURL() string

GetURL return URL for AWS target

type CheckType

type CheckType int

CheckType describes a type for a check

const (
	// CheckTypeTCP is TCP type of check
	CheckTypeTCP CheckType = iota
	// CheckTypeHTTP is HTTP type of check
	CheckTypeHTTP
	// CheckTypeHTTPS is HTTPS type of check
	CheckTypeHTTPS
)

type LatencyOutput

type LatencyOutput struct {
	Level   int
	Repeats int
	// contains filtered or unexported fields
}

LatencyOutput prints data into console

func NewOutput

func NewOutput(level, repeats int) *LatencyOutput

NewOutput creates a new LatencyOutput instance

func (*LatencyOutput) Show

func (lo *LatencyOutput) Show(regions *AWSRegions)

Show print data

type RequestType

type RequestType int

RequestType describes a type for a request type

const (
	// RequestTypeHTTP is HTTP type of request
	RequestTypeHTTP RequestType = iota
	// RequestTypeTCP is TCP type of request
	RequestTypeTCP
)

type Requester

type Requester interface {
	Do(ua, url string, reqType RequestType) (time.Duration, error)
}

Requester is an interface to do a network request

type Targetter

type Targetter interface {
	GetURL() string
	GetIP() (*net.TCPAddr, error)
}

Targetter is an interface to get target's IP or URL

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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