recipe_gentoo/recipes/recipe_check_ping.sh

42 lines
1.2 KiB
Bash
Raw Normal View History

2019-03-24 15:56:17 +01:00
echo "-------------------------------------------------"
echo -e "----------------- ${BLUE}CHECK PING${NC} --------------------"
echo -e "-------------------------------------------------\n"
# Test ping
for name_to_ping in ${NAMES_TO_RESOLV_AND_PING[@]};
do
echo -e "Check ping ${BLUE}${name_to_ping}${NC}"
# Check ping with IPv4
ping -c1 -4 ${name_to_ping} &>/dev/null
# Return Code
RC=$?
# Ping with IPv4 failed
if [ $RC -ne 0 ]
then
PING_FAILED="${PING_FAILED} (IPv4)${name_to_ping}"
echo -e "${RED}Ping (IPv4) ${name_to_ping} FAILED : check KO${NC}\n"
# Ping with IPv4 succeded
else
echo -e "${GREEN}Ping (IPv4) ${name_to_ping} SUCCEDED : check OK${NC}\n"
fi
# Check ping with IPv6
ping -c1 -6 ${name_to_ping} &>/dev/null
# Return Code
RC=$?
# Ping with IPv6 failed
if [ $RC -ne 0 ]
then
PING_FAILED="${PING_FAILED} (IPv6)${name_to_ping}"
echo -e "${RED}Ping (IPv6) ${name_to_ping} FAILED : check KO${NC}\n"
# Ping with IPv6 succeded
else
echo -e "${GREEN}Ping (IPv6) ${name_to_ping} SUCCEDED : check OK${NC}\n"
fi
done