監控無線網路
ubuntu-mate@ubuntu-mate:~$ nmcli device wifi connect eduroam
裝置「wlp4s0」已成功以「2439cc43-4b15-4c4e-8102-d036ab80d430」啟用。
ubuntu-mate@ubuntu-mate:~$ nmcli device wifi connect TN-Teacher
裝置「wlp4s0」已成功以「77b6a030-977c-4aa5-b86f-9c0611eaf8ce」啟用。
#檢查dns
dig www.google.com | grep ^www.google.com | awk '{print $NF}'
fping 8.8.8.8
fping www.google.com
建立定期檢查shell程式
#!/bin/bash
for wifi in TN-Teacher eduroam
do
timeout 15 nmcli device wifi connect $wifi
if [ $? -eq 0 ]; then
echo "$wifi 連線成功"
if [ "`fping 8.8.8.8 | grep 'is alive'`" ]; then
echo "outside IP 連線 OK"
fi
if [ "`fping www.google.com | grep 'is alive'`" ]; then
echo "網際網路連線OK"
fi
fi
doneLast updated
Was this helpful?