Skip to content
Snippets Groups Projects
Commit 8bec423b authored by Sven Mäder's avatar Sven Mäder :speech_balloon:
Browse files

Update prettyping

parent b41c6245
No related branches found
No related tags found
No related merge requests found
...@@ -9,11 +9,14 @@ ...@@ -9,11 +9,14 @@
# * ping (from iputils) # * ping (from iputils)
# #
# More information: # More information:
# http://denilsonsa.github.io/prettyping/ # https://denilsonsa.github.io/prettyping/
# https://github.com/denilsonsa/prettyping # https://github.com/denilsonsa/prettyping
# http://www.reddit.com/r/linux/comments/1op98a/prettypingsh_a_better_ui_for_watching_ping/ # https://old.reddit.com/r/linux/comments/1op98a/prettypingsh_a_better_ui_for_watching_ping/
# Third-party demonstration video: https://www.youtube.com/watch?v=ziEMY1BcikM # Third-party demonstration video: https://www.youtube.com/watch?v=ziEMY1BcikM
# TODO: Test in original-awk:
# https://aur.archlinux.org/packages/original-awk
# https://sources.debian.org/src/original-awk/
# TODO: Adjust how many items in the legend are printed based on the terminal width. # TODO: Adjust how many items in the legend are printed based on the terminal width.
# #
# TODO: Detect the following kinds of message and avoid printing it repeatedly. # TODO: Detect the following kinds of message and avoid printing it repeatedly.
...@@ -35,7 +38,7 @@ ...@@ -35,7 +38,7 @@
# TODO: Autodetect the width of printf numbers, so they will always line up correctly. # TODO: Autodetect the width of printf numbers, so they will always line up correctly.
# #
# TODO: Test the behavior of this script upon receiving out-of-order packets, like these: # TODO: Test the behavior of this script upon receiving out-of-order packets, like these:
# http://www.blug.linux.no/rfc1149/pinglogg.txt # https://web.archive.org/web/20130531083142/http://www.blug.linux.no/rfc1149/pinglogg.txt
# #
# TODO? How will prettyping behave if it receives a duplicate response? # TODO? How will prettyping behave if it receives a duplicate response?
...@@ -75,7 +78,7 @@ EOF ...@@ -75,7 +78,7 @@ EOF
} }
# Thanks to people at #bash who pointed me at # Thanks to people at #bash who pointed me at
# http://bash-hackers.org/wiki/doku.php/scripting/posparams # https://web.archive.org/web/20100301171512/https://bash-hackers.org/wiki/doku.php/scripting/posparams
parse_arguments() { parse_arguments() {
USE_COLOR=1 USE_COLOR=1
USE_MULTICOLOR=1 USE_MULTICOLOR=1
...@@ -176,7 +179,7 @@ parse_arguments() { ...@@ -176,7 +179,7 @@ parse_arguments() {
fi fi
# Workaround for mawk: # Workaround for mawk:
# http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=593504 # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=593504
local version="$(echo | "${AWK_BIN}" -W version 2>&1)" local version="$(echo | "${AWK_BIN}" -W version 2>&1)"
if [[ "${version}" == mawk* ]] ; then if [[ "${version}" == mawk* ]] ; then
AWK_PARAMS+=(-W interactive) AWK_PARAMS+=(-W interactive)
...@@ -639,8 +642,8 @@ BEGIN { ...@@ -639,8 +642,8 @@ BEGIN {
ESC_RED_ON_YELLOW = "\033[43;31m" ESC_RED_ON_YELLOW = "\033[43;31m"
} }
# Other escape codes, see: # Other escape codes, see:
# http://en.wikipedia.org/wiki/ANSI_escape_code # https://en.wikipedia.org/wiki/ANSI_escape_code
# http://invisible-island.net/xterm/ctlseqs/ctlseqs.html # https://invisible-island.net/xterm/ctlseqs/ctlseqs.html
ESC_NEXTLINE = "\n" ESC_NEXTLINE = "\n"
ESC_CURSORUP = "\033[A" ESC_CURSORUP = "\033[A"
ESC_CURSORDOWN = "\033[B" ESC_CURSORDOWN = "\033[B"
...@@ -652,7 +655,7 @@ BEGIN { ...@@ -652,7 +655,7 @@ BEGIN {
ESC_UNSAVEPOS = "\0338" ESC_UNSAVEPOS = "\0338"
# I am avoiding these escapes as they are not listed in: # I am avoiding these escapes as they are not listed in:
# http://vt100.net/docs/vt100-ug/chapter3.html # https://vt100.net/docs/vt100-ug/chapter3.html
#ESC_PREVLINE = "\033[F" #ESC_PREVLINE = "\033[F"
#ESC_SAVEPOS = "\033[s" #ESC_SAVEPOS = "\033[s"
#ESC_UNSAVEPOS = "\033[u" #ESC_UNSAVEPOS = "\033[u"
...@@ -742,7 +745,7 @@ BEGIN { ...@@ -742,7 +745,7 @@ BEGIN {
############################################################ ############################################################
# Main loop # Main loop
{ {
if ( $0 ~ /^[0-9]+ bytes from .*: icmp_[rs]eq=[0-9]+ ttl=[0-9]+ time=[0-9.]+ *ms/ ) { if ( $0 ~ /^[0-9]+ bytes from .*[:,] icmp_[rs]eq=[0-9]+ (ttl|hlim)=[0-9]+ time=[0-9.]+ *ms/ ) {
# Sample line from ping: # Sample line from ping:
# 64 bytes from 8.8.8.8: icmp_seq=1 ttl=49 time=184 ms # 64 bytes from 8.8.8.8: icmp_seq=1 ttl=49 time=184 ms
if ( other_line_times >= 2 ) { if ( other_line_times >= 2 ) {
...@@ -751,7 +754,7 @@ BEGIN { ...@@ -751,7 +754,7 @@ BEGIN {
# $1 = useless prefix string # $1 = useless prefix string
# $2 = icmp_seq # $2 = icmp_seq
# $3 = ttl # $3 = ttl/hlim
# $4 = time # $4 = time
# This must be called before incrementing the last_seq variable! # This must be called before incrementing the last_seq variable!
...@@ -778,7 +781,7 @@ BEGIN { ...@@ -778,7 +781,7 @@ BEGIN {
print_statistics_bar_if_terminal() print_statistics_bar_if_terminal()
} else if ( $0 ~ /^.*onnected to.*, seq=[0-9]+ time=[0-9.]+ *ms/ ) { } else if ( $0 ~ /^.*onnected to.*, seq=[0-9]+ time=[0-9.]+ *ms/ ) {
# Sample line from httping: # Sample line from httping:
# connected to 200.149.119.168:80 (273 bytes), seq=0 time=129.86 ms # connected to 200.149.119.168:80 (273 bytes), seq=0 time=129.86 ms
if ( other_line_times >= 2 ) { if ( other_line_times >= 2 ) {
other_line_finished_repeating() other_line_finished_repeating()
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment