Skip to content

Instantly share code, notes, and snippets.

@nilskoppelmann
Last active August 29, 2015 14:13
Show Gist options
  • Save nilskoppelmann/0d1e5f6572ea6118e228 to your computer and use it in GitHub Desktop.
Save nilskoppelmann/0d1e5f6572ea6118e228 to your computer and use it in GitHub Desktop.
netCon - neat tool to test network connections
#example list of severs/sites to ping
blog.fefe.de
google.com
spiegel.de
#set defaults
file=./.netConList
count=3

netCon - Test network-connection

Configuration-file: .netConrc (default)
List-file: .netConList (default in .netConrc)

####Configurations:

  • List: each line should contain a servername
  • RC-File: vars are defined here (shell-syntax)
  • Comments: # (shell-syntax)

####Options:

-c Number of pings to each server
-f File containing the list of servers to ping

####Examples:

  • To quickly get a pingback from a certain server which isn't in a file you can simply do the following:
    netCon -f <(echo 'test.server.tld')
  • You can also modify the amount of packets to be sent:
    netCon -c n (but please do NOT 'spam')

###ToDo

  • Directly pass multiple server-addresses to the script without the need of an extra file
#!/bin/sh
#init defaults
. ./.netConrc
while [ $# -gt 0 ]
do
case "$1" in
-f) file="$2"; shift;;
-c) count="$2"; shift;;
--) shift; break;;
-*) echo >&2 \
"usage: $0 [-f file] [-c count]"
exit 1;;
*) break;; # terminate while loop
esac
shift
done
while read -r line
do
[[ $line = \#* ]] && continue
ping -c $count $line | tail -3
done < $file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment