check_webservice_load.sh: change check of PostgreSQL service.

This commit is contained in:
Christoph 2024-05-21 12:14:07 +02:00
parent 4b77adbd93
commit 8c771b6ec4
3 changed files with 38 additions and 6 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
*.swp
/conf/*.conf
/conf/*.conf.*
/BAK/*

View File

@ -183,6 +183,8 @@ DEFAULT_TIMEOUT_CHECK_PHP=10
DEFAULT_mysql_credential_args="--login-path=local"
DEFAULT_mariadb_credential_args=""
DEFAULT_postgresql_port=5432
if [[ ! -f "$conf_file" ]]; then
echo ""
echo -e " [ Fatal ] Configuration file '$(basename ${conf_file})' not found!"
@ -202,6 +204,8 @@ fi
[[ -n "$mysql_credential_args" ]] || mysql_credential_args="$DEFAULT_mysql_credential_args"
[[ -n "$mariadb_credential_args" ]] || mariadb_credential_args="$DEFAULT_mariadb_credential_args"
[[ -n "$postgresql_port" ]] || postgresql_port="$DEFAULT_postgresql_port"
# - Stop here, if these give scripts are running
# -
@ -2295,15 +2299,34 @@ if $check_postgresql ; then
echo -e "\nChecking PostgreSQL database service on \"`hostname -f`\".."
fi
CHILD_PID="$(ps aux | grep -E "\ postgres:\ " | grep -v grep | tail -n 1 | awk '{print$2}')"
PSQL_MAIN_PID="$(ps -o ppid= -p $CHILD_PID 2> /dev/null)"
# CHILD_PID="$(ps aux | grep -E "\ postgres:\ " | grep -v grep | tail -n 1 | awk '{print$2}')"
# PSQL_MAIN_PID="$(ps -o ppid= -p $CHILD_PID 2> /dev/null)"
#
# if [ "X${PSQL_MAIN_PID}X" = "XX" ];then
#
# echo -e "\nPostgreSQL database service is not running! - Try to restart service.." > $LOCK_DIR/extra_msg.txt
# echo -e "======================================================================" >> $LOCK_DIR/extra_msg.txt
#
# error "PostgeSQL database service is not running! - Try to restart service.."
#
# restart_postgresql
#
# else
#
# if $terminal ; then
# ok "PostgreSQL database server on \"`hostname -f`\" seems to be running.."
# fi
#
# fi
if [ "X${PSQL_MAIN_PID}X" = "XX" ];then
$(pg_isready -q -h localhost -p ${postgresql_port} -t 5 2> /dev/null)
echo -e "\nPostgreSQL database service is not running! - Try to restart service.." > $LOCK_DIR/extra_msg.txt
echo -e "======================================================================" >> $LOCK_DIR/extra_msg.txt
if [[ $? -gt 0 ]] ; then
error "PostgeSQL database service is not running! - Try to restart service.."
echo -e "\nPostgreSQL database service is not responding! - Try to restart service.." > $LOCK_DIR/extra_msg.txt
echo -e "=========================================================================" >> $LOCK_DIR/extra_msg.txt
error "PostgeSQL database service is not responding! - Try to restart service.."
restart_postgresql

View File

@ -159,6 +159,14 @@ check_website=false
#mariadb_credential_args=""
# - Port of PostgreSQL Service
# -
# - defaults to '5432'
# - postgresql_port=5432
# -
#postgresql_port=5432
# - Additional Settings for check_php_fpm
# -
# - On Linux Vserver System set