Giter Club home page Giter Club logo

pingtop's Introduction

pingtop

Ping multiple servers and show the result in a top like terminal UI.

asciicast

Install

pip install pingtop

** pingtop support Python3.8 Python3.8. **

There is a dependency (blist <http://stutzbachenterprises.com/blist/>) not supporting Python3.9, so please pingtop can't support 3.9.

Usage

Then ping mutiple server:

pingtop baidu.com google.com twitter.com

This project is using click. Check help info with pingtop -h.

~ pingtop --help
Usage: pingtop [OPTIONS] [HOST]...

Options:
  -s, --packetsize INTEGER        specify the number of data bytes to be sent.
                                  The default is 56, which translates into 64
                                  ICMP data bytes when combined with the 8
                                  bytes of ICMP header data.  This option
                                  cannot be used with ping sweeps.  [default:
                                  56]
  -l, --logto PATH
  -v, --log-level [DEBUG|INFO|WARNING|ERROR|CRITICAL]
  --help                          Show this message and exit.

Why do I get Permission denied ?

We use ICMP socket to send ping packet without sudo (See this post by lilydjwg(in Chinese)), however, who(which group) can use this feature is controled by a kernel parameter: net.ipv4.ping_group_range.

cat /proc/sys/net/ipv4/ping_group_range

1    0

The default value is 1 0, this means the whose group number from 1 to 0 can use this feature(which means nobody can use this), so you get a Permission denied .

To fix this, change this variable to a proper range include your group id, like this:

[vagrant@centos7 pingtop]$ id
uid=1000(vagrant) gid=1000(vagrant) groups=1000(vagrant) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023

[vagrant@centos7 pingtop]$ sudo sysctl -w net.ipv4.ping_group_range='0 1001'
net.ipv4.ping_group_range = 0 1001

Credits

  • For the credits of ping.pyโ€™s implementation please refer ping.py.
  • The UI was built on panwid thanks to @tonycpsu.
  • @gzxultra helped to solve the permission issues.

pingtop's People

Contributors

gzxultra avatar ivanhercaz avatar jasonqiao36 avatar laixintao avatar quintonamore avatar rsharifnasab avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pingtop's Issues

pip install problem on version 0.2.14

When installing via pip install pingtop in virtualenv or default on macos, windows and linux I allways get:
$ pingtop Traceback (most recent call last): File "/home/adrian/.local/bin/pingtop", line 7, in <module> from pingtop import multi_ping ModuleNotFoundError: No module named 'pingtop'

If I install from source version 0.2.12 it works a bit until it crashes.

ipv6 support?

Seems current implementation don't include ipv6 support, any plan to implement the feature?

pingtop 2001:19f0:4009:405:5400:ff:fe00:5363 108.61.149.182
๏ฟฝSending ICMP packet with 56 data bytes.
๏ฟฝ[Sort Key] H: host S: seq R: real_rtt I: min_rtt A: avg_rtt M: max_rtt T: std L: lost
๏ฟฝ[Quit key] Q
๏ฟฝโ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•๏ฟฝ Host(IP)                             | IP              | Seq|โ†‘  RTT|   Min|     Avg|   Max|     Std| LOSS| LOSS%|Stat
๏ฟฝ 108.61.149.182                       | 108.61.149.182  |  13|  1000|  1000|    1000|  1000|       0|   13|  100%|
๏ฟฝ 2001:19f0:4009:405:5400:ff:fe00:5363 | Unknown         |    |      |      |        |      |        |     |      |

TypeError: __init__() got an unexpected keyword argument 'border'

Hi,

I got this error on the latest stable version:

> pingtop google.com bing.com
Traceback (most recent call last):
  File "/usr/bin/pingtop", line 33, in <module>
    sys.exit(load_entry_point('pingtop==0.3.0', 'console_scripts', 'pingtop')())
  File "/usr/lib/python3.9/site-packages/click/core.py", line 1137, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3.9/site-packages/click/core.py", line 1062, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3.9/site-packages/click/core.py", line 763, in invoke
    return __callback(*args, **kwargs)
  File "/usr/lib/python3.9/site-packages/pingtop/__init__.py", line 427, in multi_ping
    tablebox = MainBox(
  File "/usr/lib/python3.9/site-packages/pingtop/__init__.py", line 210, in __init__
    self.table = PingDataTable(*args, **kwargs)
  File "/usr/lib/python3.9/site-packages/pingtop/__init__.py", line 193, in __init__
    super().__init__(*args, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'border'

Python version: 3.9
OS: ArchLinux

Handle socket.gaierror

~ pingtop aaaa
RROR:root:[Errno 8] nodename nor servname provided, or not known
Traceback (most recent call last):
  File "/usr/local/var/pyenv/versions/3.7.1/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/Users/laixintao/Program/pingtop/pingtop.py", line 239, in forever_ping
    dest_ip = socket.gethostbyname(dest)
socket.gaierror: [Errno 8] nodename nor servname provided, or not known
  • set a smaller timeout
  • display SERVFAIL at the IP column

image

Unknown distribution option

Hi at all,
I am trying to install pingtop, but i have this problem:

`root@kali:~/Scaricati/pingtop# python3 setup.py
/usr/lib/python3.7/distutils/dist.py:274: UserWarning: Unknown distribution option: 'entry_points'
warnings.warn(msg)
/usr/lib/python3.7/distutils/dist.py:274: UserWarning: Unknown distribution option: 'install_requires'
warnings.warn(msg)
/usr/lib/python3.7/distutils/dist.py:274: UserWarning: Unknown distribution option: 'long_description_content_type'
warnings.warn(msg)
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: setup.py --help [cmd1 cmd2 ...]
or: setup.py --help-commands
or: setup.py cmd --help

error: no commands supplied`

What about?

Print summary after quit.

Like ping:

โžœ  ~ \ping google.com
PING google.com (172.217.195.113): 56 data bytes
64 bytes from 172.217.195.113: icmp_seq=0 ttl=40 time=233.197 ms
64 bytes from 172.217.195.113: icmp_seq=1 ttl=40 time=235.467 ms
64 bytes from 172.217.195.113: icmp_seq=2 ttl=40 time=306.328 ms
64 bytes from 172.217.195.113: icmp_seq=3 ttl=40 time=325.957 ms
^C
--- google.com ping statistics ---
4 packets transmitted, 4 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 233.197/275.237/325.957/41.498 ms

Also support -q --quite without summary. ( Or no summary by default, and support -s --summary to print summary? )

0.2.9 isn't in PyPI

I was going to make a pull request to solve the error message when you execute pingtop without commands because in 0.2.8 the message might be hard to understand that the error was to execute the program without commands.

However, I clone this repository and I check the solution is already applied! The problem is that it seems that version 0.2.9 isn't availabe yet.

Could you solve it?

In addition I think you should have the README in RST format, but for that I am going to open a PR by myself.

Dynamic add more hosts.

Add a test widget below and user can add more hosts in pingtop's TUI without quitting and change the parameters.

PermissionError when Pingtop is executed without sudo

Hi,
Beautiful and useful tool! However I am having a similar problem to #5, but it is already fixed and seems a bit different to this one I am reporting.

I installed it with pip install pingtop. Then I ping baidu.com with pingtop baidu.com but it doesn't work, I get this error:

ERROR:root:[Errno13]: Permiso denegado
[...]
PermissionError: [Errno13]  Permiso denegado

I can't copy the error, so I am going to attach a screenshot.

pingtop_error

I achieve to run it thanks to the comment of @laixintao in the mentioned issue, I mean making a which pingtop to get the path in which it is installed and then using sudo PATH baidu.com.

Is there some reason to run it as super user? Or, could it be fixed?

Regards

Handle mouse input (click column header to sort)

็‚นๅ‡ปไปปไฝ•้กน็š„ๅ็งฐๅฐ†ไผšๅดฉๆบƒ

Traceback (most recent call last):
  File "/usr/local/bin/pingtop", line 10, in <module>
    sys.exit(multi_ping())
  File "/usr/local/lib64/python3.6/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib64/python3.6/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib64/python3.6/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib64/python3.6/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/bin/pingtop.py", line 370, in multi_ping
    mainloop.run()
  File "/usr/local/lib64/python3.6/site-packages/urwid/main_loop.py", line 286, in run
    self._run()
  File "/usr/local/lib64/python3.6/site-packages/urwid/main_loop.py", line 384, in _run
    self.event_loop.run()
  File "/usr/local/lib64/python3.6/site-packages/urwid/main_loop.py", line 788, in run
    self._loop()
  File "/usr/local/lib64/python3.6/site-packages/urwid/main_loop.py", line 825, in _loop
    self._watch_files[fd]()
  File "/usr/local/lib64/python3.6/site-packages/urwid/raw_display.py", line 404, in <lambda>
    event_loop, callback, self.get_available_raw_input())
  File "/usr/local/lib64/python3.6/site-packages/urwid/raw_display.py", line 502, in parse_input
    callback(processed, processed_codes)
  File "/usr/local/lib64/python3.6/site-packages/urwid/main_loop.py", line 411, in _update
    self.process_input(keys)
  File "/usr/local/lib64/python3.6/site-packages/urwid/main_loop.py", line 517, in process_input
    something_handled |= bool(self.unhandled_input(k))
  File "/usr/local/lib64/python3.6/site-packages/urwid/main_loop.py", line 563, in unhandled_input
    return self._unhandled_input(input)
  File "/usr/local/bin/pingtop.py", line 217, in global_input
    elif key.upper() in sort_keys:
AttributeError: 'tuple' object has no attribute 'upper'

Socket.socket id is same, it's not thread safe.

weibo.com        28.842926025390625
weibo.com        28.017044067382812
baidu.com        28.11598777770996
baidu.com        28.035879135131836
weibo.com        28.059959411621094
weibo.com        28.36894989013672
baidu.com        28.847932815551758
baidu.com        28.081893920898438
weibo.com        28.048992156982422
baidu.com        28.68819236755371
weibo.com        28.76424789428711
baidu.com        27.24289894104004
weibo.com        27.281761169433594
weibo.com        31.570911407470703
baidu.com        31.70323371887207
baidu.com        30.002117156982422
weibo.com        30.025005340576172
weibo.com        28.65886688232422
baidu.com        28.689861297607422
baidu.com        29.37793731689453
weibo.com        29.562950134277344

That's interesting...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.