监控服务器swap并重启php的Shell脚本
2014-03-06 00:00
477 查看
折中一下,写个脚本监控swap吧,放在crontab里面,2小时执行一次,世界安静了,再也没有烦人的报警短信了
注:if /etc/init.d/php5-fpm restart|grep -c fail 这一句中间的命令换成你自己的即可
#!/bin/bash function usage { echo "Usage: $0" echo "e.g. $0 1500" exit } if [ $# -lt 1 ];then usage fi typeset -i nowSwap limitSwap limitSwap=$1 nowSwap=$(free -m|grep "Swap"|sed -e "s/\(.*\)\:\(.*\)/\2/g"|awk '{print $2}') if [ $limitSwap -lt $nowSwap ];then while [ 1 ] do if /etc/init.d/php5-fpm restart|grep -c fail then echo "[$(date +%Y/%m/%d0-%H:%M)]restart php failed" else echo "[$(date +%Y/%m/%d-%H:%M)]restart php successful!" break fi done fi
注:if /etc/init.d/php5-fpm restart|grep -c fail 这一句中间的命令换成你自己的即可
相关文章推荐
- 监控服务器swap并重启php的Shell脚本
- 监控php-fpm并自动重启服务的shell脚本
- 自动监控apache服务状态并重启的shell脚本
- 使用shell脚本进行服务器系统监控——文件系统监控(2)
- 智能监测自动重启Apache服务器的Shell脚本
- 监控服务器连通性的shell脚本
- Shell脚本实现监控swap空间使用情况和查看占用swap的进程
- Linux 服务器系统监控脚本 Shell【转】
- 用shell+sendmail实现服务器监控报警小脚本
- 使用shell脚本进行服务器系统监控——文件系统监控(3)
- Shell脚本监控服务器pts登录情况记录为日志并邮件通知【CentOS 6.5】
- 用shell脚本实现监控程序自动重启
- shell脚本 监控 web服务器状态
- shell自动监控重启tomcat脚本
- 使用shell脚本进行服务器系统监控——文件系统监控(4)
- 使用shell脚本进行服务器系统监控——文件系统监控(1)
- 用Shell脚本监控服务器并发邮件报警
- shell自动监控重启Tomcat脚本,每一分钟检查
- 网站状态异常时自动重启php-fpm的shell脚本