check_webservice_load.sh:
- support of parameter ommit_curl_check_nginx (don't make additional curl check) - fix error for VServer guet systems (set 'systemd_supported* to false). - fix error at stopping nginx (kill remaining subprocesses 'nginx:').
This commit is contained in:
		| @@ -20,6 +20,9 @@ check_php_fpm=false | |||||||
| check_redis=false | check_redis=false | ||||||
| check_website=false | check_website=false | ||||||
|  |  | ||||||
|  | ommit_curl_check_nginx=false | ||||||
|  | vserver_guest=false | ||||||
|  |  | ||||||
| if [[ ! -f "$conf_file" ]]; then | if [[ ! -f "$conf_file" ]]; then | ||||||
|    echo "" |    echo "" | ||||||
|    echo -e "   [ Fatal ] Configuration file '$(basename ${conf_file})' not found!" |    echo -e "   [ Fatal ] Configuration file '$(basename ${conf_file})' not found!" | ||||||
| @@ -156,12 +159,16 @@ fi | |||||||
|  |  | ||||||
| # - Systemd supported ? | # - Systemd supported ? | ||||||
| ## - | ## - | ||||||
| systemd=$(which systemd) |  | ||||||
| systemctl=$(which systemctl) |  | ||||||
|  |  | ||||||
| systemd_supported=false | systemd_supported=false | ||||||
| if [[ -n "$systemd" ]] && [[ -n "$systemctl" ]] ; then |  | ||||||
|  | if ! $vserver_guest ; then | ||||||
|  |  | ||||||
|  |    systemd=$(which systemd) | ||||||
|  |    systemctl=$(which systemctl) | ||||||
|  |  | ||||||
|  |    if [[ -n "$systemd" ]] && [[ -n "$systemctl" ]] ; then | ||||||
|       systemd_supported=true |       systemd_supported=true | ||||||
|  |    fi | ||||||
| fi | fi | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -638,13 +645,32 @@ stop_nginx() { | |||||||
|       fi |       fi | ||||||
|  |  | ||||||
|       for _PID in $PIDS ; do |       for _PID in $PIDS ; do | ||||||
|          kill -9 $_PID > /dev/null 2>&1 |          kill $_PID > /dev/null 2>&1 | ||||||
|       done |       done | ||||||
|  |  | ||||||
|       sleep 2 |       sleep 2 | ||||||
|       PIDS=$(ps aux | grep "$NGINXD" | grep -v grep | awk '{print$2}') |       PIDS=$(ps aux | grep "$NGINXD" | grep -v grep | awk '{print$2}') | ||||||
|       i=i+1 |       i=i+1 | ||||||
|    done |    done | ||||||
|  |  | ||||||
|  |    SUB_PIDS=$(ps aux | grep "$(basename $NGINXD):" | grep -v grep | awk '{print$2}')  | ||||||
|  |  | ||||||
|  |    if [[ "X${SUB_PIDS}X" != 'XX' ]]; then | ||||||
|  |  | ||||||
|  |       echo "" >> $LOCK_DIR/extra_msg.txt | ||||||
|  |       echo -e "\t[ Error ]: Found processes '$(basename $NGINXD):'." >> $LOCK_DIR/extra_msg.txt | ||||||
|  |       echo "" >> $LOCK_DIR/extra_msg.txt | ||||||
|  |       echo -e "\t[ Info ];  Going to kill remaining nginx-processes.." >> $LOCK_DIR/extra_msg.txt | ||||||
|  |       echo "" >> $LOCK_DIR/extra_msg.txt | ||||||
|  |  | ||||||
|  |       error "Found processes '$(basename $NGINXD):'." | ||||||
|  |       info "Going to kill processes '$(basename $NGINXD):'.." | ||||||
|  |  | ||||||
|  |       for _PID in $SUB_PIDS ; do | ||||||
|  |          kill $_PID > /dev/null 2>&1 | ||||||
|  |       done | ||||||
|  |    fi | ||||||
|  |  | ||||||
| } | } | ||||||
|  |  | ||||||
| stop_mysql() { | stop_mysql() { | ||||||
| @@ -1570,7 +1596,7 @@ if $check_nginx ; then | |||||||
|       echo -e "\nChecking Nginx webservice on \"`hostname -f`\".." |       echo -e "\nChecking Nginx webservice on \"`hostname -f`\".." | ||||||
|    fi |    fi | ||||||
|  |  | ||||||
|    PID=`ps aux | grep "$NGINXD " | grep -e "^root" | grep -v grep | awk '{print$2}'` |    PID=`ps aux | grep "$NGINXD" | grep -e "^root" | grep -v grep | awk '{print$2}'` | ||||||
|    if [ "X${PID}X" = "XX" ];then |    if [ "X${PID}X" = "XX" ];then | ||||||
|  |  | ||||||
|       echo -e "\nNginx Webservice is not running! - Try to start it.." > $LOCK_DIR/extra_msg.txt |       echo -e "\nNginx Webservice is not running! - Try to start it.." > $LOCK_DIR/extra_msg.txt | ||||||
| @@ -1581,6 +1607,7 @@ if $check_nginx ; then | |||||||
|       restart_nginx |       restart_nginx | ||||||
|  |  | ||||||
|    else |    else | ||||||
|  |       if ! $ommit_curl_check_nginx ; then | ||||||
|  |  | ||||||
|          if ! $(curl -Is -m 10 http://$curl_check_host | head -n 1 | grep "200 OK" > /dev/null) ; then |          if ! $(curl -Is -m 10 http://$curl_check_host | head -n 1 | grep "200 OK" > /dev/null) ; then | ||||||
|             echo -e "\nNginx Webservice seems to be running, but is NOT responding! - Try to restart service.." >> $LOCK_DIR/extra_msg.txt |             echo -e "\nNginx Webservice seems to be running, but is NOT responding! - Try to restart service.." >> $LOCK_DIR/extra_msg.txt | ||||||
| @@ -1595,6 +1622,15 @@ if $check_nginx ; then | |||||||
|             if $LOGGING ; then |             if $LOGGING ; then | ||||||
|                ok "Nginx Webserver on \"`hostname -f`\" seems to be running.." |                ok "Nginx Webserver on \"`hostname -f`\" seems to be running.." | ||||||
|             fi |             fi | ||||||
|  |  | ||||||
|  |          fi | ||||||
|  |  | ||||||
|  |       else | ||||||
|  |  | ||||||
|  |          if $LOGGING ; then | ||||||
|  |             ok "Nginx Webserver on \"`hostname -f`\" seems to be running.." | ||||||
|  |          fi | ||||||
|  |  | ||||||
|       fi |       fi | ||||||
|    fi |    fi | ||||||
| fi | fi | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user