700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > shell监控Nginx服务是否存在的脚本

shell监控Nginx服务是否存在的脚本

时间:2018-09-07 17:39:15

相关推荐

shell监控Nginx服务是否存在的脚本

#!/bin/bash

url=“http://127.0.0.1/nginx_status”

culr=/usr/bin/curl

#检测nginx进程是否存在

function ping {

/sbin/pidof nginx | wc -l

}

#检测nginx性能

function active {

$curl $url 2>/dev/null | grep ‘Active’ | awk ‘{print $ NF}’

}

function reading {

$curl $url 2>/dev/null | grep ‘Reading’ | awk ‘{print $ $2}’

}

function writing {

$curl $url 2>/dev/null | grep ‘Writing’ | awk ‘{print $ $4}’

}

function waiting {

$curl $url 2>/dev/null | grep ‘Waiting’ | awk ‘{print $ $6}’

}

function accepts {

$curl $url 2>/dev/null | awk NR= =33 | awk ‘{print $ $1}’

}

function handled {

$curl $url 2>/dev/null | grep NR==3 | awk ‘{print $ $2}’

}

$!

shell脚本部署Nginx

#!/bin/bashPATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/binexport PATH#安装依赖环境yum install -y patch openssl make cmake gcc gcc-c++ gcc-g77 flex bison file libtool libtool-libs autoconf kernel-devel libjpeg libjpeg-devel libpng libpng-devel libpng10 libpng10-devel gd gd-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glib2 glib2-devel bzip2 bzip2-devel libevent libevent-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel vim-minimal nano fonts-chinese gettext gettext-devel ncurses-devel gmp-devel pspell-devel unzip libcap diffutils#安装PCREwget /project/pcre/pcre/8.36/pcre-8.36.tar.gztar zxf pcre-8.36.tar.gzcd pcre-8.36/./configure && make && make installcd …/#安装NGINXwget /download/nginx-1.6.3.tar.gztar zxf nginx-1.6.3.tar.gzcd nginx-1.6.3/./configure --user=nobody --group=nobody --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-ipv6 --with-http_sub_module --with-http_spdy_modulemake && make installcd …/ln -s /usr/local/lib/libpcre.so.1 /libln -s /usr/local/nginx/sbin/nginx /usr/bin/nginxrm -f /usr/local/nginx/conf/nginx.confmkdir -p /home/wwwroot/defaultchmod +w /home/wwwroot/defaultmkdir -p /home/wwwlogschmod 777 /home/wwwlogschown -R nobody:nobody /home/wwwroot/defaultwget -c /lnmp/ext/init.d.nginxcp init.d.nginx /etc/init.d/nginxchmod +x /etc/init.d/nginxchkconfig --level 345 nginx on/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT/sbin/iptables-saveldconfigwget -c /upload/nginx.confmv nginx.conf /usr/local/nginx/conf//etc/init.d/nginx start

作者:王哲理

链接:/p/097acc266cc8

来源:简书

简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。