一、通過定時(shí)收發(fā)email檢測網(wǎng)絡(luò)連通性
復(fù)制代碼 代碼如下:
#/bin/bash
echo "Daily test mail" gt; state.txt
mail -s Server_State abc@jb51.net state.txt
rm -df ./state.txt
~
crontab -e
增加如下任務(wù)
10 07 * * * /root/checkNKmail
分時(shí)日月周
二、定時(shí)檢測網(wǎng)絡(luò)狀態(tài)通過email發(fā)送
checkserverstat腳本內(nèi)容:
復(fù)制代碼 代碼如下:
#/bin/bash
echo "HZtelecomDNS" > state.txt
ping -c 5 202.101.172.35 >> state.txt
echo "
bJU" gt;gt; 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中增加任務(wù)
復(fù)制代碼 代碼如下:
corntab -e
10 16 * * * /root/CheckWeatherState
10 09 * * * /root/checkserverstate
10 13 * * * /root/checkserverstate
10 17 * * * /root/checkserverstate
您可能感興趣的文章:- linux 雙網(wǎng)卡綁定網(wǎng)絡(luò)設(shè)置方法
- Linux網(wǎng)絡(luò)編程之基于UDP實(shí)現(xiàn)可靠的文件傳輸示例
- Linux下用netstat查看網(wǎng)絡(luò)狀態(tài)、端口狀態(tài)
- linux命令學(xué)習(xí)之10個(gè)網(wǎng)絡(luò)命令和監(jiān)控命令
- linux下監(jiān)控網(wǎng)絡(luò)流量的腳本
- Linux基本網(wǎng)絡(luò)配置方法介紹
- Linux 檢測服務(wù)器是否連接著網(wǎng)絡(luò)
- Linux的常用網(wǎng)絡(luò)命令
- Linux下的網(wǎng)絡(luò)監(jiān)聽技術(shù)之一
- Linux模擬網(wǎng)絡(luò)丟包與延遲的方法