Created
August 2, 2022 06:21
-
-
Save strizhechenko/72813d803553c842606ab1e98b7a6310 to your computer and use it in GitHub Desktop.
Красивая проверка что именно там в сети опять отвалилось
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -euE | |
SUCCESS="\\033[1;32m" | |
HEADER="\\033[1;34m" | |
FAILURE="\\033[1;31m" | |
NORMAL="\\033[0;39m" | |
check() { | |
echo -ne "$HEADER$2...$NORMAL" | |
cmd="ping -w 2 -qc 1 $1" | |
[ "$2" = 'ARP' ] && cmd="arping -c 1 -I INET $1" | |
if ! $cmd &>/dev/null; then | |
echo -e "$FAILURE FAIL $1$NORMAL" | |
return 1 | |
fi | |
echo -e "$SUCCESS OK$NORMAL" | |
return 0 | |
} | |
ARP=192.168.0.1 | |
LAN=192.168.0.1 | |
ISP=gate.of.your.provider | |
WAN=8.8.8.8 | |
DNS=ya.ru | |
VPN=gate.of.your.vpn | |
for resource in ARP LAN ISP WAN DNS VPN; do | |
check "${!resource}" "$resource" | |
done | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment