Skip to main content

ping in python

Project description

PyPI Coverage GitHub license

pping

ping in python

Installing

pip install pping

Usage

from pping import ping
result = ping('www.example.com') # simple usage
result = ping('www.example.com', # optional arguments
              repeat=4,          # -- Number of echo requests to send.
              interval=1,        # -- Time in seconds interval between each request.
              size=32,           # -- Send buffer size in bytes.
              timeout=1,         # -- Timeout in seconds to wait for each reply.
              ttl=128)           # -- Time To Live.

Operation on the result

>>> print(result)
'''
Reply from 93.184.216.34: bytes=32 time=151ms TTL=52
Request timed out.
Reply from 93.184.216.34: bytes=32 time=149ms TTL=52
Reply from 93.184.216.34: bytes=32 time=150ms TTL=52

Ping statistics for www.example.com:
        Packets: Sent = 4, Received = 3, Lost = 1 (25% loss)
Approximate round trip times in milli-seconds:
        Average = 150ms, Minimum = 149ms, Maximum = 151ms, Stdev = 0.5
'''
>>> result[0]
Response(status='ok', src='93.184.216.34', dst='192.168.31.100', ttl=52, size=32, seq=1, rtt=0.15059328079223633)

>>> result[1]
Response(status='timedout')
>>> result.hostname
'www.example.com'

>>> result.iplist
['93.184.216.34']
>>> result.times      # timed out are not inclued
[0.15059328079223633, 0.1492629051208496, 0.14995193481445312]

>>> result.all_times  # timed out as None
[0.15059328079223633, None, 0.1492629051208496, 0.14995193481445312]
# other properties
>>> result.hostalias
>>> result.avg
>>> result.min
>>> result.max
>>> result.stdev
>>> result.sent
>>> result.recv
>>> result.lost

License

This project is licensed under the MIT License - see the LICENSE file for details

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pping, version 0.0.8
Filename, size File type Python version Upload date Hashes
Filename, size pping-0.0.8-py3-none-any.whl (9.0 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size pping-0.0.8.tar.gz (6.3 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page