#!/bin/bash i=0 j=0 subject="web1 80 端口狀態監控" messagelog="web1 80 端口測試成功!!" messagelog1="web1 80 端口測試不成功!!" while [[ $i -le 10 ]] do i=$((${i}+1)) nc -z -w 1 172.20.101.54 80 >/usr/local/monitor/test.txt b=`cat test.txt|grep succeeded|wc -l` if [ $b -ne 0 ]; then j=$((${j}+1)) else exit 0 fi done if [ $j -ge 9 ]; then /usr/local/bin/sendEmail -s 172.20.101.63 -xu [email protected] -xp 1234565 -f [email protected] -t [email protected] -u "$su bject" -m "$messagelog" else /usr/local/bin/sendEmail -s 172.20.101.63 -xu [email protected] -xp 1234565 -f [email protected] -t [email protected] -u "$su bject" -m "$messagelog1" fi
監控80端口腳本
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.