Blame tests/p_traceroute/traceroute_test.sh

Christoph Galuschka 08145a
#!/bin/sh
Christoph Galuschka 08145a
# Author: Christoph Galuschka <christoph.galuschka@chello.at>
Christoph Galuschka 08145a
Christoph Galuschka 372989
t_Log "Running $0 - running traceroute to webhost"
Christoph Galuschka 08145a
Christoph Galuschka 372989
# Testing availability of network
Christoph Galuschka 372989
if [ $SKIP_QA_HARNESS -eq 1 ]; then
Christoph Galuschka 372989
  HOST="www.centos.org"
Christoph Galuschka 372989
else
Christoph Galuschka 372989
  HOST="repo.centos.qa"
Christoph Galuschka 372989
fi
Christoph Galuschka 372989
Christoph Galuschka 372989
IP=$(ping -qn -c 1 ${HOST} | grep -i 'ping '${HOST})
Christoph Galuschka 372989
Christoph Galuschka 372989
regex='PING\ '${HOST}'\ \(([0-9.]*)\).*'
Christoph Galuschka 8e8c03
if [[ $IP =~ $regex ]]
Christoph Galuschka 372989
then
Christoph Galuschka 372989
  t_Log "resolved ${HOST} successfully - continuing"
Christoph Galuschka 372989
  ping -q -c 2 -i 0.25 ${HOST}
Christoph Galuschka 372989
  if [ $? = 0 ]
Christoph Galuschka 8e8c03
  then
Christoph Galuschka 372989
    t_Log "$HOST is reachable - continuing"
Christoph Galuschka 372989
    COUNT=$( traceroute -n ${HOST} | grep -c ${BASH_REMATCH[1]} )
Christoph Galuschka 372989
    if [ $COUNT = 2 ]
Christoph Galuschka 372989
    then
Christoph Galuschka 372989
      t_Log "traceroute reached ${HOST} and nslookup seems to work, too"
Christoph Galuschka 372989
      ret_val=0
Christoph Galuschka 372989
    else
Christoph Galuschka 372989
      t_Log "traceroute didn't reach ${HOST}"
Christoph Galuschka 372989
      ret_val=1
Christoph Galuschka 372989
    fi
Christoph Galuschka 08145a
  fi
Christoph Galuschka 08145a
else
Christoph Galuschka 372989
  t_Log "$HOST seems to be unavailable - skipping"
Christoph Galuschka 08145a
  ret_val=0
Christoph Galuschka 08145a
fi
Christoph Galuschka 08145a
Christoph Galuschka 372989
echo $ret_val
Christoph Galuschka 372989
#t_CheckExitStatus $ret_val