首页 > 系统服务 > 详细

shell脚本编写

时间:2017-03-23 21:47:15      阅读:280      评论:0      收藏:0      [点我收藏+]

自动部署、初始配置、并启动nginx反向代理服务;自动部署、初始配置、并启动两台web

#!/bin/bash
yum install epel-release -y
yum install nginx -y
ps aux |grep nginx |grep -v grep
if [ $? -ne 0 ]
    then
        systemctl start nginx
fi
sed -ri /^http/a upstream xzhweb\{ /etc/nginx/nginx.conf
sed -ri /^upstream/a server 192.168.16.99 /etc/nginx/nginx.conf
sed -ri /^server/a } /etc/nginx/nginx.conf
sed -ri /^server/a server 192.168.16.175 /etc/nginx/nginx.conf
sed -ri /^\ +location \/ /a proxy_pass http://xzhweb; /etc/nginx/nginx.conf
systemctl stop firewalld
setenforce 0
systemctl restart nginx
if [ $? -ne 0 ]
    then
       echo wellcome to congratulation
fi

技术分享

192.168.16.27 为反向代理

监控脚本:监控每台机器的内存使用率>70%,则输出报警信息

#!/bin/bash
mem_used=`free | awk NR==2{print $3}`
mem_total=`free | awk NR==2{print $2}`
x=`expr "scale=2; $mem_used/$mem_total" |bc -l |cut -d. -f2`
if ((x>70)); then
        echo "Your memory is using $x\%, please handle as soon as possible."
    else
        echo "Your memory usage is $x%, can be at ease use!"
fi    

shell脚本编写

原文:http://www.cnblogs.com/xuzheng940806/p/6607149.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!