监控http状态,出现非200就发邮件告警!

shell脚本-监控http状态,出现非200就发邮件告警!

功能: 监控http状态,出现非200就发邮件告警!

 

少废话直接上源码代码:

HTTP_Url1="https://www.funet8.com"
HTTP_CODE1=`curl -I -m 10 -o /dev/null -s -w %{http_code}"\n" $HTTP_Url1`
# 不等于200则发送邮件
if [ $HTTP_CODE1 != 200 ]
then
	#echo "亲^_^!你的服务器好像不乖了哦,状态码:[${HTTP_CODE}] ,请尽快处理哦~" | mail -v -s '服务器HTTP监控' ${收件人邮箱}
	/usr/local/bin/sendEmail -f ${发件人邮箱} \
	-t "${收件人邮箱}" \
	-s smtp.163.com \
	-u "$HTTP_Url1-访问出现非200,请检查" \
	-o message-content-type=html \
	-o message-charset=utf8 \
	-xu ${发件人邮箱} \
	-xp ${发件人发件密码}  \
	-m "时间:`date +%F-%T`-域名: $HTTP_Url1 ,访问出现非200,请检查!"
fi

 

每5分钟执行一次:

 

#部署方式
#vi /data/conf/shell/jiankong_http_code.sh
#chmod +x /data/conf/shell/jiankong_http_code.sh
加入crontab定时中
#*/5 * * * *  backupall /data/conf/shell/jiankong_http_code.sh

 

 

参考:http://gong.gg/post-107.html

 

 

暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇