Kping

simple

 * 1) !/bin/bash


 * 1) kping - simple history ping
 * 2) programmed by Kenneth Burgener  (SEP 2011)

if [ "$1" = "" ] ; then echo "Usage: hping [host]" exit 1 fi

while true ; do ping -c 1 -W 1 $1 > /dev/null if [ $? -eq 0 ] ; then echo -n "." sleep 1 else echo -n "-" sleep .05  # ugly to allow ctrl-c fi done

echo ""

line wrap
with new lines at 60 seconds
 * 1) !/bin/bash


 * 1) kping - simple history ping
 * 2) programmed by Kenneth Burgener  (SEP 2011)

if [ "$1" = "" ] ; then echo "Usage: hping [host]" exit 1 fi

count=0 while true ; do ping -c 1 -W 1 $1 > /dev/null if [ $? -eq 0 ] ; then echo -n "." sleep 1 else echo -n "-" sleep .05 fi count=$(( count + 1 )) if [ $count -eq 60 ] ; then echo count=0 fi done

echo ""

audio bell and minute count

 * 1) !/bin/bash


 * 1) kping - visual ping history
 * 2) Programmed by Kenneth Burgener  (SEP 2011)
 * 3) Change Log:
 * 4)   Sep 2012 - Initial version
 * 5)   Oct 2011 - minute wrap
 * 6)   Jul 2012 - added options, audio bell, minute count, restart flag
 * 1)   Jul 2012 - added options, audio bell, minute count, restart flag

UPBELL=false   # audio bell on ping recovery DOWNBELL=false # audio bell on ping loss RESTART=false  # restart minute count on state change

while getopts "aAr" Option do case $Option in       a )            DOWNBELL=true ;;        A ) UPBELL=true ;; r )           RESTART=true ;;        * ) echo "Error: Invalid option!" exit 1 ;;   esac done shift $(($OPTIND - 1))

if [ $# -ne 1 ] ; then echo "Usage: $0 [-a:DOWNBELL] [-A:UPBELL] [-r:RESTART] " echo " UPBELL   - audio bell on ping recovery" echo " DOWNBELL - audio bell on ping loss" echo " RESTART  - restart minute count on state change" exit 1 fi

MAXCOUNT=60 count=0 minutes=0
 * 1) minute and seconds count

NEWSTATE=1 OLDSTATE=1 DORESTART=false
 * 1) restart condition

printf "%03d " $minutes while true ; do

# check ping state ping -c 1 -W 1 $1 > /dev/null if [ $? -eq 0 ] ; then NEWSTATE=1 echo -n "." if $UPBELL ; then echo -en "\a" fi       sleep 1 else NEWSTATE=0 echo -n "-" if $DOWNBELL ; then echo -en "\a" fi       sleep .05 fi

# minute restart condition if [ $RESTART == true -a $NEWSTATE -ne $OLDSTATE ] ; then DORESTART=true fi   OLDSTATE=$NEWSTATE

# minute and second count count=$(( count + 1 )) if [ $count -eq $MAXCOUNT -o $DORESTART == true ] ; then echo minutes=$(( minutes + 1 )) printf "%03d " $minutes count=0 DORESTART=false fi

done

echo ""