Advertisement
opexxx

check_traceroute.sh

Aug 8th, 2013
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.68 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. ################################################################################
  4. # AUTHOR: Vladimir Vuksan
  5. # E-mail: Check http://vuksan.com/linux/
  6. # License: GPL
  7. ################################################################################
  8. if [ $# -ne 1 ]; then
  9.     echo "Usage: $0 <hostname>"
  10.     exit;
  11. fi     
  12.  
  13. # Get the IP of the host then do traceroute against it.
  14. IP=`/usr/bin/gethostip ${1} | cut -f2 -d" "`
  15.  
  16. TRACEROUTE=`/usr/sbin/traceroute ${IP} 2>&1 | grep "(${IP}) "`
  17.  
  18. RESULT=`echo $TRACEROUTE | grep -c ms`
  19.  
  20. if [ $RESULT -eq 1 ]; then
  21.     echo TRACERT OK: `echo $TRACEROUTE | cut -f4- -d" "`
  22.     exit 0
  23. else
  24.     echo TRACERT CRITICAL: Host unreachable
  25.     exit 2
  26. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement