服务进程和流量检测,web界面检查(shell)
2017-09-29 00:00
176 查看
摘要: 服务进程和流量检测,web界面检查(shell)
#!/bin/bash
export base_dir=`pwd`
export IP=`ifconfig|grep "inet addr:"|awk '{print $2}'|head -n 1|awk -F ":" '{print $2}'`
export time=`date +"%Y%m%d%H%M"`
chechpr(){
#判断服务进程是否存在
pid=`ps -ef|grep tomcat|grep -v grep|awk '{print $2}'`
if [ $? -eq 0 ];then
if [ -n "$pid" ];then
echo "tomcat is alived"
else
echo "tomcat service is not running!">>/$base_dir/$IP\_$time.log
fi
else
echo "ps command run failed!!!">>/$base_dir/$IP\_$time.log
exit 1
fi
#服务流量监测,是否有tcp连接进入
port=`netstat -antp|grep "ESTABLISHED"|grep "8080"`
if [ $? -eq 1 ];then
if [ -s "$port" ];then
echo "tomcat is alived"
else
echo "tomcat is not tcp conncent ">>/$base_dir/$IP\_$time.log
fi
else
echo "netstat command run failed!!!">>/$base_dir/$IP\_$time.log
exit 1
fi
#监测web界面是否正常;
curl "http://x.x.x.x:8080"
if [ $? -eq 0 ];then
echo "web is ok"
else
echo "web is can not conncent!!!">>/$base_dir/$IP\_$time.log
fi
}
checkfile(){
#如果服务进程异常,将相关信息cp到跳板机对应日期目录下面。
cd /$base_dir
if [ $? -eq 0 ];then
if [ -n "$IP\_$time.log" ];then
date=`date +%Y%m%d`
scp $IP\_$time.log root@x.x.x.x:/home/$date/
if [ $? -eq 0 ];then
echo "scp is ok"
else
echo "scp command run failed"
mail -s "scp command run failed" xxxxxxx@qq.com < /$base_dir/$IP\_$time.log
fi
else
echo "service is ok"
fi
else
echo "cd command run failed">>/$base_dir/$IP\_$time.log
exit 1
fi
}
chechpr
checkfile
#!/bin/bash
export base_dir=`pwd`
export IP=`ifconfig|grep "inet addr:"|awk '{print $2}'|head -n 1|awk -F ":" '{print $2}'`
export time=`date +"%Y%m%d%H%M"`
chechpr(){
#判断服务进程是否存在
pid=`ps -ef|grep tomcat|grep -v grep|awk '{print $2}'`
if [ $? -eq 0 ];then
if [ -n "$pid" ];then
echo "tomcat is alived"
else
echo "tomcat service is not running!">>/$base_dir/$IP\_$time.log
fi
else
echo "ps command run failed!!!">>/$base_dir/$IP\_$time.log
exit 1
fi
#服务流量监测,是否有tcp连接进入
port=`netstat -antp|grep "ESTABLISHED"|grep "8080"`
if [ $? -eq 1 ];then
if [ -s "$port" ];then
echo "tomcat is alived"
else
echo "tomcat is not tcp conncent ">>/$base_dir/$IP\_$time.log
fi
else
echo "netstat command run failed!!!">>/$base_dir/$IP\_$time.log
exit 1
fi
#监测web界面是否正常;
curl "http://x.x.x.x:8080"
if [ $? -eq 0 ];then
echo "web is ok"
else
echo "web is can not conncent!!!">>/$base_dir/$IP\_$time.log
fi
}
checkfile(){
#如果服务进程异常,将相关信息cp到跳板机对应日期目录下面。
cd /$base_dir
if [ $? -eq 0 ];then
if [ -n "$IP\_$time.log" ];then
date=`date +%Y%m%d`
scp $IP\_$time.log root@x.x.x.x:/home/$date/
if [ $? -eq 0 ];then
echo "scp is ok"
else
echo "scp command run failed"
mail -s "scp command run failed" xxxxxxx@qq.com < /$base_dir/$IP\_$time.log
fi
else
echo "service is ok"
fi
else
echo "cd command run failed">>/$base_dir/$IP\_$time.log
exit 1
fi
}
chechpr
checkfile
相关文章推荐
- shell实现web服务进程监控并自动重启
- RHEL4- WEB服务(四)apache服务进程和端口的检测
- 通过进程检测服务时脚本文件名不要起要检测的服务名字命名 shell程序从上到下执行若定义函数或引用系统函数需先定义 kill -USR2
- shell监控web服务的多种方案
- 生成(c#检查输入数据、web界面控件)代码的存储过程
- shell脚本-检查服务状态
- 基于lvs的DR模型搭建高可用的web服务,并部署wordpress,(附有脚本实现健康状态检测的代码) 推荐
- 生产环境批量检查web服务是否正常并且发送相关邮件或手机报警
- shell mysql服务状态检查脚本示例
- 【Python】检测Web服务质量
- 用于检测进程的shell脚本代码小结
- NTP服务被利用做流量攻击以及检测预防手段
- web-project 故障查看功能 检测是否启动fmd服务
- 检测web服务质量
- 用于检测进程的shell脚本
- 生产环境WEB服务管理脚本之日志检测脚本
- 【Java】JavaWeb 登录检查及界面跳转
- Shell脚本实现检测进程是否正在运行
- pycurl+web服务质量检测
- 自动检测tomcat服务的shell脚本