Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/origin/master' into add_scan_fu…
Browse files Browse the repository at this point in the history
…nctions

Conflicts:
	serviceping/serviceping.py
  • Loading branch information
Dwight Hubbard committed Jan 20, 2017
2 parents 5843db0 + 7145d28 commit f1d9f5e
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 36 deletions.
2 changes: 1 addition & 1 deletion HACKING.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Contributing to serviceping
============================================
serviceping development occurs on github at:
Serviceping development occurs on github at:
https://github.com/yahoo/serviceping

If you want to contribute to serviceping please work on a
Expand Down
40 changes: 19 additions & 21 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,16 @@ Usage

.. code-block::
Usage: serviceping [options] url | host[:port] | ip[:port]
usage: serviceping [-h] [-c COUNT] [-i INTERVAL] [-d]
destination [destination ...]
positional arguments:
destination Destination host or URL
Options:
optional arguments:
-h, --help show this help message and exit
-c COUNT Number of pings to send
-i INTERVAL Ping interval
-d
-d Show timings for the entire connection
Examples
Expand All @@ -66,9 +69,8 @@ The serviceping tool uses a syntax that mirrors that of the ping commmand.
Ping port 80 (http) on www.yahoo.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Here we ping www.yahoo.com via http (port 80).
It is easy to see that that address has multiple hosts responding and the
latency of each request.
By pinging www.yahoo.com via http (port 80), we can clearly see the
multiple hosts responding and the latency of each request.

.. code-block::
Expand All @@ -84,7 +86,7 @@ latency of each request.
Same thing using ssl
~~~~~~~~~~~~~~~~~~~~

Service ping can also connect to other ports such as the ssl port (443).
Serviceping can also connect to other ports such as the ssl port (443).

.. code-block::
Expand All @@ -100,17 +102,13 @@ Service ping can also connect to other ports such as the ssl port (443).
Pinging a URL instead of the port
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Portping also allows specifying a URL. If a URL is specified it will also
perform an http get request and show the response.

This is useful to see when there are hosts doing unexpected things in a dns
Portping can also specify a URL. If a URL is specified, it will
perform an http get request and show the response, which is useful
when hosts are doing unexpected things in a dns
rotation or behind a reverse proxy or vip.

In this example we specify a url of http://cnn.com/

This shows that there are two hosts responding to this request and that they
are returning different amounts of data in their responses.

.. code-block::
$ serviceping http://cnn.com/
Expand All @@ -124,20 +122,17 @@ are returning different amounts of data in their responses.
rtt min/avg/max/dev = 62.98/73.31/87.14/56.00 ms
$
The output shows that two hosts are responding to this request, and that they
are returning different amounts of data in their responses.

Pinging a URL with timings
~~~~~~~~~~~~~~~~~~~~~~~~~~

The detailed timing flag adds timings for each step of each request.

This is useful for determining what is causing latency issues or errors.
The detailed timing flag adds timings for each step of each request,
which is useful for determining the causes of latency issues or errors.

Here we are doing the previous example with detailed timings.

In the results we can see a few new things.

It is clear that the host with address 157.166.226.25 is taking significantly longer to establish the tcp connection and handle the http get request.

.. code-block::
$ serviceping -d http://cnn.com/
Expand All @@ -151,6 +146,9 @@ It is clear that the host with address 157.166.226.25 is taking significantly lo
rtt min/avg/max/dev = 156.69/212.76/327.43/138.24 ms
$
Clearly, the host with address 157.166.226.25 is taking significantly longer
to establish the tcp connection and handle the http get request.

License
=======

Expand Down
25 changes: 12 additions & 13 deletions scripts/serviceping
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ Command line utility providing a ping like interface for pinging tcp/ssl
services.
"""
from __future__ import print_function
import ssl
import argparse
import datetime
import socket
import ssl
import sys
import datetime
import time
import optparse

from serviceping import calc_deviation
from serviceping.commandline import parse_arguments


try:
from urllib.parse import urlparse
except ImportError:
Expand Down Expand Up @@ -57,9 +57,9 @@ def exit_statistics():
)
print(
'rtt min/avg/max/dev = %.2f/%.2f/%.2f/%.2f ms' % (
min_time.seconds * 1000 + float(min_time.microseconds) / 1000,
min_time.seconds*1000 + float(min_time.microseconds)/1000,
float(avg_time) / 1000,
max_time.seconds * 1000 + float(max_time.microseconds) / 1000,
max_time.seconds*1000 + float(max_time.microseconds)/1000,
float(deviation)
)
)
Expand Down Expand Up @@ -182,9 +182,8 @@ if __name__ == '__main__':
min_time:
min_time = durations['all']
times.append(
durations['all'].seconds*1000+float(
durations['all'].microseconds
)
durations['all'].seconds * 1000
+ float(durations['all'].microseconds)
)
avg_time = sum(times) / float(len(times))
deviation = calc_deviation(times, avg_time)
Expand All @@ -205,17 +204,17 @@ if __name__ == '__main__':
if d in durations.keys():
print('%s=%.2fms' % (
d,
durations[d].seconds*1000 +
float(durations[d].microseconds)/1000
durations[d].seconds * 1000
+ float(durations[d].microseconds) / 1000
), end=" ")
else:
print(
'%sfrom %s:%s (%s:%s):%s time=%.2f ms' % (
'%d bytes ' % length if length else '',
hostname, port, ip, port, code_string,
float(
durations['all'].seconds*1000 +
durations['all'].microseconds
durations['all'].seconds * 1000
+ durations['all'].microseconds
) / 1000
),
end=" ")
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
# Copyrights licensed under the Apache 2.0 License
# See the accompanying LICENSE.txt file for terms.

import os
import json
import os

from setuptools import setup


Expand Down

0 comments on commit f1d9f5e

Please sign in to comment.