42 lines
1.2 KiB
Bash
42 lines
1.2 KiB
Bash
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
|