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 |
8e8c03 |
t_Log "Running $0 - running traceroute to default gateway"
|
|
Christoph Galuschka |
08145a |
|
|
Christoph Galuschka |
8e8c03 |
# Grabing default gateway of eth0
|
|
Christoph Galuschka |
8e8c03 |
IP=$(ip route list default | grep 'default via ')
|
|
Christoph Galuschka |
8e8c03 |
regex='.*via\ (.*)\ dev.*'
|
|
Christoph Galuschka |
8e8c03 |
if [[ $IP =~ $regex ]]
|
|
Christoph Galuschka |
8e8c03 |
then
|
|
Christoph Galuschka |
8e8c03 |
t_Log "Found default gw (${BASH_REMATCH[1]}) - starting traceroute test"
|
|
Christoph Galuschka |
8e8c03 |
COUNT=$( traceroute -n ${BASH_REMATCH[1]} | grep -c ${BASH_REMATCH[1]} )
|
|
Christoph Galuschka |
08145a |
if [ $COUNT = 2 ]
|
|
Christoph Galuschka |
08145a |
then
|
|
Christoph Galuschka |
8e8c03 |
t_Log "traceroute reached default gw"
|
|
Christoph Galuschka |
08145a |
ret_val=0
|
|
Christoph Galuschka |
08145a |
else
|
|
Christoph Galuschka |
8e8c03 |
t_Log "traceroute didn't reach default gw ${BASH_REMATCH[1]}"
|
|
Christoph Galuschka |
08145a |
ret_val=1
|
|
Christoph Galuschka |
08145a |
fi
|
|
Christoph Galuschka |
08145a |
else
|
|
Christoph Galuschka |
8e8c03 |
t_Log "no default gateway found - skipping"
|
|
Christoph Galuschka |
08145a |
ret_val=0
|
|
Christoph Galuschka |
08145a |
fi
|
|
Christoph Galuschka |
08145a |
|
|
Christoph Galuschka |
08145a |
t_CheckExitStatus $ret_val
|