监控web服务(http,本地 / 远程监控nginx)
2024-08-31 15:17:32
监控 httpd 服务一:
#!/bin/bash
#描述: 秒级别监控 http 服务 while [ 1 -lt 2 ]
do
sleep 10
ai=`netstat -ntl | grep "\<80\>" | wc -l` if [ $ai -eq 0 ]
then
echo "WARNING!!! `date` httpd is stoped" >> /root/http.log
systemctl restart httped >/dev/null 2>> /root/http.log
fi
done
监控 httpd 服务二:
#!/bin/bsah
#监控web服务的状态 timeout=5 #定义wget的访问超时时间,超时就退出
fails=0
success=0
while true
do
wget --timeout=$timeout --tries=1 http://www.qq.com -q -O /dev/null #--tries自动重试 if [ $? -ne 0 } #如果访问不成功,失败次数+1,若成功,成功次数+1
then
let fails=fails+1
else
let success+=1
fi if [ $success -ge 1 ] #如果成功次数大于1,则输出成功信息
then
echo success!
exit 0
fi if [ $falis -ge 2 ] #如果失败次数大于2,则报警
then
critical='sys is down'
echo $critical|tee|mail -s "$critical" 15570361605@163.com
exit 2
fi
done
监控nginx服务(本地 / 远程)
#!/bin/bash
#监控nginx服务 #[`rpm -q nmap | wc -l` -lt 1] && yum install -y nmap &>/dev/null
#num=`nmap 127.0.0.1 -p 80 2>/dev/null | grep open | wc -l` #远程监测端口 num=`netstat -ntlp | grep nginx | wc -l`
if [ $num -gt o ]
then
echo "nginx is running..."
else
echo "nginx is stoped..."
/etc/init.d/nginx start >/dev/null 2>> /root/nginx.log
fi
最新文章
- expect基本使用方法
- 使用parted给大于2T的磁盘分区
- 使用Photoshop不改变图片尺寸,保存图片到30K以下的解决办法
- poj3744 Scout YYF I
- HBase体系结构
- 笔记本Linux推荐
- iOS-给UIView添加点击事件
- 修改weblogic PermGen
- jquery实现点击页面其他地方隐藏指定元素
- SQL Server查询死锁并KILL
- 深度解析EM菌
- flashback table恢复数据
- 把Excel数据导入到数据库
- (92) Web Crawling: How can I build a web crawler from scratch? - Quora
- 【Alpha 阶段】后期测试及补充(第十一、十二周)
- H5 仿ios select滚动选择器。框架。
- Parameter &#39;name&#39; not found. Available parameters are [arg1, arg0, param1, param2]
- python网络图片爬取存储全代码
- stack堆栈容器、queue队列容器和priority_queue优先队列容器(常用的方法对比与总结)
- Oracle如何实现跨库查询
热门文章
- 关于github里readme编辑的方法
- select标签下option标签里value属性有什么用以及和text的区别
- 优动漫PAINT-凌霄花画法
- 比较好的Dapper封装的仓储实现类 来源:https://www.cnblogs.com/liuchang/articles/4220671.html
- h5 input失去焦点软键盘把页面顶起
- FFT&;NTT学习笔记
- pyinstall 常见错误
- BZOJ 5254 [Fjwc2018]红绿灯 (线段树)
- Axios 使用时遇到的问题
- 使用vue实现简单键盘,支持移动端和pc端