diff --git a/check_webservice_load.sh b/check_webservice_load.sh index e7170ad..be9e577 100755 --- a/check_webservice_load.sh +++ b/check_webservice_load.sh @@ -176,6 +176,8 @@ detect_os # Some default values # DEFAULT_CONFLICTING_SCRIPTS="/root/bin/monitoring/check_local_webservice.sh" +DEFAULT_TIMEOUT_CHECK_WEBSITE=10 +DEFAULT_TIMEOUT_CHECK_PHP=10 if [[ ! -f "$conf_file" ]]; then echo "" @@ -188,6 +190,9 @@ else source "$conf_file" fi +[[ -n "$TIMEOUT_CHECK_WEBSITE" ]] || TIMEOUT_CHECK_WEBSITE="$DEFAULT_TIMEOUT_CHECK_WEBSITE" +[[ -n "$TIMEOUT_CHECK_PHP" ]] || TIMEOUT_CHECK_PHP="$DEFAULT_TIMEOUT_CHECK_PHP" + [[ -n "$CONFLICTING_SCRIPTS" ]] || CONFLICTING_SCRIPTS="$DEFAULT_CONFLICTING_SCRIPTS" @@ -2063,7 +2068,7 @@ if $check_apache ; then else - if ! $(curl -Is -m 10 http://$curl_check_host | head -n 1 | grep "200 OK" > /dev/null) ; then + if ! $(curl -Is -m $TIMEOUT_CHECK_WEBSITE http://$curl_check_host | head -n 1 | grep "200 OK" > /dev/null) ; then echo -e "\nApache 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 @@ -2108,7 +2113,7 @@ if $check_nginx ; then else if ! $ommit_curl_check_nginx ; then - if ! $(curl -Is -m 10 http://$curl_check_host | head -n 1 | grep "200" > /dev/null) ; then + if ! $(curl -Is -m $TIMEOUT_CHECK_WEBSITE http://$curl_check_host | head -n 1 | grep "200" > /dev/null) ; then # Same but via SSL # @@ -2172,11 +2177,11 @@ if $check_php_fpm ; then elif [[ -n ${php_fpm_ping_path[$_version]} ]] ; then - if ! $(curl -Is -m 10 http://${curl_check_host}/${php_fpm_ping_path[$_version]} | head -n 1 | grep "200" > /dev/null) ; then + if ! $(curl -Is -m $TIMEOUT_CHECK_PHP http://${curl_check_host}/${php_fpm_ping_path[$_version]} | head -n 1 | grep "200" > /dev/null) ; then # Same via SSL # - if ! $(curl --insecure -Is -m 10 https://${curl_check_host}/${php_fpm_ping_path[$_version]} | head -n 1 | grep "200" > /dev/null) ; then + if ! $(curl --insecure -Is -m $TIMEOUT_CHECK_PHP https://${curl_check_host}/${php_fpm_ping_path[$_version]} | head -n 1 | grep "200" > /dev/null) ; then echo -e "\nPHP-FPM v$_version seems to be running, but is NOT responding! - Try to restart service.." >> $LOCK_DIR/extra_msg.txt echo -e "====================================================================================" >> $LOCK_DIR/extra_msg.txt diff --git a/conf/check_webservice_load.conf.sample b/conf/check_webservice_load.conf.sample index 7fddb9b..9c9b610 100644 --- a/conf/check_webservice_load.conf.sample +++ b/conf/check_webservice_load.conf.sample @@ -58,6 +58,26 @@ check_php_fpm=true check_redis=false check_website=false + +# TIMEOUT_CHECK_WEBSITE +# +# Maximum time in seconds that you allow for the response from the webserver. +# +# Defaults to: +# TIMEOUT_CHECK_WEBSITE=10 +# +#TIMEOUT_CHECK_WEBSITE=10 + +# TIMEOUT_CHECK_PHP +# +# Maximum time in seconds that you allow for the response from the webserver. +# +# Defaults to: +# TIMEOUT_CHECK_PHP=10 +# +#TIMEOUT_CHECK_PHP=10 + + # - If service is not listen on 127.0.0.1/loclhost, curl check must # - be ommited # -