Skip to content

Instantly share code, notes, and snippets.

@FATESAIKOU
Created August 25, 2024 06:01
Show Gist options
  • Save FATESAIKOU/0ed031996724c7ae117afee587fa3b95 to your computer and use it in GitHub Desktop.
Save FATESAIKOU/0ed031996724c7ae117afee587fa3b95 to your computer and use it in GitHub Desktop.
Script to mention you fixing the network issue
#!/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