一、通過定時收發email檢測網路連通性
複製代碼 代碼如下:
#/bin/bash
echo "Daily test mail" > state.txt
mail -s Server_State abc@jb51.net < state.txt
rm -df ./state.txt
~
crontab -e
增加如下任務
10 07 * * * /root/checkNKmail &
分時日月周
二、定時檢測網路狀態通過email發送
checkserverstat指令碼內容:
複製代碼 代碼如下:
#/bin/bash
echo "HZtelecomDNS" > state.txt
ping -c 5 202.101.172.35 >> state.txt
echo "
bJU" >> state.txt
ping -c 5 10.X.X.X >> state.txt
echo "ADSL Gateway" >>state.txt
ping -c 5 X.X.X.X >> state.txt
echo "Server_Outside VPN" >>state.txt
ping -c 5 192.168.2.100 >>state.txt
echo "Server_Outside WAN" >> state.txt
ping -c 5 X.X.X.X >> state.txt
echo "VPN in company" >> state.txt
ping -c 5 192.168.1.4 >>state.txt
echo "L2tp at aaa Libweb" >>state.txt
ping -c 5 X.X.X.X & >>state.txt
mail -s Server_State admin@abc.com <state.txt
rm -df ./state.txt
crontab中增加任務
複製代碼 代碼如下:
corntab -e
10 16 * * * /root/CheckWeatherState &
10 09 * * * /root/checkserverstate &
10 13 * * * /root/checkserverstate &
10 17 * * * /root/checkserverstate &