Giter Site home page Giter Site logo

denilsonsa / prettyping Goto Github PK

View Code? Open in Web Editor NEW
1.2K 30.0 77.0 718 KB

`prettyping` is a wrapper around the standard `ping` tool, making the output prettier, more colorful, more compact, and easier to read.

Home Page: http://denilsonsa.github.io/prettyping/

License: MIT License

Shell 100.00%
ping shell network-monitoring graph

prettyping's Introduction

prettyping

Donation - buy me a coffee

prettyping is a wrapper around the standard ping tool with the objective of making the output prettier, more colorful, more compact, and easier to read.

prettyping runs the standard ping in the background and parses its output, showing the ping responses in a graphical way at the terminal (by using colors and Unicode characters).

prettyping is written in bash and awk, and is reported to work on many different systems (Linux, Mac OS X, BSD…), as well as running on different versions of awk (gawk, mawk, nawk, busybox awk).

Read about the history of this project, as well as detailed information, screenshots, videos at: http://denilsonsa.github.io/prettyping/

Requirements

  • bash (tested on 4.20, should work on versions as old as 2008)
  • awk (either gawk, mawk, nawk or busybox awk; should work on gawk versions as old as 2008; should probably work on any other awk implementation)
  • ping (from iputils, or any other version that prints essentially the same output, like Mac OS X ping or oping)
  • Optional dependency on stty or tput to auto-detect the terminal size.

Installation

  1. Download prettyping script and save it anywhere.
  2. Make it executable: chmod +x prettyping

That's all! No root permission is required. You can save and run it from any directory. As long as your user can run ping, bash and awk, then prettyping will work.

Alternatively, you can download the latest tarball from GitHub: Latest release

For people building a prettyping package (for any Linux distro or for Mac OS X), just install the prettyping script into /usr/bin/, or whatever directory is appropriate. No other file is necessary.

prettyping's People

Contributors

denilsonsa avatar doersino avatar yggdr 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

prettyping's Issues

dropped packets dont stand out enough

i realise this is more cosmetic, but i think a no-background "!" does not stand out enough between all the block characters.

Screenshot 2019-04-17 at 16 12 03

I'd like to propose using a black background red bold "X" instead:

Screenshot 2019-04-17 at 16 44 22

Sample ICMP Denied

Migrating this from https://bitbucket.org/denilsonsa/small_scripts/issues/5/sample-icmp-denied

Justin Novack created an issue 2013-10-21

The following is a sample output from OSX 10.8.5 when ICMP is explicitly filtered by a rule on a router.

Request timeout for icmp_seq 1
76 bytes from 10.15.37.33: Communication prohibited by filter
Vr HL TOS  Len   ID Flg  off TTL Pro  cks      Src      Dst
 4  5  00 5400 42ba   0 0000  3a  01 0fb4 10.13.12.25  10.19.22.25

(IPs have been changed to protect the guilty)

The sample is provided to help you with "TODO: Detect the following kinds of message and avoid printing it repeatedly."

Denilson Sá Maia commented 2013-10-21

Do you mean... This pack of 4 lines gets repeated for each ping?

Can you post a little more output, just to give me more context?

Justin Novack commented 2013-10-21

This is the response from "ping xx.xx.xx.xx" when an ACL on an intermediate router drops the ping packet or filters the reply packet.

The full FOUR (4) lines are displayed on each packet.

It won't happen often, but was just something I wanted to include in case you wanted to capture it.

curl command on github pages returns html

curl -O https://github.com/denilsonsa/prettyping/raw/master/prettyping

returns

<html><body>You are being <a href="https://raw.githubusercontent.com/denilsonsa/prettyping/master/prettyping">redirected</a>.</body></html>

What you want is:

curl -O https://raw.githubusercontent.com/denilsonsa/prettyping/master/prettyping

Possibility to turn off statistics

There is no possibility to turn off statistics.

It would be nice to reproduce the same functionality as for --nolegend, but with --nostatistics

Just Ping, Not Pretty

On both OS X and Windows, it's just giving me the text output. No idea why. Using sudo/launching as admin doesn't make a difference.
prettyping fail
Screenshot 2023-06-09 202748

OS X ping6 output isn't parsed correctly

When used with ping6 from OSX (10.11.1), the output is not parsed correctly and no graph is drawn.

pilif@rikku:~| ⇒  ./prettyping -6 www.google.com
▁   0 ▂  10 ▃  20 ▄  30 ▅  40 ▆  50 ▇  60 █  70 ▁  80 ▂  90 ▃ 100 ▄ 110 ▅ 120
 ▆ 130 ▇ 140 █ 150 ▁ 160 ▂ 170 ▃ 180 ▄ 190 ▅ 200 ▆ 210 ▇ 220 █ 230
PING6(56=40+8+8 bytes) 2001:470:26:181:d4f6:1301:6c10:f5a0 --> 2a00:1450:400a:805::1013
16 bytes from 2a00:1450:400a:805::1013, icmp_seq=0 hlim=59 time=12.866 ms
16 bytes from 2a00:1450:400a:805::1013, icmp_seq=1 hlim=59 time=12.086 ms
16 bytes from 2a00:1450:400a:805::1013, icmp_seq=2 hlim=59 time=10.698 ms
16 bytes from 2a00:1450:400a:805::1013, icmp_seq=3 hlim=59 time=12.633 ms
16 bytes from 2a00:1450:400a:805::1013, icmp_seq=4 hlim=59 time=9.783 ms
^C--- www.google.com ping6 statistics ---
5 packets transmitted, 5 packets received, 0.0% packet loss
round-trip min/avg/max/std-dev = 9.783/11.613/12.866/1.185 ms

Option for "large to small" instead of "small to large"

I often use prettyping 8.8.8.8 -i 0.1 --nomulticolor to monitor the network stability. I really like the beautiful output. I start to think about printing them and hanging them on the wall 🤣

Awesome tool!

I guess its just a personal preference, but i would prefer huge green blocks as a representation of »everything is good« and a thinner line for »good pings« till they end in the red question marks. So what i’d like to see is basically a kind of inverted version of the nomulticolor version of prettyping.

If i am alone with this wish — could someone give me a hint were i can hack and hardcode it after forking? I guess its just a change in a single line in some height calculation.

Memory leak

After running vor 24 hrs, a 'awk' process ran by prettyping is using up over 700 MB.

macOS Catalina
Version 10.51.1

zsh --version
zsh 5.7.1 (x86_64-apple-darwin18.2.0)

› bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin19)
Copyright (C) 2007 Free Software Foundation, Inc.

› awk --version
awk version 20070501

[feature request] customizable max value for legend

The max legend currently is 230, so e.g. ping github.com shows all red for me because it's far away from here (China). Also sometimes I experience huge latency even to my router (>1s usually, today I have experienced >50s latency!). I want to tell those terrible times from bearable network lags.

Also I hope there are timestamps (e.g.) at the beginning of each line.

prettyping does not handle Destination Host Unreachable output from ping

I've been documenting the intermittent failures of a radio p2p link, and prettyping is a nice way to see history. I haven't explored the features much yet, but I did notice this:

▁▁▁▁▁▁▁▁▁▁▁▁▁▁!▁▁▁▁▁▁▁▁▁▁▁▁▁▁!▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁
▁▁▁▁▁!▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁!▁▁▁▁▁▁▁▁▁▁▁▁▁
▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁!!!!!!!!!!!!!!▁▁▁▁▁▁▁!!!!!!
7756/110390 ( 7%) lost;    0/   0/1001ms; last:    0ms
20/ 60 (33%) lost;    0/   0/   0/   0ms (last 60)
92 bytes from 192.168.100.204: Destination Host Unreachable
Vr HL TOS  Len   ID Flg  off TTL Pro  cks      Src      Dst
4  5  00 5400 7a91   0 0000  3f  01 19db 192.168.1.235  192.168.100.1
!!!!!!!!!!!!!!!█▁▁▁▁▁!▁▁!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!▁▁▁▁▁▁▁▁▁!▁▁▁▁▁▁▁▁▁▁▁▁!▁▁▁▁
▁▁▁▁▁▁▁!▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁!▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁!▁▁▁▁▁▁▁▁

The Host Unreachable output from ping causes a discontinuity in the output. Could we see a special symbol for this message -- like an X instead of a ! -- instead of this disruptive text?

also, I have yet to try all the flags and options but I would really like an option (maybe it already exists!) to start each line with a time stamp and show exactly 60 pings (1 minute) per line, to make it easier to scroll back and review history. it would of course be user's responsibility to size the xterm to make this work :-)

this is a very handy utility and I am pleased to have discovered it... many thanks to developer.

Doesn't handle duplicate responses

While diagnosing a local networking problem I found that prettyping doesn't handle duplicate ping messages. With the base ping tool I was periodically seeing output like this:

64 bytes from 0.0.0.0: icmp_seq=56890 ttl=64 time=1.174 ms (DUP!)

During this time I had prettyping running side by side in another window. It showed no indication of duplicate responses happening.

Note that I saw this comment in the script:

# TODO? How will prettyping behave if it receives a duplicate response?

I think the current answer is that prettyping does not handle duplicate responses.

It looks like ping considers duplicates a warning. But searching online seems to indicate that duplicates are unexpected, and often associated with link level problems.

It seems like prettyping should recognize duplicates, possibly as an error, and somehow display them.

[BUG] Pinging a stealth host provides no live feedback

When pinging a host that has IDCMP blocked (e.g. one activates the stealth option on Mac OS X's firewall settings), then running prettyping host will just dump the legend and then nothing happens… just sits there.

First when one hits CTRL-C after getting bored prettyping will dump a series of red exclamation marks.

Probably some flush command is missing here when generating that particular output, so things only get flushed in one go at the very end.

Syntax error

➜  Downloads  curl -O https://github.com/denilsonsa/prettyping/raw/master/prettyping
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   139  100   139    0     0    237      0 --:--:-- --:--:-- --:--:--   237
➜  Downloads  chmod +x prettyping
➜  Downloads  ./prettyping www.google.com
./prettyping: line 1: syntax error near unexpected token `<'
./prettyping: line 1: `<html><body>You are being <a href="https://raw.githubusercontent.com/denilsonsa/prettyping/master/prettyping">redirected</a>.</body></html>'

ping:7: fork failed: resource temporarily unavailable

Running on macOS Big Sur 11.6, Darwin BirkhoffMBPR 20.6.0 Darwin Kernel Version 20.6.0: Mon Aug 30 06:12:21 PDT 2021; root:xnu-7195.141.6~3/RELEASE_X86_64 x86_64 i386 MacBookPro13,2 Darwin, I get the following:

$ wget https://raw.githubusercontent.com/denilsonsa/prettyping/master/prettyping
--2021-11-07 14:56:02--  https://raw.githubusercontent.com/denilsonsa/prettyping/master/prettyping
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.109.133, 185.199.110.133, 185.199.111.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.109.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 23396 (23K) [text/plain]
Saving to: ‘prettyping’

prettyping                       100%[========================================================>]  22.85K  12.8KB/s    in 1.8s

2021-11-07 14:56:05 (12.8 KB/s) - ‘prettyping’ saved [23396/23396]

$ chmod +x prettyping

$ ./prettyping 1.1.1.1
0 ▁ 10 ▂ 20 ▃ 30 ▄ 40 ▅ 50 ▆ 60 ▇ 70 █ 80 ▁ 90 ▂ 100 ▃ 110 ▄ 120 ▅ 130 ▆ 140 ▇ 150 █ 160 ▁ 170 ▂ 180 ▃ 190 ▄ 200 ▅ 210 ▆ 220 ▇
230 █ ∞
0 ▁ 10 ▂ 20 ▃ 30 ▄ 40 ▅ 50 ▆ 60 ▇ 70 █ 80 ▁ 90 ▂ 100 ▃ 110 ▄ 120 ▅ 130 ▆ 140 ▇ 150 █ 160 ▁ 170 ▂ 180 ▃ 190 ▄ 200 ▅ 210 ▆ 220 ▇ 230 █ ∞
Last message repeated 2 times.
Last message repeated 2 times.
Last message repeated 3 times.
Last message repeated 3 times.
Last message repeated 2 times.
Last message repeated 2 times.
Last message repeated 3 times.
Last message repeated 2 times.
Last message repeated 3 times.
Last message repeated 3 times.
Last message repeated 2 times.
Last message repeated 3 times.
Last message repeated 2 times.
Last message repeated 3 times.
Last message repeated 2 times.
Last message repeated 3 times.
Last message repeated 2 times.
Last message repeated 2 times.
Last message repeated 3 times.
sh: fork: Resource temporarily unavailable
0 ▁ 10 ▂ 20 ▃ 30 ▄ 40 ▅ 50 ▆ 60 ▇ 70 █ 80 ▁ 90 ▂ 100 ▃ 110 ▄ 120 ▅ 130 ▆ 140 ▇ 150 █ 160 ▁ 170 ▂ 180 ▃ 190 ▄ 200 ▅ 210 ▆ 220 ▇ 230 █ ∞
ping:7: fork failed: resource temporarily unavailable

$ /sbin/ping 1.1.1.1
PING 1.1.1.1 (1.1.1.1): 56 data bytes
64 bytes from 1.1.1.1: icmp_seq=0 ttl=54 time=55.997 ms
64 bytes from 1.1.1.1: icmp_seq=1 ttl=54 time=45.403 ms
64 bytes from 1.1.1.1: icmp_seq=2 ttl=54 time=52.760 ms
^C
--- 1.1.1.1 ping statistics ---
4 packets transmitted, 3 packets received, 25.0% packet loss
round-trip min/avg/max/stddev = 45.403/51.387/55.997/4.433 ms

Looks like prettyping is exhausting shell resources somehow, while the stock ping utility functions normally.

Numbers in legend further from reference bar than next

The small (<100) numbers in the legend are right aligned; they should be left-aligned to be closer to their bar.

e.g. in it looks like 30 is referring to the bar on its right, not the bar on its left, which is further away due to a space.


[deliberately misleadingly cropped]

minor contrib/suggestion: timestamp

I have made a small hack to prettyping which imho renders it way more useful. I leave pp running for hours at a time to watch the performance of the first hop to my (radio) repeater. when I see disruptions (lost packets, long turnarounds) in the history I want to know when they happened; so I added a timestamp at the end of each line.

                       if ( IS_PRINTING_DOTS ) {
                                # HACK, add time stamp to end of each line!
                                printf(system("date \"+ %m.%d.%H:%M\""))
                                # printf( "\n" )
                        }

so the end of a typical line for me is now (example):

▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ 11.02.14:36

unfortunately I don't understand the code quite well enough to make this behave correctly under all circumstances: when the last char of a line is a red bang (lost packet), for some reason I get an extra linefeed and 2 timestamps. the first timestamp is in red (same text formatting as the bang) and then there is a regular (green) timestamp on a line by itself. this is not bothering me much at present :-) since very rarely is there a bang as the last char of the line.

I'd really appreciate it if some future release, someday, had a new flag --timestamp and implemented my crude hack more cleanly so that it doesn't disrupt the output format no matter what the final char of the line is.

Add --version option?

I know there's only been one major release and one patch release since 2015, but I was just surprised to see no command line option to report version information.

I don't suppose it's terribly important, but I thought it was unusual.

Getting the pid of cmd_a in a pipelined command group

# Suppose this:
#
#   cmd_a | cmd_b &

Noticed the comment (and the code) about getting the pid of cmd_a, but the rest of the script doesn't seem to make use of it. Anyway, if you still need to get it (more elegantly), here are two other ways:

# Inside cmd_b
PID=$(ps -p $$ -o pgid=)

# or (tested only on cygwin)
PID=$(</proc/$$/pgid)

# Outside cmd_b
# same command with the above, but replace $$ with $!

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.