Automatic deployment, initial configuration, and start of Nginx reverse proxy service, automatic deployment, initial configuration, and launch of two Web
#!/bin/BashYum InstallEpel-release-yYum InstallNginx-yPSAux |grepNginx |grep-V'grep'if[$?-ne0 ] Thensystemctl start Nginxfised-ri'/^http/a upstream xzhweb\{'/etc/nginx/nginx.confsed-ri'/^upstream/a Server 192.168.16.99'/etc/nginx/nginx.confsed-ri'/^server/a}'/etc/nginx/nginx.confsed-ri'/^server/a Server 192.168.16.175'/etc/nginx/nginx.confsed-ri'/^\ +location \/A proxy_pass http://xzhweb;'/etc/nginx/nginx.confsystemctl Stop Firewalldsetenforce0systemctl Restart Nginxif[$?-ne0 ] Then EchoWellcome to congratulationfi
192.168.16.27 for reverse proxy
Monitoring script: Monitor the memory usage of each machine >70%, then output alarm information
#! /bin/bashmem_used=` Free|awk 'Nr==2{print}'' Mem_total=` Free|awk 'Nr==2{print $}'' x=`Expr "scale=2, $mem _used/$mem _total"|bc-l |Cut-D.-F2 'if((x> -)); Then Echo "Your memory is using the $x \%, please handle as soon as possible." Else Echo "Your memory usage is $x%, can are at ease use!"fi
Shell Script Writing