Last active
December 25, 2015 22:19
-
-
Save strlcp/7049096 to your computer and use it in GitHub Desktop.
tool to check pingstimes, awk tool is updated by shellscript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/awk -f | |
| { | |
| if ($7 ~ /^time/) { | |
| split ($7, out, "="); | |
| split (out[2], val, "."); | |
| if (val[1] >= 60) { | |
| system("date '+%H-%M-%S---%d/%b/%Y'"); | |
| printf ("%-20s %d \n", out[2], n); | |
| n= 0; | |
| }else printf ("%c", "."); | |
| n++; | |
| } | |
| else { | |
| system("date '+%H-%M-%S---%d/%b/%Y'"); | |
| printf ("%-20s %d \n", $2, n); | |
| n= 0; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| ## fileds $7 is in case of IP $8 -> host | |
| TIMEOUT=3 | |
| if [ "$#" -lt 1 ] | |
| then echo "at least 1 argument required, $# provided" | |
| exit 0 | |
| fi | |
| if [ "$#" -eq 2 ] | |
| then TIMEOUT=$2 | |
| fi | |
| echo "ping host $1 with timeout $TIMEOUT " | |
| # while true ping ? | |
| while (true) | |
| do ping -c 1 $1 | |
| sleep $TIMEOUT | |
| done |\ | |
| awk ' | |
| { | |
| # timevalue is needed because of differnet host/ip output | |
| timevalue = 0; | |
| if ($8 ~ /^time/) { | |
| timevalue = $8; | |
| } | |
| if ($7 ~ /^time/){ | |
| timevalue = $7; | |
| } | |
| # must set limit ping time with shellvar too | |
| if (timevalue){ | |
| split (timevalue, out, "=") | |
| split (out[2], val, "."); | |
| # testing if value is in limit | |
| if (val[1] >= 70) { | |
| system("date '+%H-%M-%S---%d/%b/%Y'"); | |
| # printing the numbers of correct pings, setting counter to zero | |
| printf ("%-20s %d \n", out[2], n); | |
| n=0; | |
| } | |
| # print a dot | |
| else printf ("%c", "."); | |
| n++; | |
| } | |
| # testing for losts | |
| if ($4 ~ /^0/) { | |
| printf("%c", "l"); | |
| losts++; | |
| } if ($4 ~ /^1/) { | |
| if(losts){ | |
| system("date '+%H-%M-%S---%d/%b/%Y'"); | |
| printf ("%-20s %d \n", "losts", losts); | |
| losts=0; | |
| } | |
| } | |
| }' | |
| # | |
| #!/ ping statistics | bytes of data|^($|#)|^rtt/ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment