diff --git a/check_webservice_load.sh b/check_webservice_load.sh index 06d99e4..de20f05 100755 --- a/check_webservice_load.sh +++ b/check_webservice_load.sh @@ -20,6 +20,9 @@ check_php_fpm=false check_redis=false check_website=false +ommit_curl_check_nginx=false +vserver_guest=false + if [[ ! -f "$conf_file" ]]; then echo "" echo -e " [ Fatal ] Configuration file '$(basename ${conf_file})' not found!" @@ -156,12 +159,16 @@ fi # - Systemd supported ? ## - -systemd=$(which systemd) -systemctl=$(which systemctl) - systemd_supported=false -if [[ -n "$systemd" ]] && [[ -n "$systemctl" ]] ; then - systemd_supported=true + +if ! $vserver_guest ; then + + systemd=$(which systemd) + systemctl=$(which systemctl) + + if [[ -n "$systemd" ]] && [[ -n "$systemctl" ]] ; then + systemd_supported=true + fi fi @@ -638,13 +645,32 @@ stop_nginx() { fi for _PID in $PIDS ; do - kill -9 $_PID > /dev/null 2>&1 + kill $_PID > /dev/null 2>&1 done + sleep 2 PIDS=$(ps aux | grep "$NGINXD" | grep -v grep | awk '{print$2}') i=i+1 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() { @@ -1570,7 +1596,7 @@ if $check_nginx ; then echo -e "\nChecking Nginx webservice on \"`hostname -f`\".." 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 echo -e "\nNginx Webservice is not running! - Try to start it.." > $LOCK_DIR/extra_msg.txt @@ -1581,20 +1607,30 @@ if $check_nginx ; then restart_nginx 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 - echo -e "\nNginx Webservice seems to be running, but is NOT responding! - Try to restart service.." >> $LOCK_DIR/extra_msg.txt - echo -e "=======================================================================================" >> $LOCK_DIR/extra_msg.txt + 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 "=======================================================================================" >> $LOCK_DIR/extra_msg.txt - error "Nginx Webservice seems to be running, but is NOT responding! - Try to restart service.." + error "Nginx Webservice seems to be running, but is NOT responding! - Try to restart service.." - restart_nginx + restart_nginx + + else + + if $LOGGING ; then + ok "Nginx Webserver on \"`hostname -f`\" seems to be running.." + fi + + fi else if $LOGGING ; then ok "Nginx Webserver on \"`hostname -f`\" seems to be running.." fi + fi fi fi