First, through the timing of email to detect network connectivity
Copy Code code as follows:
#/bin/bash
echo "Daily Test mail" > State.txt
Mail-s Server_state Abc@jb51.net < State.txt
Rm-df./state.txt
~
Crontab-e
Add the following tasks
* * */root/checknkmail &
Time-Sharing and Lunar Week
Second, timed detection network status by e-mail
Checkserverstat Script content:
Copy Code code as follows:
#/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
Additional tasks in crontab
Copy Code code as follows:
Corntab-e
* * */root/checkweatherstate &
* * */root/checkserverstate &
* * */root/checkserverstate &
* * */root/checkserverstate &