mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-12-25 06:10:20 +00:00
Include ping statistics in default gateway checks.
This commit is contained in:
parent
ac1c299369
commit
3df9c48012
1 changed files with 28 additions and 7 deletions
|
@ -10,6 +10,7 @@
|
||||||
# the Free Software Foundation, either version 2 of the License, or
|
# the Free Software Foundation, either version 2 of the License, or
|
||||||
# (at your option) any later version.
|
# (at your option) any later version.
|
||||||
|
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
######## GLOBAL VARS ########
|
######## GLOBAL VARS ########
|
||||||
DEBUG_LOG="/var/log/pihole_debug.log"
|
DEBUG_LOG="/var/log/pihole_debug.log"
|
||||||
|
@ -116,25 +117,45 @@ function ipCheck {
|
||||||
echo "$IPADDR" >> ${DEBUG_LOG}
|
echo "$IPADDR" >> ${DEBUG_LOG}
|
||||||
|
|
||||||
IP6ADDR=$(ip a | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "inet6") print $(i+1) }')
|
IP6ADDR=$(ip a | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "inet6") print $(i+1) }')
|
||||||
if [ -n "$IP6ADDR" ]
|
if [[ $? = 0 ]]
|
||||||
then
|
then
|
||||||
echo "$IP6ADDR" >> ${DEBUG_LOG}
|
echo "$IP6ADDR" >> ${DEBUG_LOG}
|
||||||
|
else
|
||||||
|
echo "No IPv6 addresses found." >> ${DEBUG_LOG}
|
||||||
fi
|
fi
|
||||||
echo >> ${DEBUG_LOG}
|
echo >> ${DEBUG_LOG}
|
||||||
|
|
||||||
echo "::: Locating default gateway and checking connectivity"
|
echo "::: Locating default gateway and checking connectivity"
|
||||||
GATEWAY=$(ip r | grep default | cut -d ' ' -f 3)
|
GATEWAY=$(ip r | grep default | cut -d ' ' -f 3)
|
||||||
GATEWAY_CHECK=$(ping -q -w 1 -c 1 "${GATEWAY}" > /dev/null && echo ok || echo error)
|
if [[ $? = 0 ]]
|
||||||
echo "Gateway check at ${GATEWAY}:" >> ${DEBUG_LOG}
|
then
|
||||||
|
echo "::: Pinging default IPv4 gateway..."
|
||||||
|
GATEWAY_CHECK=$(ping -q -w 3 -c 3 -n "${GATEWAY}" | tail -n3)
|
||||||
|
if [[ $? = 0 ]]
|
||||||
|
then
|
||||||
|
echo "IPv4 Gateway check:" >> ${DEBUG_LOG}
|
||||||
|
else
|
||||||
|
echo "IPv4 Gateway check failed:" >> ${DEBUG_LOG}
|
||||||
|
fi
|
||||||
echo "$GATEWAY_CHECK" >> ${DEBUG_LOG}
|
echo "$GATEWAY_CHECK" >> ${DEBUG_LOG}
|
||||||
|
fi
|
||||||
|
|
||||||
GATEWAY6=$(ip -6 r | grep default | cut -d ' ' -f 3)
|
GATEWAY6=$(ip -6 r | grep default | cut -d ' ' -f 3)
|
||||||
if [ -n "$GATEWAY6" ]
|
if [[ $? = 0 ]]
|
||||||
then
|
then
|
||||||
GATEWAY6_CHECK=$(ping6 -q -w 1 -c 1 "${GATEWAY6}" > /dev/null && echo ok || echo error)
|
echo "::: Pinging default IPv4 gateway..."
|
||||||
echo "IPv6 Gateway check at ${GATEWAY6}:" >> ${DEBUG_LOG}
|
GATEWAY6_CHECK=$(ping6 -q -w 3 -c 3 -n "${GATEWAY6}" | tail -n3)
|
||||||
echo "$GATEWAY6_CHECK" >> ${DEBUG_LOG}
|
if [[ $? = 0 ]]
|
||||||
|
then
|
||||||
|
echo "IPv6 Gateway check:" >> ${DEBUG_LOG}
|
||||||
|
else
|
||||||
|
echo "IPv6 Gateway check failed:" >> ${DEBUG_LOG}
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
GATEWAY_CHECK="No IPv6 Gateway Detected"
|
||||||
|
fi
|
||||||
|
echo "$GATEWAY_CHECK" >> ${DEBUG_LOG}
|
||||||
|
|
||||||
echo >> ${DEBUG_LOG}
|
echo >> ${DEBUG_LOG}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue