#!/bin/bash #auto monitor #write by 2015-8-9 IP=ifconfig |grep "Bcast" |awk '{print $2}'|sed 's/addr://g' DATE=`date` EMAIL=email.txt cat << EOF ######################################################## ######## wlecome to use auto ########### ######## monitor scripts ########### ######################################################## EOF if [ -z $1 ];then echo -e "\033[32mUsage :{sh $0 nginx|http|mysql|ntp|list.txt}\033[0m" sleep 2 exit fi if [ -f "$1" -a "$1" == "list.txt" ];then for i in `cat list.txt` do count=`ps -ef |grep $i|grep -v grep|grep -v "$0"|wc -l` if [ $count -eq 0 ];then cat >$EMAIL << EOF +++++++++++++++++++SERVER MONITOR++++++++++++++++++++++++ 通知类型:故障 服务:$i 主机:$IP 状态:警告 日期:$DATE 额外信息: CRITTACL + $i server is no running ,please check.. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ EOF echo -e "\033[32mthe monitor $i warning ,please check..\033[0m" mail -s "$IP $i warning" 752840649@qq.com < $EMAIL >>/dev/null 2>&1 else echo -e "\033[32mthe monitor $i is ok...\033[0m" fi done else count=`ps -ef |grep $1|grep -v grep|grep -v $0|wc -l` if [ $count -eq 0 ];then cat >$EMAIL << EOF +++++++++++++++++++SERVER MONITOR++++++++++++++++++++++++ 通知类型:故障 服务:$1 主机:$IP 状态:警告 日期:$DATE 额外信息: CRITTACL + $1 server is no running ,please check.. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ EOF dos2unix $EMAIL echo -e "\033[32mthe monitor $1 warning ,please check..\033[0m" mail -s "$IP $1 warning" 752840649@qq.com < $EMAIL >>/dev/null 2>&1 else echo -e "\033[32mthe monitor $1 is ok...\033[0m" fi fi
监控报警脚本
原创Anonymous123 博主文章分类:shell脚本 ©著作权
©著作权归作者所有:来自51CTO博客作者Anonymous123的原创作品,请联系作者获取转载授权,否则将追究法律责任
上一篇:恶意登录ip添加到防火墙
下一篇:常用监控脚本
![](https://ucenter.51cto.com/images/noavatar_middle.gif)
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
错误日志监控报警脚本
错误日志监控报警脚本
错误日志 监控 monitor mutt 邮件报警 -
nagios 流量监控和报警的shell脚本
配合nagios实现异常流量报警的shell 脚本
nagios脚本 异常流量报警