Created
August 25, 2024 06:01
-
-
Save FATESAIKOU/0ed031996724c7ae117afee587fa3b95 to your computer and use it in GitHub Desktop.
Script to mention you fixing the network issue
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
#!/usr/bin/env bash | |
conn_fail_threshold=5 | |
conn_fail_cnt=0 | |
while true; | |
do | |
curl -m1 'https://www.google.com' 1>/dev/null 2>&1 | |
if [ $? -ne 0 ]; | |
then | |
(( conn_fail_cnt += 1 )) | |
echo "[$(date)] Connection NG: $conn_fail_cnt" | |
else | |
echo "[$(date)] Connection OK" | |
conn_fail_cnt=0 | |
fi | |
if [ $conn_fail_cnt -ge $conn_fail_threshold ]; | |
then | |
osascript -e 'tell app "System Events" to display dialog "Check network connection!"' | |
conn_fail_cnt=0 | |
fi | |
sleep 1 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment