mirror of
https://github.com/zabbix/zabbix-docker.git
synced 2025-01-24 14:28:38 +01:00
Fixed PostgreSQL schema name. Fixed graph legends on CentOS
This commit is contained in:
parent
c32237360d
commit
8ad66c8639
@ -290,6 +290,7 @@ check_db_connect_postgresql() {
|
|||||||
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
||||||
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
||||||
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
||||||
|
echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}"
|
||||||
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
||||||
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
||||||
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
||||||
@ -307,12 +308,18 @@ check_db_connect_postgresql() {
|
|||||||
|
|
||||||
WAIT_TIMEOUT=5
|
WAIT_TIMEOUT=5
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
||||||
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
||||||
sleep $WAIT_TIMEOUT
|
sleep $WAIT_TIMEOUT
|
||||||
done
|
done
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -336,10 +343,16 @@ psql_query() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
|
|
||||||
echo $result
|
echo $result
|
||||||
}
|
}
|
||||||
@ -436,11 +449,17 @@ create_db_schema_postgresql() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
||||||
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -651,6 +670,7 @@ update_zbx_config() {
|
|||||||
else
|
else
|
||||||
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
||||||
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
||||||
|
update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}"
|
||||||
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
||||||
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
||||||
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
||||||
@ -835,6 +855,7 @@ prepare_zbx_web_config() {
|
|||||||
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
||||||
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
||||||
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
||||||
|
-e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \
|
||||||
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
||||||
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
||||||
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
||||||
|
@ -290,6 +290,7 @@ check_db_connect_postgresql() {
|
|||||||
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
||||||
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
||||||
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
||||||
|
echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}"
|
||||||
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
||||||
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
||||||
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
||||||
@ -307,12 +308,18 @@ check_db_connect_postgresql() {
|
|||||||
|
|
||||||
WAIT_TIMEOUT=5
|
WAIT_TIMEOUT=5
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
||||||
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
||||||
sleep $WAIT_TIMEOUT
|
sleep $WAIT_TIMEOUT
|
||||||
done
|
done
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -336,10 +343,16 @@ psql_query() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
|
|
||||||
echo $result
|
echo $result
|
||||||
}
|
}
|
||||||
@ -436,11 +449,17 @@ create_db_schema_postgresql() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
||||||
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -651,6 +670,7 @@ update_zbx_config() {
|
|||||||
else
|
else
|
||||||
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
||||||
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
||||||
|
update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}"
|
||||||
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
||||||
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
||||||
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
||||||
@ -835,6 +855,7 @@ prepare_zbx_web_config() {
|
|||||||
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
||||||
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
||||||
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
||||||
|
-e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \
|
||||||
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
||||||
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
||||||
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
||||||
|
@ -290,6 +290,7 @@ check_db_connect_postgresql() {
|
|||||||
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
||||||
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
||||||
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
||||||
|
echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}"
|
||||||
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
||||||
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
||||||
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
||||||
@ -307,12 +308,18 @@ check_db_connect_postgresql() {
|
|||||||
|
|
||||||
WAIT_TIMEOUT=5
|
WAIT_TIMEOUT=5
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
||||||
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
||||||
sleep $WAIT_TIMEOUT
|
sleep $WAIT_TIMEOUT
|
||||||
done
|
done
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -336,10 +343,16 @@ psql_query() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
|
|
||||||
echo $result
|
echo $result
|
||||||
}
|
}
|
||||||
@ -436,11 +449,17 @@ create_db_schema_postgresql() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
||||||
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -651,6 +670,7 @@ update_zbx_config() {
|
|||||||
else
|
else
|
||||||
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
||||||
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
||||||
|
update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}"
|
||||||
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
||||||
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
||||||
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
||||||
@ -835,6 +855,7 @@ prepare_zbx_web_config() {
|
|||||||
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
||||||
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
||||||
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
||||||
|
-e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \
|
||||||
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
||||||
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
||||||
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
||||||
|
@ -290,6 +290,7 @@ check_db_connect_postgresql() {
|
|||||||
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
||||||
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
||||||
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
||||||
|
echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}"
|
||||||
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
||||||
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
||||||
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
||||||
@ -307,12 +308,18 @@ check_db_connect_postgresql() {
|
|||||||
|
|
||||||
WAIT_TIMEOUT=5
|
WAIT_TIMEOUT=5
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
||||||
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
||||||
sleep $WAIT_TIMEOUT
|
sleep $WAIT_TIMEOUT
|
||||||
done
|
done
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -336,10 +343,16 @@ psql_query() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
|
|
||||||
echo $result
|
echo $result
|
||||||
}
|
}
|
||||||
@ -436,11 +449,17 @@ create_db_schema_postgresql() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
||||||
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -651,6 +670,7 @@ update_zbx_config() {
|
|||||||
else
|
else
|
||||||
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
||||||
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
||||||
|
update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}"
|
||||||
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
||||||
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
||||||
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
||||||
@ -835,6 +855,7 @@ prepare_zbx_web_config() {
|
|||||||
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
||||||
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
||||||
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
||||||
|
-e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \
|
||||||
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
||||||
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
||||||
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
||||||
|
@ -290,6 +290,7 @@ check_db_connect_postgresql() {
|
|||||||
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
||||||
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
||||||
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
||||||
|
echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}"
|
||||||
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
||||||
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
||||||
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
||||||
@ -307,12 +308,18 @@ check_db_connect_postgresql() {
|
|||||||
|
|
||||||
WAIT_TIMEOUT=5
|
WAIT_TIMEOUT=5
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
||||||
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
||||||
sleep $WAIT_TIMEOUT
|
sleep $WAIT_TIMEOUT
|
||||||
done
|
done
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -336,10 +343,16 @@ psql_query() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
|
|
||||||
echo $result
|
echo $result
|
||||||
}
|
}
|
||||||
@ -436,11 +449,17 @@ create_db_schema_postgresql() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
||||||
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -651,6 +670,7 @@ update_zbx_config() {
|
|||||||
else
|
else
|
||||||
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
||||||
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
||||||
|
update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}"
|
||||||
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
||||||
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
||||||
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
||||||
@ -835,6 +855,7 @@ prepare_zbx_web_config() {
|
|||||||
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
||||||
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
||||||
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
||||||
|
-e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \
|
||||||
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
||||||
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
||||||
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
||||||
|
@ -290,6 +290,7 @@ check_db_connect_postgresql() {
|
|||||||
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
||||||
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
||||||
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
||||||
|
echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}"
|
||||||
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
||||||
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
||||||
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
||||||
@ -307,12 +308,18 @@ check_db_connect_postgresql() {
|
|||||||
|
|
||||||
WAIT_TIMEOUT=5
|
WAIT_TIMEOUT=5
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
||||||
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
||||||
sleep $WAIT_TIMEOUT
|
sleep $WAIT_TIMEOUT
|
||||||
done
|
done
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -336,10 +343,16 @@ psql_query() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
|
|
||||||
echo $result
|
echo $result
|
||||||
}
|
}
|
||||||
@ -436,11 +449,17 @@ create_db_schema_postgresql() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
||||||
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -651,6 +670,7 @@ update_zbx_config() {
|
|||||||
else
|
else
|
||||||
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
||||||
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
||||||
|
update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}"
|
||||||
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
||||||
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
||||||
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
||||||
@ -835,6 +855,7 @@ prepare_zbx_web_config() {
|
|||||||
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
||||||
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
||||||
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
||||||
|
-e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \
|
||||||
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
||||||
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
||||||
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
||||||
|
@ -290,6 +290,7 @@ check_db_connect_postgresql() {
|
|||||||
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
||||||
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
||||||
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
||||||
|
echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}"
|
||||||
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
||||||
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
||||||
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
||||||
@ -307,12 +308,18 @@ check_db_connect_postgresql() {
|
|||||||
|
|
||||||
WAIT_TIMEOUT=5
|
WAIT_TIMEOUT=5
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
||||||
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
||||||
sleep $WAIT_TIMEOUT
|
sleep $WAIT_TIMEOUT
|
||||||
done
|
done
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -336,10 +343,16 @@ psql_query() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
|
|
||||||
echo $result
|
echo $result
|
||||||
}
|
}
|
||||||
@ -436,11 +449,17 @@ create_db_schema_postgresql() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
||||||
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -651,6 +670,7 @@ update_zbx_config() {
|
|||||||
else
|
else
|
||||||
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
||||||
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
||||||
|
update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}"
|
||||||
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
||||||
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
||||||
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
||||||
@ -835,6 +855,7 @@ prepare_zbx_web_config() {
|
|||||||
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
||||||
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
||||||
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
||||||
|
-e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \
|
||||||
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
||||||
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
||||||
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
||||||
|
@ -290,6 +290,7 @@ check_db_connect_postgresql() {
|
|||||||
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
||||||
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
||||||
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
||||||
|
echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}"
|
||||||
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
||||||
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
||||||
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
||||||
@ -307,12 +308,18 @@ check_db_connect_postgresql() {
|
|||||||
|
|
||||||
WAIT_TIMEOUT=5
|
WAIT_TIMEOUT=5
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
||||||
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
||||||
sleep $WAIT_TIMEOUT
|
sleep $WAIT_TIMEOUT
|
||||||
done
|
done
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -336,10 +343,16 @@ psql_query() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
|
|
||||||
echo $result
|
echo $result
|
||||||
}
|
}
|
||||||
@ -436,11 +449,17 @@ create_db_schema_postgresql() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
||||||
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -651,6 +670,7 @@ update_zbx_config() {
|
|||||||
else
|
else
|
||||||
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
||||||
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
||||||
|
update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}"
|
||||||
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
||||||
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
||||||
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
||||||
@ -835,6 +855,7 @@ prepare_zbx_web_config() {
|
|||||||
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
||||||
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
||||||
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
||||||
|
-e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \
|
||||||
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
||||||
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
||||||
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
||||||
|
@ -290,6 +290,7 @@ check_db_connect_postgresql() {
|
|||||||
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
||||||
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
||||||
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
||||||
|
echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}"
|
||||||
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
||||||
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
||||||
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
||||||
@ -307,12 +308,18 @@ check_db_connect_postgresql() {
|
|||||||
|
|
||||||
WAIT_TIMEOUT=5
|
WAIT_TIMEOUT=5
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
||||||
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
||||||
sleep $WAIT_TIMEOUT
|
sleep $WAIT_TIMEOUT
|
||||||
done
|
done
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -336,10 +343,16 @@ psql_query() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
|
|
||||||
echo $result
|
echo $result
|
||||||
}
|
}
|
||||||
@ -436,11 +449,17 @@ create_db_schema_postgresql() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
||||||
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -651,6 +670,7 @@ update_zbx_config() {
|
|||||||
else
|
else
|
||||||
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
||||||
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
||||||
|
update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}"
|
||||||
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
||||||
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
||||||
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
||||||
@ -835,6 +855,7 @@ prepare_zbx_web_config() {
|
|||||||
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
||||||
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
||||||
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
||||||
|
-e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \
|
||||||
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
||||||
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
||||||
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
||||||
|
@ -290,6 +290,7 @@ check_db_connect_postgresql() {
|
|||||||
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
||||||
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
||||||
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
||||||
|
echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}"
|
||||||
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
||||||
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
||||||
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
||||||
@ -307,12 +308,18 @@ check_db_connect_postgresql() {
|
|||||||
|
|
||||||
WAIT_TIMEOUT=5
|
WAIT_TIMEOUT=5
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
||||||
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
||||||
sleep $WAIT_TIMEOUT
|
sleep $WAIT_TIMEOUT
|
||||||
done
|
done
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -336,10 +343,16 @@ psql_query() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
|
|
||||||
echo $result
|
echo $result
|
||||||
}
|
}
|
||||||
@ -436,11 +449,17 @@ create_db_schema_postgresql() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
||||||
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -651,6 +670,7 @@ update_zbx_config() {
|
|||||||
else
|
else
|
||||||
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
||||||
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
||||||
|
update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}"
|
||||||
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
||||||
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
||||||
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
||||||
@ -835,6 +855,7 @@ prepare_zbx_web_config() {
|
|||||||
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
||||||
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
||||||
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
||||||
|
-e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \
|
||||||
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
||||||
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
||||||
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
||||||
|
@ -290,6 +290,7 @@ check_db_connect_postgresql() {
|
|||||||
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
||||||
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
||||||
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
||||||
|
echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}"
|
||||||
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
||||||
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
||||||
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
||||||
@ -307,12 +308,18 @@ check_db_connect_postgresql() {
|
|||||||
|
|
||||||
WAIT_TIMEOUT=5
|
WAIT_TIMEOUT=5
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
||||||
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
||||||
sleep $WAIT_TIMEOUT
|
sleep $WAIT_TIMEOUT
|
||||||
done
|
done
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -336,10 +343,16 @@ psql_query() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
|
|
||||||
echo $result
|
echo $result
|
||||||
}
|
}
|
||||||
@ -436,11 +449,17 @@ create_db_schema_postgresql() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
||||||
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -651,6 +670,7 @@ update_zbx_config() {
|
|||||||
else
|
else
|
||||||
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
||||||
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
||||||
|
update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}"
|
||||||
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
||||||
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
||||||
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
||||||
@ -835,6 +855,7 @@ prepare_zbx_web_config() {
|
|||||||
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
||||||
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
||||||
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
||||||
|
-e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \
|
||||||
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
||||||
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
||||||
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
||||||
|
@ -290,6 +290,7 @@ check_db_connect_postgresql() {
|
|||||||
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
||||||
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
||||||
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
||||||
|
echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}"
|
||||||
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
||||||
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
||||||
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
||||||
@ -307,12 +308,18 @@ check_db_connect_postgresql() {
|
|||||||
|
|
||||||
WAIT_TIMEOUT=5
|
WAIT_TIMEOUT=5
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
||||||
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
||||||
sleep $WAIT_TIMEOUT
|
sleep $WAIT_TIMEOUT
|
||||||
done
|
done
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -336,10 +343,16 @@ psql_query() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
|
|
||||||
echo $result
|
echo $result
|
||||||
}
|
}
|
||||||
@ -436,11 +449,17 @@ create_db_schema_postgresql() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
||||||
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -651,6 +670,7 @@ update_zbx_config() {
|
|||||||
else
|
else
|
||||||
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
||||||
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
||||||
|
update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}"
|
||||||
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
||||||
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
||||||
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
||||||
@ -835,6 +855,7 @@ prepare_zbx_web_config() {
|
|||||||
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
||||||
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
||||||
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
||||||
|
-e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \
|
||||||
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
||||||
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
||||||
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
||||||
|
@ -290,6 +290,7 @@ check_db_connect_postgresql() {
|
|||||||
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
||||||
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
||||||
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
||||||
|
echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}"
|
||||||
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
||||||
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
||||||
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
||||||
@ -307,12 +308,18 @@ check_db_connect_postgresql() {
|
|||||||
|
|
||||||
WAIT_TIMEOUT=5
|
WAIT_TIMEOUT=5
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
||||||
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
||||||
sleep $WAIT_TIMEOUT
|
sleep $WAIT_TIMEOUT
|
||||||
done
|
done
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -336,10 +343,16 @@ psql_query() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
|
|
||||||
echo $result
|
echo $result
|
||||||
}
|
}
|
||||||
@ -436,11 +449,17 @@ create_db_schema_postgresql() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
||||||
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -651,6 +670,7 @@ update_zbx_config() {
|
|||||||
else
|
else
|
||||||
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
||||||
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
||||||
|
update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}"
|
||||||
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
||||||
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
||||||
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
||||||
@ -835,6 +855,7 @@ prepare_zbx_web_config() {
|
|||||||
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
||||||
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
||||||
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
||||||
|
-e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \
|
||||||
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
||||||
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
||||||
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
||||||
|
@ -290,6 +290,7 @@ check_db_connect_postgresql() {
|
|||||||
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
||||||
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
||||||
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
||||||
|
echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}"
|
||||||
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
||||||
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
||||||
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
||||||
@ -307,12 +308,18 @@ check_db_connect_postgresql() {
|
|||||||
|
|
||||||
WAIT_TIMEOUT=5
|
WAIT_TIMEOUT=5
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
||||||
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
||||||
sleep $WAIT_TIMEOUT
|
sleep $WAIT_TIMEOUT
|
||||||
done
|
done
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -336,10 +343,16 @@ psql_query() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
|
|
||||||
echo $result
|
echo $result
|
||||||
}
|
}
|
||||||
@ -436,11 +449,17 @@ create_db_schema_postgresql() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
||||||
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -651,6 +670,7 @@ update_zbx_config() {
|
|||||||
else
|
else
|
||||||
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
||||||
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
||||||
|
update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}"
|
||||||
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
||||||
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
||||||
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
||||||
@ -835,6 +855,7 @@ prepare_zbx_web_config() {
|
|||||||
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
||||||
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
||||||
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
||||||
|
-e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \
|
||||||
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
||||||
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
||||||
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
||||||
|
@ -290,6 +290,7 @@ check_db_connect_postgresql() {
|
|||||||
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
||||||
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
||||||
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
||||||
|
echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}"
|
||||||
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
||||||
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
||||||
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
||||||
@ -307,12 +308,18 @@ check_db_connect_postgresql() {
|
|||||||
|
|
||||||
WAIT_TIMEOUT=5
|
WAIT_TIMEOUT=5
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
||||||
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
||||||
sleep $WAIT_TIMEOUT
|
sleep $WAIT_TIMEOUT
|
||||||
done
|
done
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -336,10 +343,16 @@ psql_query() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
|
|
||||||
echo $result
|
echo $result
|
||||||
}
|
}
|
||||||
@ -436,11 +449,17 @@ create_db_schema_postgresql() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
||||||
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -651,6 +670,7 @@ update_zbx_config() {
|
|||||||
else
|
else
|
||||||
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
||||||
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
||||||
|
update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}"
|
||||||
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
||||||
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
||||||
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
||||||
@ -835,6 +855,7 @@ prepare_zbx_web_config() {
|
|||||||
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
||||||
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
||||||
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
||||||
|
-e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \
|
||||||
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
||||||
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
||||||
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
||||||
|
@ -290,6 +290,7 @@ check_db_connect_postgresql() {
|
|||||||
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
||||||
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
||||||
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
||||||
|
echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}"
|
||||||
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
||||||
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
||||||
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
||||||
@ -307,12 +308,18 @@ check_db_connect_postgresql() {
|
|||||||
|
|
||||||
WAIT_TIMEOUT=5
|
WAIT_TIMEOUT=5
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
||||||
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
||||||
sleep $WAIT_TIMEOUT
|
sleep $WAIT_TIMEOUT
|
||||||
done
|
done
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -336,10 +343,16 @@ psql_query() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
|
|
||||||
echo $result
|
echo $result
|
||||||
}
|
}
|
||||||
@ -436,11 +449,17 @@ create_db_schema_postgresql() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
||||||
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -651,6 +670,7 @@ update_zbx_config() {
|
|||||||
else
|
else
|
||||||
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
||||||
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
||||||
|
update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}"
|
||||||
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
||||||
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
||||||
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
||||||
@ -835,6 +855,7 @@ prepare_zbx_web_config() {
|
|||||||
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
||||||
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
||||||
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
||||||
|
-e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \
|
||||||
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
||||||
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
||||||
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
||||||
|
@ -290,6 +290,7 @@ check_db_connect_postgresql() {
|
|||||||
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
||||||
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
||||||
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
||||||
|
echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}"
|
||||||
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
||||||
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
||||||
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
||||||
@ -307,12 +308,18 @@ check_db_connect_postgresql() {
|
|||||||
|
|
||||||
WAIT_TIMEOUT=5
|
WAIT_TIMEOUT=5
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
||||||
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
||||||
sleep $WAIT_TIMEOUT
|
sleep $WAIT_TIMEOUT
|
||||||
done
|
done
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -336,10 +343,16 @@ psql_query() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
|
|
||||||
echo $result
|
echo $result
|
||||||
}
|
}
|
||||||
@ -436,11 +449,17 @@ create_db_schema_postgresql() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
||||||
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -651,6 +670,7 @@ update_zbx_config() {
|
|||||||
else
|
else
|
||||||
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
||||||
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
||||||
|
update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}"
|
||||||
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
||||||
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
||||||
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
||||||
@ -835,6 +855,7 @@ prepare_zbx_web_config() {
|
|||||||
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
||||||
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
||||||
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
||||||
|
-e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \
|
||||||
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
||||||
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
||||||
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
||||||
|
@ -290,6 +290,7 @@ check_db_connect_postgresql() {
|
|||||||
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
||||||
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
||||||
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
||||||
|
echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}"
|
||||||
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
||||||
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
||||||
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
||||||
@ -307,12 +308,18 @@ check_db_connect_postgresql() {
|
|||||||
|
|
||||||
WAIT_TIMEOUT=5
|
WAIT_TIMEOUT=5
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
||||||
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
||||||
sleep $WAIT_TIMEOUT
|
sleep $WAIT_TIMEOUT
|
||||||
done
|
done
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -336,10 +343,16 @@ psql_query() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
|
|
||||||
echo $result
|
echo $result
|
||||||
}
|
}
|
||||||
@ -436,11 +449,17 @@ create_db_schema_postgresql() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
||||||
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -651,6 +670,7 @@ update_zbx_config() {
|
|||||||
else
|
else
|
||||||
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
||||||
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
||||||
|
update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}"
|
||||||
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
||||||
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
||||||
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
||||||
@ -835,6 +855,7 @@ prepare_zbx_web_config() {
|
|||||||
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
||||||
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
||||||
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
||||||
|
-e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \
|
||||||
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
||||||
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
||||||
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
||||||
|
@ -10,7 +10,7 @@ $DB['USER'] = '{DB_SERVER_USER}';
|
|||||||
$DB['PASSWORD'] = '{DB_SERVER_PASS}';
|
$DB['PASSWORD'] = '{DB_SERVER_PASS}';
|
||||||
|
|
||||||
// Schema name. Used for IBM DB2 and PostgreSQL.
|
// Schema name. Used for IBM DB2 and PostgreSQL.
|
||||||
$DB['SCHEMA'] = '';
|
$DB['SCHEMA'] = '{DB_SERVER_SCHEMA}';
|
||||||
|
|
||||||
$ZBX_SERVER = '{ZBX_SERVER_HOST}';
|
$ZBX_SERVER = '{ZBX_SERVER_HOST}';
|
||||||
$ZBX_SERVER_PORT = '{ZBX_SERVER_PORT}';
|
$ZBX_SERVER_PORT = '{ZBX_SERVER_PORT}';
|
||||||
|
@ -290,6 +290,7 @@ check_db_connect_postgresql() {
|
|||||||
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
||||||
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
||||||
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
||||||
|
echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}"
|
||||||
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
||||||
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
||||||
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
||||||
@ -307,12 +308,18 @@ check_db_connect_postgresql() {
|
|||||||
|
|
||||||
WAIT_TIMEOUT=5
|
WAIT_TIMEOUT=5
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
||||||
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
||||||
sleep $WAIT_TIMEOUT
|
sleep $WAIT_TIMEOUT
|
||||||
done
|
done
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -336,10 +343,16 @@ psql_query() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
|
|
||||||
echo $result
|
echo $result
|
||||||
}
|
}
|
||||||
@ -436,11 +449,17 @@ create_db_schema_postgresql() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
||||||
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -651,6 +670,7 @@ update_zbx_config() {
|
|||||||
else
|
else
|
||||||
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
||||||
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
||||||
|
update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}"
|
||||||
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
||||||
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
||||||
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
||||||
@ -835,6 +855,7 @@ prepare_zbx_web_config() {
|
|||||||
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
||||||
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
||||||
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
||||||
|
-e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \
|
||||||
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
||||||
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
||||||
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
||||||
|
@ -77,7 +77,7 @@ RUN groupadd --system zabbix && \
|
|||||||
php-mbstring \
|
php-mbstring \
|
||||||
php-mysql \
|
php-mysql \
|
||||||
php-xml && \
|
php-xml && \
|
||||||
ln -s /usr/share/fonts/ttf-dejavu/DejaVuSans.ttf /usr/share/zabbix/fonts/graphfont.ttf && \
|
ln -s /usr/share/fonts/dejavu/DejaVuSans.ttf /usr/share/zabbix/fonts/graphfont.ttf && \
|
||||||
yum ${YUM_FLAGS_PERSISTANT} clean all && \
|
yum ${YUM_FLAGS_PERSISTANT} clean all && \
|
||||||
rm -rf /var/cache/yum/
|
rm -rf /var/cache/yum/
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ $DB['USER'] = '{DB_SERVER_USER}';
|
|||||||
$DB['PASSWORD'] = '{DB_SERVER_PASS}';
|
$DB['PASSWORD'] = '{DB_SERVER_PASS}';
|
||||||
|
|
||||||
// Schema name. Used for IBM DB2 and PostgreSQL.
|
// Schema name. Used for IBM DB2 and PostgreSQL.
|
||||||
$DB['SCHEMA'] = '';
|
$DB['SCHEMA'] = '{DB_SERVER_SCHEMA}';
|
||||||
|
|
||||||
$ZBX_SERVER = '{ZBX_SERVER_HOST}';
|
$ZBX_SERVER = '{ZBX_SERVER_HOST}';
|
||||||
$ZBX_SERVER_PORT = '{ZBX_SERVER_PORT}';
|
$ZBX_SERVER_PORT = '{ZBX_SERVER_PORT}';
|
||||||
|
@ -290,6 +290,7 @@ check_db_connect_postgresql() {
|
|||||||
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
||||||
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
||||||
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
||||||
|
echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}"
|
||||||
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
||||||
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
||||||
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
||||||
@ -307,12 +308,18 @@ check_db_connect_postgresql() {
|
|||||||
|
|
||||||
WAIT_TIMEOUT=5
|
WAIT_TIMEOUT=5
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
||||||
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
||||||
sleep $WAIT_TIMEOUT
|
sleep $WAIT_TIMEOUT
|
||||||
done
|
done
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -336,10 +343,16 @@ psql_query() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
|
|
||||||
echo $result
|
echo $result
|
||||||
}
|
}
|
||||||
@ -436,11 +449,17 @@ create_db_schema_postgresql() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
||||||
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -651,6 +670,7 @@ update_zbx_config() {
|
|||||||
else
|
else
|
||||||
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
||||||
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
||||||
|
update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}"
|
||||||
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
||||||
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
||||||
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
||||||
@ -835,6 +855,7 @@ prepare_zbx_web_config() {
|
|||||||
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
||||||
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
||||||
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
||||||
|
-e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \
|
||||||
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
||||||
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
||||||
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
||||||
|
@ -10,7 +10,7 @@ $DB['USER'] = '{DB_SERVER_USER}';
|
|||||||
$DB['PASSWORD'] = '{DB_SERVER_PASS}';
|
$DB['PASSWORD'] = '{DB_SERVER_PASS}';
|
||||||
|
|
||||||
// Schema name. Used for IBM DB2 and PostgreSQL.
|
// Schema name. Used for IBM DB2 and PostgreSQL.
|
||||||
$DB['SCHEMA'] = '';
|
$DB['SCHEMA'] = '{DB_SERVER_SCHEMA}';
|
||||||
|
|
||||||
$ZBX_SERVER = '{ZBX_SERVER_HOST}';
|
$ZBX_SERVER = '{ZBX_SERVER_HOST}';
|
||||||
$ZBX_SERVER_PORT = '{ZBX_SERVER_PORT}';
|
$ZBX_SERVER_PORT = '{ZBX_SERVER_PORT}';
|
||||||
|
@ -290,6 +290,7 @@ check_db_connect_postgresql() {
|
|||||||
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
||||||
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
||||||
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
||||||
|
echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}"
|
||||||
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
||||||
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
||||||
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
||||||
@ -307,12 +308,18 @@ check_db_connect_postgresql() {
|
|||||||
|
|
||||||
WAIT_TIMEOUT=5
|
WAIT_TIMEOUT=5
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
||||||
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
||||||
sleep $WAIT_TIMEOUT
|
sleep $WAIT_TIMEOUT
|
||||||
done
|
done
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -336,10 +343,16 @@ psql_query() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
|
|
||||||
echo $result
|
echo $result
|
||||||
}
|
}
|
||||||
@ -436,11 +449,17 @@ create_db_schema_postgresql() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
||||||
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -651,6 +670,7 @@ update_zbx_config() {
|
|||||||
else
|
else
|
||||||
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
||||||
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
||||||
|
update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}"
|
||||||
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
||||||
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
||||||
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
||||||
@ -835,6 +855,7 @@ prepare_zbx_web_config() {
|
|||||||
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
||||||
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
||||||
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
||||||
|
-e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \
|
||||||
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
||||||
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
||||||
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
||||||
|
@ -10,7 +10,7 @@ $DB['USER'] = '{DB_SERVER_USER}';
|
|||||||
$DB['PASSWORD'] = '{DB_SERVER_PASS}';
|
$DB['PASSWORD'] = '{DB_SERVER_PASS}';
|
||||||
|
|
||||||
// Schema name. Used for IBM DB2 and PostgreSQL.
|
// Schema name. Used for IBM DB2 and PostgreSQL.
|
||||||
$DB['SCHEMA'] = '';
|
$DB['SCHEMA'] = '{DB_SERVER_SCHEMA}';
|
||||||
|
|
||||||
$ZBX_SERVER = '{ZBX_SERVER_HOST}';
|
$ZBX_SERVER = '{ZBX_SERVER_HOST}';
|
||||||
$ZBX_SERVER_PORT = '{ZBX_SERVER_PORT}';
|
$ZBX_SERVER_PORT = '{ZBX_SERVER_PORT}';
|
||||||
|
@ -290,6 +290,7 @@ check_db_connect_postgresql() {
|
|||||||
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
||||||
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
||||||
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
||||||
|
echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}"
|
||||||
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
||||||
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
||||||
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
||||||
@ -307,12 +308,18 @@ check_db_connect_postgresql() {
|
|||||||
|
|
||||||
WAIT_TIMEOUT=5
|
WAIT_TIMEOUT=5
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
||||||
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
||||||
sleep $WAIT_TIMEOUT
|
sleep $WAIT_TIMEOUT
|
||||||
done
|
done
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -336,10 +343,16 @@ psql_query() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
|
|
||||||
echo $result
|
echo $result
|
||||||
}
|
}
|
||||||
@ -436,11 +449,17 @@ create_db_schema_postgresql() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
||||||
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -651,6 +670,7 @@ update_zbx_config() {
|
|||||||
else
|
else
|
||||||
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
||||||
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
||||||
|
update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}"
|
||||||
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
||||||
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
||||||
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
||||||
@ -835,6 +855,7 @@ prepare_zbx_web_config() {
|
|||||||
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
||||||
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
||||||
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
||||||
|
-e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \
|
||||||
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
||||||
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
||||||
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
||||||
|
@ -78,7 +78,7 @@ RUN groupadd --system zabbix && \
|
|||||||
php-pgsql \
|
php-pgsql \
|
||||||
php-xml \
|
php-xml \
|
||||||
postgresql && \
|
postgresql && \
|
||||||
ln -s /usr/share/fonts/ttf-dejavu/DejaVuSans.ttf /usr/share/zabbix/fonts/graphfont.ttf && \
|
ln -s /usr/share/fonts/dejavu/DejaVuSans.ttf /usr/share/zabbix/fonts/graphfont.ttf && \
|
||||||
yum ${YUM_FLAGS_PERSISTENT} clean all && \
|
yum ${YUM_FLAGS_PERSISTENT} clean all && \
|
||||||
rm -rf /var/cache/yum/
|
rm -rf /var/cache/yum/
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ $DB['USER'] = '{DB_SERVER_USER}';
|
|||||||
$DB['PASSWORD'] = '{DB_SERVER_PASS}';
|
$DB['PASSWORD'] = '{DB_SERVER_PASS}';
|
||||||
|
|
||||||
// Schema name. Used for IBM DB2 and PostgreSQL.
|
// Schema name. Used for IBM DB2 and PostgreSQL.
|
||||||
$DB['SCHEMA'] = '';
|
$DB['SCHEMA'] = '{DB_SERVER_SCHEMA}';
|
||||||
|
|
||||||
$ZBX_SERVER = '{ZBX_SERVER_HOST}';
|
$ZBX_SERVER = '{ZBX_SERVER_HOST}';
|
||||||
$ZBX_SERVER_PORT = '{ZBX_SERVER_PORT}';
|
$ZBX_SERVER_PORT = '{ZBX_SERVER_PORT}';
|
||||||
|
@ -290,6 +290,7 @@ check_db_connect_postgresql() {
|
|||||||
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
||||||
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
||||||
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
||||||
|
echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}"
|
||||||
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
||||||
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
||||||
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
||||||
@ -307,12 +308,18 @@ check_db_connect_postgresql() {
|
|||||||
|
|
||||||
WAIT_TIMEOUT=5
|
WAIT_TIMEOUT=5
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
||||||
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
||||||
sleep $WAIT_TIMEOUT
|
sleep $WAIT_TIMEOUT
|
||||||
done
|
done
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -336,10 +343,16 @@ psql_query() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
|
|
||||||
echo $result
|
echo $result
|
||||||
}
|
}
|
||||||
@ -436,11 +449,17 @@ create_db_schema_postgresql() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
||||||
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -651,6 +670,7 @@ update_zbx_config() {
|
|||||||
else
|
else
|
||||||
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
||||||
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
||||||
|
update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}"
|
||||||
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
||||||
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
||||||
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
||||||
@ -835,6 +855,7 @@ prepare_zbx_web_config() {
|
|||||||
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
||||||
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
||||||
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
||||||
|
-e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \
|
||||||
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
||||||
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
||||||
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
||||||
|
@ -10,7 +10,7 @@ $DB['USER'] = '{DB_SERVER_USER}';
|
|||||||
$DB['PASSWORD'] = '{DB_SERVER_PASS}';
|
$DB['PASSWORD'] = '{DB_SERVER_PASS}';
|
||||||
|
|
||||||
// Schema name. Used for IBM DB2 and PostgreSQL.
|
// Schema name. Used for IBM DB2 and PostgreSQL.
|
||||||
$DB['SCHEMA'] = '';
|
$DB['SCHEMA'] = '{DB_SERVER_SCHEMA}';
|
||||||
|
|
||||||
$ZBX_SERVER = '{ZBX_SERVER_HOST}';
|
$ZBX_SERVER = '{ZBX_SERVER_HOST}';
|
||||||
$ZBX_SERVER_PORT = '{ZBX_SERVER_PORT}';
|
$ZBX_SERVER_PORT = '{ZBX_SERVER_PORT}';
|
||||||
|
@ -290,6 +290,7 @@ check_db_connect_postgresql() {
|
|||||||
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
||||||
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
||||||
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
||||||
|
echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}"
|
||||||
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
||||||
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
||||||
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
||||||
@ -307,12 +308,18 @@ check_db_connect_postgresql() {
|
|||||||
|
|
||||||
WAIT_TIMEOUT=5
|
WAIT_TIMEOUT=5
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
||||||
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
||||||
sleep $WAIT_TIMEOUT
|
sleep $WAIT_TIMEOUT
|
||||||
done
|
done
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -336,10 +343,16 @@ psql_query() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
|
|
||||||
echo $result
|
echo $result
|
||||||
}
|
}
|
||||||
@ -436,11 +449,17 @@ create_db_schema_postgresql() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
||||||
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -651,6 +670,7 @@ update_zbx_config() {
|
|||||||
else
|
else
|
||||||
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
||||||
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
||||||
|
update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}"
|
||||||
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
||||||
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
||||||
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
||||||
@ -835,6 +855,7 @@ prepare_zbx_web_config() {
|
|||||||
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
||||||
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
||||||
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
||||||
|
-e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \
|
||||||
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
||||||
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
||||||
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
||||||
|
@ -10,7 +10,7 @@ $DB['USER'] = '{DB_SERVER_USER}';
|
|||||||
$DB['PASSWORD'] = '{DB_SERVER_PASS}';
|
$DB['PASSWORD'] = '{DB_SERVER_PASS}';
|
||||||
|
|
||||||
// Schema name. Used for IBM DB2 and PostgreSQL.
|
// Schema name. Used for IBM DB2 and PostgreSQL.
|
||||||
$DB['SCHEMA'] = '';
|
$DB['SCHEMA'] = '{DB_SERVER_SCHEMA}';
|
||||||
|
|
||||||
$ZBX_SERVER = '{ZBX_SERVER_HOST}';
|
$ZBX_SERVER = '{ZBX_SERVER_HOST}';
|
||||||
$ZBX_SERVER_PORT = '{ZBX_SERVER_PORT}';
|
$ZBX_SERVER_PORT = '{ZBX_SERVER_PORT}';
|
||||||
|
@ -290,6 +290,7 @@ check_db_connect_postgresql() {
|
|||||||
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
||||||
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
||||||
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
||||||
|
echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}"
|
||||||
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
||||||
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
||||||
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
||||||
@ -307,12 +308,18 @@ check_db_connect_postgresql() {
|
|||||||
|
|
||||||
WAIT_TIMEOUT=5
|
WAIT_TIMEOUT=5
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
||||||
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
||||||
sleep $WAIT_TIMEOUT
|
sleep $WAIT_TIMEOUT
|
||||||
done
|
done
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -336,10 +343,16 @@ psql_query() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
|
|
||||||
echo $result
|
echo $result
|
||||||
}
|
}
|
||||||
@ -436,11 +449,17 @@ create_db_schema_postgresql() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
||||||
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -651,6 +670,7 @@ update_zbx_config() {
|
|||||||
else
|
else
|
||||||
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
||||||
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
||||||
|
update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}"
|
||||||
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
||||||
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
||||||
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
||||||
@ -835,6 +855,7 @@ prepare_zbx_web_config() {
|
|||||||
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
||||||
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
||||||
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
||||||
|
-e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \
|
||||||
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
||||||
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
||||||
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
||||||
|
@ -80,7 +80,7 @@ RUN groupadd --system zabbix && \
|
|||||||
php-mysql \
|
php-mysql \
|
||||||
php-xml \
|
php-xml \
|
||||||
supervisor && \
|
supervisor && \
|
||||||
ln -s /usr/share/fonts/ttf-dejavu/DejaVuSans.ttf /usr/share/zabbix/fonts/graphfont.ttf && \
|
ln -s /usr/share/fonts/dejavu/DejaVuSans.ttf /usr/share/zabbix/fonts/graphfont.ttf && \
|
||||||
rm -f /etc/php-fpm.d/www.conf && \
|
rm -f /etc/php-fpm.d/www.conf && \
|
||||||
mkdir -p /var/lib/php/ && \
|
mkdir -p /var/lib/php/ && \
|
||||||
chown --quiet -R nginx:nginx /var/lib/php/ && \
|
chown --quiet -R nginx:nginx /var/lib/php/ && \
|
||||||
|
@ -10,7 +10,7 @@ $DB['USER'] = '{DB_SERVER_USER}';
|
|||||||
$DB['PASSWORD'] = '{DB_SERVER_PASS}';
|
$DB['PASSWORD'] = '{DB_SERVER_PASS}';
|
||||||
|
|
||||||
// Schema name. Used for IBM DB2 and PostgreSQL.
|
// Schema name. Used for IBM DB2 and PostgreSQL.
|
||||||
$DB['SCHEMA'] = '';
|
$DB['SCHEMA'] = '{DB_SERVER_SCHEMA}';
|
||||||
|
|
||||||
$ZBX_SERVER = '{ZBX_SERVER_HOST}';
|
$ZBX_SERVER = '{ZBX_SERVER_HOST}';
|
||||||
$ZBX_SERVER_PORT = '{ZBX_SERVER_PORT}';
|
$ZBX_SERVER_PORT = '{ZBX_SERVER_PORT}';
|
||||||
|
@ -290,6 +290,7 @@ check_db_connect_postgresql() {
|
|||||||
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
||||||
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
||||||
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
||||||
|
echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}"
|
||||||
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
||||||
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
||||||
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
||||||
@ -307,12 +308,18 @@ check_db_connect_postgresql() {
|
|||||||
|
|
||||||
WAIT_TIMEOUT=5
|
WAIT_TIMEOUT=5
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
||||||
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
||||||
sleep $WAIT_TIMEOUT
|
sleep $WAIT_TIMEOUT
|
||||||
done
|
done
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -336,10 +343,16 @@ psql_query() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
|
|
||||||
echo $result
|
echo $result
|
||||||
}
|
}
|
||||||
@ -436,11 +449,17 @@ create_db_schema_postgresql() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
||||||
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -651,6 +670,7 @@ update_zbx_config() {
|
|||||||
else
|
else
|
||||||
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
||||||
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
||||||
|
update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}"
|
||||||
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
||||||
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
||||||
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
||||||
@ -835,6 +855,7 @@ prepare_zbx_web_config() {
|
|||||||
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
||||||
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
||||||
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
||||||
|
-e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \
|
||||||
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
||||||
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
||||||
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
||||||
|
@ -10,7 +10,7 @@ $DB['USER'] = '{DB_SERVER_USER}';
|
|||||||
$DB['PASSWORD'] = '{DB_SERVER_PASS}';
|
$DB['PASSWORD'] = '{DB_SERVER_PASS}';
|
||||||
|
|
||||||
// Schema name. Used for IBM DB2 and PostgreSQL.
|
// Schema name. Used for IBM DB2 and PostgreSQL.
|
||||||
$DB['SCHEMA'] = '';
|
$DB['SCHEMA'] = '{DB_SERVER_SCHEMA}';
|
||||||
|
|
||||||
$ZBX_SERVER = '{ZBX_SERVER_HOST}';
|
$ZBX_SERVER = '{ZBX_SERVER_HOST}';
|
||||||
$ZBX_SERVER_PORT = '{ZBX_SERVER_PORT}';
|
$ZBX_SERVER_PORT = '{ZBX_SERVER_PORT}';
|
||||||
|
@ -290,6 +290,7 @@ check_db_connect_postgresql() {
|
|||||||
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
||||||
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
||||||
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
||||||
|
echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}"
|
||||||
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
||||||
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
||||||
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
||||||
@ -307,12 +308,18 @@ check_db_connect_postgresql() {
|
|||||||
|
|
||||||
WAIT_TIMEOUT=5
|
WAIT_TIMEOUT=5
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
||||||
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
||||||
sleep $WAIT_TIMEOUT
|
sleep $WAIT_TIMEOUT
|
||||||
done
|
done
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -336,10 +343,16 @@ psql_query() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
|
|
||||||
echo $result
|
echo $result
|
||||||
}
|
}
|
||||||
@ -436,11 +449,17 @@ create_db_schema_postgresql() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
||||||
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -651,6 +670,7 @@ update_zbx_config() {
|
|||||||
else
|
else
|
||||||
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
||||||
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
||||||
|
update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}"
|
||||||
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
||||||
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
||||||
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
||||||
@ -835,6 +855,7 @@ prepare_zbx_web_config() {
|
|||||||
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
||||||
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
||||||
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
||||||
|
-e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \
|
||||||
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
||||||
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
||||||
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
||||||
|
@ -10,7 +10,7 @@ $DB['USER'] = '{DB_SERVER_USER}';
|
|||||||
$DB['PASSWORD'] = '{DB_SERVER_PASS}';
|
$DB['PASSWORD'] = '{DB_SERVER_PASS}';
|
||||||
|
|
||||||
// Schema name. Used for IBM DB2 and PostgreSQL.
|
// Schema name. Used for IBM DB2 and PostgreSQL.
|
||||||
$DB['SCHEMA'] = '';
|
$DB['SCHEMA'] = '{DB_SERVER_SCHEMA}';
|
||||||
|
|
||||||
$ZBX_SERVER = '{ZBX_SERVER_HOST}';
|
$ZBX_SERVER = '{ZBX_SERVER_HOST}';
|
||||||
$ZBX_SERVER_PORT = '{ZBX_SERVER_PORT}';
|
$ZBX_SERVER_PORT = '{ZBX_SERVER_PORT}';
|
||||||
|
@ -290,6 +290,7 @@ check_db_connect_postgresql() {
|
|||||||
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
||||||
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
||||||
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
||||||
|
echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}"
|
||||||
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
||||||
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
||||||
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
||||||
@ -307,12 +308,18 @@ check_db_connect_postgresql() {
|
|||||||
|
|
||||||
WAIT_TIMEOUT=5
|
WAIT_TIMEOUT=5
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
||||||
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
||||||
sleep $WAIT_TIMEOUT
|
sleep $WAIT_TIMEOUT
|
||||||
done
|
done
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -336,10 +343,16 @@ psql_query() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
|
|
||||||
echo $result
|
echo $result
|
||||||
}
|
}
|
||||||
@ -436,11 +449,17 @@ create_db_schema_postgresql() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
||||||
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -651,6 +670,7 @@ update_zbx_config() {
|
|||||||
else
|
else
|
||||||
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
||||||
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
||||||
|
update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}"
|
||||||
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
||||||
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
||||||
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
||||||
@ -835,6 +855,7 @@ prepare_zbx_web_config() {
|
|||||||
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
||||||
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
||||||
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
||||||
|
-e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \
|
||||||
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
||||||
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
||||||
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
||||||
|
@ -79,7 +79,7 @@ RUN groupadd --system zabbix && \
|
|||||||
php-mbstring \
|
php-mbstring \
|
||||||
php-pgsql \
|
php-pgsql \
|
||||||
php-xml && \
|
php-xml && \
|
||||||
ln -s /usr/share/fonts/ttf-dejavu/DejaVuSans.ttf /usr/share/zabbix/fonts/graphfont.ttf && \
|
ln -s /usr/share/fonts/dejavu/DejaVuSans.ttf /usr/share/zabbix/fonts/graphfont.ttf && \
|
||||||
rm -f /etc/php-fpm.d/www.conf && \
|
rm -f /etc/php-fpm.d/www.conf && \
|
||||||
mkdir -p /var/lib/php/ && \
|
mkdir -p /var/lib/php/ && \
|
||||||
chown --quiet -R nginx:nginx /var/lib/php/ && \
|
chown --quiet -R nginx:nginx /var/lib/php/ && \
|
||||||
|
@ -10,7 +10,7 @@ $DB['USER'] = '{DB_SERVER_USER}';
|
|||||||
$DB['PASSWORD'] = '{DB_SERVER_PASS}';
|
$DB['PASSWORD'] = '{DB_SERVER_PASS}';
|
||||||
|
|
||||||
// Schema name. Used for IBM DB2 and PostgreSQL.
|
// Schema name. Used for IBM DB2 and PostgreSQL.
|
||||||
$DB['SCHEMA'] = '';
|
$DB['SCHEMA'] = '{DB_SERVER_SCHEMA}';
|
||||||
|
|
||||||
$ZBX_SERVER = '{ZBX_SERVER_HOST}';
|
$ZBX_SERVER = '{ZBX_SERVER_HOST}';
|
||||||
$ZBX_SERVER_PORT = '{ZBX_SERVER_PORT}';
|
$ZBX_SERVER_PORT = '{ZBX_SERVER_PORT}';
|
||||||
|
@ -290,6 +290,7 @@ check_db_connect_postgresql() {
|
|||||||
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
||||||
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
||||||
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
||||||
|
echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}"
|
||||||
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
||||||
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
||||||
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
||||||
@ -307,12 +308,18 @@ check_db_connect_postgresql() {
|
|||||||
|
|
||||||
WAIT_TIMEOUT=5
|
WAIT_TIMEOUT=5
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
||||||
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
||||||
sleep $WAIT_TIMEOUT
|
sleep $WAIT_TIMEOUT
|
||||||
done
|
done
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -336,10 +343,16 @@ psql_query() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
|
|
||||||
echo $result
|
echo $result
|
||||||
}
|
}
|
||||||
@ -436,11 +449,17 @@ create_db_schema_postgresql() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
||||||
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -651,6 +670,7 @@ update_zbx_config() {
|
|||||||
else
|
else
|
||||||
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
||||||
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
||||||
|
update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}"
|
||||||
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
||||||
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
||||||
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
||||||
@ -835,6 +855,7 @@ prepare_zbx_web_config() {
|
|||||||
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
||||||
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
||||||
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
||||||
|
-e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \
|
||||||
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
||||||
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
||||||
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
||||||
|
@ -10,7 +10,7 @@ $DB['USER'] = '{DB_SERVER_USER}';
|
|||||||
$DB['PASSWORD'] = '{DB_SERVER_PASS}';
|
$DB['PASSWORD'] = '{DB_SERVER_PASS}';
|
||||||
|
|
||||||
// Schema name. Used for IBM DB2 and PostgreSQL.
|
// Schema name. Used for IBM DB2 and PostgreSQL.
|
||||||
$DB['SCHEMA'] = '';
|
$DB['SCHEMA'] = '{DB_SERVER_SCHEMA}';
|
||||||
|
|
||||||
$ZBX_SERVER = '{ZBX_SERVER_HOST}';
|
$ZBX_SERVER = '{ZBX_SERVER_HOST}';
|
||||||
$ZBX_SERVER_PORT = '{ZBX_SERVER_PORT}';
|
$ZBX_SERVER_PORT = '{ZBX_SERVER_PORT}';
|
||||||
|
@ -290,6 +290,7 @@ check_db_connect_postgresql() {
|
|||||||
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
||||||
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
||||||
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
||||||
|
echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}"
|
||||||
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
||||||
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
||||||
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
||||||
@ -307,12 +308,18 @@ check_db_connect_postgresql() {
|
|||||||
|
|
||||||
WAIT_TIMEOUT=5
|
WAIT_TIMEOUT=5
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
||||||
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
||||||
sleep $WAIT_TIMEOUT
|
sleep $WAIT_TIMEOUT
|
||||||
done
|
done
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -336,10 +343,16 @@ psql_query() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
|
|
||||||
echo $result
|
echo $result
|
||||||
}
|
}
|
||||||
@ -436,11 +449,17 @@ create_db_schema_postgresql() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
||||||
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -651,6 +670,7 @@ update_zbx_config() {
|
|||||||
else
|
else
|
||||||
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
||||||
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
||||||
|
update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}"
|
||||||
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
||||||
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
||||||
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
||||||
@ -835,6 +855,7 @@ prepare_zbx_web_config() {
|
|||||||
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
||||||
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
||||||
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
||||||
|
-e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \
|
||||||
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
||||||
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
||||||
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
||||||
|
@ -290,6 +290,7 @@ check_db_connect_postgresql() {
|
|||||||
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
||||||
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
||||||
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
||||||
|
echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}"
|
||||||
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
||||||
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
||||||
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
||||||
@ -307,12 +308,18 @@ check_db_connect_postgresql() {
|
|||||||
|
|
||||||
WAIT_TIMEOUT=5
|
WAIT_TIMEOUT=5
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
||||||
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
||||||
sleep $WAIT_TIMEOUT
|
sleep $WAIT_TIMEOUT
|
||||||
done
|
done
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -336,10 +343,16 @@ psql_query() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
|
|
||||||
echo $result
|
echo $result
|
||||||
}
|
}
|
||||||
@ -436,11 +449,17 @@ create_db_schema_postgresql() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
||||||
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -651,6 +670,7 @@ update_zbx_config() {
|
|||||||
else
|
else
|
||||||
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
||||||
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
||||||
|
update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}"
|
||||||
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
||||||
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
||||||
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
||||||
@ -835,6 +855,7 @@ prepare_zbx_web_config() {
|
|||||||
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
||||||
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
||||||
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
||||||
|
-e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \
|
||||||
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
||||||
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
||||||
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
||||||
|
@ -168,7 +168,7 @@ RUN groupadd --system zabbix && \
|
|||||||
mkdir -p /var/lib/php/ && \
|
mkdir -p /var/lib/php/ && \
|
||||||
chown --quiet -R nginx:nginx /var/lib/php/ && \
|
chown --quiet -R nginx:nginx /var/lib/php/ && \
|
||||||
ls -lah /usr/share/zabbix/ && \
|
ls -lah /usr/share/zabbix/ && \
|
||||||
ln -s /usr/share/fonts/ttf-dejavu/DejaVuSans.ttf /usr/share/zabbix/fonts/graphfont.ttf && \
|
ln -s /usr/share/fonts/dejavu/DejaVuSans.ttf /usr/share/zabbix/fonts/graphfont.ttf && \
|
||||||
yum ${YUM_FLAGS_PERSISTENT} clean all && \
|
yum ${YUM_FLAGS_PERSISTENT} clean all && \
|
||||||
rm -rf /var/cache/yum/
|
rm -rf /var/cache/yum/
|
||||||
|
|
||||||
|
@ -290,6 +290,7 @@ check_db_connect_postgresql() {
|
|||||||
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
||||||
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
||||||
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
||||||
|
echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}"
|
||||||
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
||||||
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
||||||
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
||||||
@ -307,12 +308,18 @@ check_db_connect_postgresql() {
|
|||||||
|
|
||||||
WAIT_TIMEOUT=5
|
WAIT_TIMEOUT=5
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
||||||
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
||||||
sleep $WAIT_TIMEOUT
|
sleep $WAIT_TIMEOUT
|
||||||
done
|
done
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -336,10 +343,16 @@ psql_query() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
|
|
||||||
echo $result
|
echo $result
|
||||||
}
|
}
|
||||||
@ -436,11 +449,17 @@ create_db_schema_postgresql() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
||||||
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -651,6 +670,7 @@ update_zbx_config() {
|
|||||||
else
|
else
|
||||||
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
||||||
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
||||||
|
update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}"
|
||||||
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
||||||
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
||||||
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
||||||
@ -835,6 +855,7 @@ prepare_zbx_web_config() {
|
|||||||
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
||||||
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
||||||
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
||||||
|
-e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \
|
||||||
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
||||||
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
||||||
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
||||||
|
@ -290,6 +290,7 @@ check_db_connect_postgresql() {
|
|||||||
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
||||||
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
||||||
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
||||||
|
echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}"
|
||||||
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
||||||
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
||||||
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
||||||
@ -307,12 +308,18 @@ check_db_connect_postgresql() {
|
|||||||
|
|
||||||
WAIT_TIMEOUT=5
|
WAIT_TIMEOUT=5
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
||||||
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
||||||
sleep $WAIT_TIMEOUT
|
sleep $WAIT_TIMEOUT
|
||||||
done
|
done
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -336,10 +343,16 @@ psql_query() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
|
|
||||||
echo $result
|
echo $result
|
||||||
}
|
}
|
||||||
@ -436,11 +449,17 @@ create_db_schema_postgresql() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
||||||
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -656,6 +675,7 @@ update_zbx_config() {
|
|||||||
else
|
else
|
||||||
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
||||||
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
||||||
|
update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}"
|
||||||
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
||||||
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
||||||
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
||||||
@ -847,6 +867,7 @@ prepare_zbx_web_config() {
|
|||||||
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
||||||
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
||||||
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
||||||
|
-e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \
|
||||||
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
||||||
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
||||||
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
||||||
|
@ -290,6 +290,7 @@ check_db_connect_postgresql() {
|
|||||||
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
|
||||||
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
|
||||||
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
echo "* DB_SERVER_DBNAME: ${DB_SERVER_DBNAME}"
|
||||||
|
echo "* DB_SERVER_SCHEMA: ${DB_SERVER_SCHEMA}"
|
||||||
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
if [ "${USE_DB_ROOT_USER}" == "true" ]; then
|
||||||
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
echo "* DB_SERVER_ROOT_USER: ${DB_SERVER_ROOT_USER}"
|
||||||
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
echo "* DB_SERVER_ROOT_PASS: ${DB_SERVER_ROOT_PASS}"
|
||||||
@ -307,12 +308,18 @@ check_db_connect_postgresql() {
|
|||||||
|
|
||||||
WAIT_TIMEOUT=5
|
WAIT_TIMEOUT=5
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
while [ ! "$(psql -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} -U ${DB_SERVER_ROOT_USER} -d ${DB_SERVER_DBNAME} -l -q 2>/dev/null)" ]; do
|
||||||
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
echo "**** PostgreSQL server is not available. Waiting $WAIT_TIMEOUT seconds..."
|
||||||
sleep $WAIT_TIMEOUT
|
sleep $WAIT_TIMEOUT
|
||||||
done
|
done
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -336,10 +343,16 @@ psql_query() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
result=$(psql -A -q -t -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
-U ${DB_SERVER_ROOT_USER} -c "$query" $db 2>/dev/null);
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
|
|
||||||
echo $result
|
echo $result
|
||||||
}
|
}
|
||||||
@ -436,11 +449,17 @@ create_db_schema_postgresql() {
|
|||||||
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
export PGPASSWORD="${DB_SERVER_ZBX_PASS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${DB_SERVER_SCHEMA}" ]; then
|
||||||
|
PGOPTIONS="--search_path=${DB_SERVER_SCHEMA}"
|
||||||
|
export PGOPTIONS
|
||||||
|
fi
|
||||||
|
|
||||||
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
zcat /usr/share/doc/zabbix-$type-postgresql/create.sql.gz | psql -q \
|
||||||
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
-h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \
|
||||||
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
-U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null
|
||||||
|
|
||||||
unset PGPASSWORD
|
unset PGPASSWORD
|
||||||
|
unset PGOPTIONS
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -651,6 +670,7 @@ update_zbx_config() {
|
|||||||
else
|
else
|
||||||
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
update_config_var $ZBX_CONFIG "DBHost" "${DB_SERVER_HOST}"
|
||||||
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
update_config_var $ZBX_CONFIG "DBName" "${DB_SERVER_DBNAME}"
|
||||||
|
update_config_var $ZBX_CONFIG "DBSchema" "${DB_SERVER_SCHEMA}"
|
||||||
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
update_config_var $ZBX_CONFIG "DBUser" "${DB_SERVER_ZBX_USER}"
|
||||||
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
update_config_var $ZBX_CONFIG "DBPort" "${DB_SERVER_PORT}"
|
||||||
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
update_config_var $ZBX_CONFIG "DBPassword" "${DB_SERVER_ZBX_PASS}"
|
||||||
@ -835,6 +855,7 @@ prepare_zbx_web_config() {
|
|||||||
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
-e "s/{DB_SERVER_HOST}/${DB_SERVER_HOST}/g" \
|
||||||
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
-e "s/{DB_SERVER_PORT}/${DB_SERVER_PORT}/g" \
|
||||||
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
-e "s/{DB_SERVER_DBNAME}/${DB_SERVER_DBNAME}/g" \
|
||||||
|
-e "s/{DB_SERVER_SCHEMA}/${DB_SERVER_SCHEMA}/g" \
|
||||||
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
-e "s/{DB_SERVER_USER}/$server_user/g" \
|
||||||
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
-e "s/{DB_SERVER_PASS}/$server_pass/g" \
|
||||||
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
-e "s/{ZBX_SERVER_HOST}/${ZBX_SERVER_HOST}/g" \
|
||||||
|
Loading…
Reference in New Issue
Block a user