From c747a44303c14b0712970c0424dabb86ce5f918f Mon Sep 17 00:00:00 2001 From: root Date: Fri, 12 Apr 2019 13:22:41 +0300 Subject: [PATCH] Added timescale support --- .env_db_pgsql | 1 + agent/alpine/docker-entrypoint.sh | 15 ++++++++++++++- agent/centos/docker-entrypoint.sh | 15 ++++++++++++++- agent/ubuntu/docker-entrypoint.sh | 15 ++++++++++++++- java-gateway/alpine/docker-entrypoint.sh | 15 ++++++++++++++- java-gateway/centos/docker-entrypoint.sh | 15 ++++++++++++++- java-gateway/ubuntu/docker-entrypoint.sh | 15 ++++++++++++++- proxy-mysql/alpine/docker-entrypoint.sh | 15 ++++++++++++++- proxy-mysql/centos/docker-entrypoint.sh | 15 ++++++++++++++- proxy-mysql/ubuntu/docker-entrypoint.sh | 15 ++++++++++++++- proxy-sqlite3/alpine/docker-entrypoint.sh | 15 ++++++++++++++- proxy-sqlite3/centos/docker-entrypoint.sh | 15 ++++++++++++++- proxy-sqlite3/ubuntu/docker-entrypoint.sh | 15 ++++++++++++++- server-mysql/alpine/docker-entrypoint.sh | 15 ++++++++++++++- server-mysql/centos/docker-entrypoint.sh | 15 ++++++++++++++- server-mysql/ubuntu/docker-entrypoint.sh | 15 ++++++++++++++- server-pgsql/alpine/Dockerfile | 1 + server-pgsql/alpine/docker-entrypoint.sh | 15 ++++++++++++++- server-pgsql/centos/Dockerfile | 1 + server-pgsql/centos/docker-entrypoint.sh | 15 ++++++++++++++- server-pgsql/ubuntu/Dockerfile | 1 + server-pgsql/ubuntu/docker-entrypoint.sh | 15 ++++++++++++++- web-apache-mysql/alpine/docker-entrypoint.sh | 15 ++++++++++++++- web-apache-mysql/centos/docker-entrypoint.sh | 15 ++++++++++++++- web-apache-mysql/ubuntu/docker-entrypoint.sh | 15 ++++++++++++++- web-apache-pgsql/alpine/docker-entrypoint.sh | 15 ++++++++++++++- web-apache-pgsql/centos/docker-entrypoint.sh | 15 ++++++++++++++- web-apache-pgsql/ubuntu/docker-entrypoint.sh | 15 ++++++++++++++- web-nginx-mysql/alpine/docker-entrypoint.sh | 15 ++++++++++++++- web-nginx-mysql/centos/docker-entrypoint.sh | 15 ++++++++++++++- web-nginx-mysql/ubuntu/docker-entrypoint.sh | 15 ++++++++++++++- web-nginx-pgsql/alpine/docker-entrypoint.sh | 15 ++++++++++++++- web-nginx-pgsql/centos/docker-entrypoint.sh | 15 ++++++++++++++- web-nginx-pgsql/ubuntu/docker-entrypoint.sh | 15 ++++++++++++++- zabbix-appliance/alpine/docker-entrypoint.sh | 15 ++++++++++++++- zabbix-appliance/centos/docker-entrypoint.sh | 15 ++++++++++++++- zabbix-appliance/rhel/docker-entrypoint.sh | 15 ++++++++++++++- zabbix-appliance/ubuntu/docker-entrypoint.sh | 15 ++++++++++++++- 38 files changed, 480 insertions(+), 34 deletions(-) diff --git a/.env_db_pgsql b/.env_db_pgsql index 6cef2214a..4fefe7dce 100644 --- a/.env_db_pgsql +++ b/.env_db_pgsql @@ -7,3 +7,4 @@ POSTGRES_PASSWORD=zabbix # POSTGRES_DB=zabbix POSTGRES_DB=zabbix # DB_SERVER_SCHEMA=public +# ENABLE_TIMESCALEDB=true diff --git a/agent/alpine/docker-entrypoint.sh b/agent/alpine/docker-entrypoint.sh index e7b95037f..fb08a76e5 100755 --- a/agent/alpine/docker-entrypoint.sh +++ b/agent/alpine/docker-entrypoint.sh @@ -30,6 +30,9 @@ ZBX_SERVER_PORT=${ZBX_SERVER_PORT:-"10051"} # Default timezone for web interface PHP_TZ=${PHP_TZ:-"Europe/Riga"} +#Enable PostgreSQL timescaleDB feature: +ENABLE_TIMESCALEDB=${ENABLE_TIMESCALEDB:-"false"} + # Default directories # User 'zabbix' home directory ZABBIX_USER_HOME_DIR="/var/lib/zabbix" @@ -439,7 +442,7 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '$DB_SERVER_SCHEMA' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." @@ -449,6 +452,10 @@ create_db_schema_postgresql() { if [ -z "${ZBX_DB_VERSION}" ]; then echo "** Creating '${DB_SERVER_DBNAME}' schema in PostgreSQL" + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + psql_query "CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;" + fi + if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi @@ -462,6 +469,12 @@ create_db_schema_postgresql() { -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + cat /usr/share/doc/zabbix-$type-postgresql/timescaledb.sql | psql -q \ + -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ + -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + fi + unset PGPASSWORD unset PGOPTIONS fi diff --git a/agent/centos/docker-entrypoint.sh b/agent/centos/docker-entrypoint.sh index e7b95037f..fb08a76e5 100755 --- a/agent/centos/docker-entrypoint.sh +++ b/agent/centos/docker-entrypoint.sh @@ -30,6 +30,9 @@ ZBX_SERVER_PORT=${ZBX_SERVER_PORT:-"10051"} # Default timezone for web interface PHP_TZ=${PHP_TZ:-"Europe/Riga"} +#Enable PostgreSQL timescaleDB feature: +ENABLE_TIMESCALEDB=${ENABLE_TIMESCALEDB:-"false"} + # Default directories # User 'zabbix' home directory ZABBIX_USER_HOME_DIR="/var/lib/zabbix" @@ -439,7 +442,7 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '$DB_SERVER_SCHEMA' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." @@ -449,6 +452,10 @@ create_db_schema_postgresql() { if [ -z "${ZBX_DB_VERSION}" ]; then echo "** Creating '${DB_SERVER_DBNAME}' schema in PostgreSQL" + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + psql_query "CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;" + fi + if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi @@ -462,6 +469,12 @@ create_db_schema_postgresql() { -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + cat /usr/share/doc/zabbix-$type-postgresql/timescaledb.sql | psql -q \ + -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ + -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + fi + unset PGPASSWORD unset PGOPTIONS fi diff --git a/agent/ubuntu/docker-entrypoint.sh b/agent/ubuntu/docker-entrypoint.sh index e7b95037f..fb08a76e5 100755 --- a/agent/ubuntu/docker-entrypoint.sh +++ b/agent/ubuntu/docker-entrypoint.sh @@ -30,6 +30,9 @@ ZBX_SERVER_PORT=${ZBX_SERVER_PORT:-"10051"} # Default timezone for web interface PHP_TZ=${PHP_TZ:-"Europe/Riga"} +#Enable PostgreSQL timescaleDB feature: +ENABLE_TIMESCALEDB=${ENABLE_TIMESCALEDB:-"false"} + # Default directories # User 'zabbix' home directory ZABBIX_USER_HOME_DIR="/var/lib/zabbix" @@ -439,7 +442,7 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '$DB_SERVER_SCHEMA' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." @@ -449,6 +452,10 @@ create_db_schema_postgresql() { if [ -z "${ZBX_DB_VERSION}" ]; then echo "** Creating '${DB_SERVER_DBNAME}' schema in PostgreSQL" + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + psql_query "CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;" + fi + if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi @@ -462,6 +469,12 @@ create_db_schema_postgresql() { -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + cat /usr/share/doc/zabbix-$type-postgresql/timescaledb.sql | psql -q \ + -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ + -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + fi + unset PGPASSWORD unset PGOPTIONS fi diff --git a/java-gateway/alpine/docker-entrypoint.sh b/java-gateway/alpine/docker-entrypoint.sh index e7b95037f..fb08a76e5 100755 --- a/java-gateway/alpine/docker-entrypoint.sh +++ b/java-gateway/alpine/docker-entrypoint.sh @@ -30,6 +30,9 @@ ZBX_SERVER_PORT=${ZBX_SERVER_PORT:-"10051"} # Default timezone for web interface PHP_TZ=${PHP_TZ:-"Europe/Riga"} +#Enable PostgreSQL timescaleDB feature: +ENABLE_TIMESCALEDB=${ENABLE_TIMESCALEDB:-"false"} + # Default directories # User 'zabbix' home directory ZABBIX_USER_HOME_DIR="/var/lib/zabbix" @@ -439,7 +442,7 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '$DB_SERVER_SCHEMA' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." @@ -449,6 +452,10 @@ create_db_schema_postgresql() { if [ -z "${ZBX_DB_VERSION}" ]; then echo "** Creating '${DB_SERVER_DBNAME}' schema in PostgreSQL" + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + psql_query "CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;" + fi + if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi @@ -462,6 +469,12 @@ create_db_schema_postgresql() { -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + cat /usr/share/doc/zabbix-$type-postgresql/timescaledb.sql | psql -q \ + -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ + -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + fi + unset PGPASSWORD unset PGOPTIONS fi diff --git a/java-gateway/centos/docker-entrypoint.sh b/java-gateway/centos/docker-entrypoint.sh index e7b95037f..fb08a76e5 100755 --- a/java-gateway/centos/docker-entrypoint.sh +++ b/java-gateway/centos/docker-entrypoint.sh @@ -30,6 +30,9 @@ ZBX_SERVER_PORT=${ZBX_SERVER_PORT:-"10051"} # Default timezone for web interface PHP_TZ=${PHP_TZ:-"Europe/Riga"} +#Enable PostgreSQL timescaleDB feature: +ENABLE_TIMESCALEDB=${ENABLE_TIMESCALEDB:-"false"} + # Default directories # User 'zabbix' home directory ZABBIX_USER_HOME_DIR="/var/lib/zabbix" @@ -439,7 +442,7 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '$DB_SERVER_SCHEMA' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." @@ -449,6 +452,10 @@ create_db_schema_postgresql() { if [ -z "${ZBX_DB_VERSION}" ]; then echo "** Creating '${DB_SERVER_DBNAME}' schema in PostgreSQL" + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + psql_query "CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;" + fi + if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi @@ -462,6 +469,12 @@ create_db_schema_postgresql() { -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + cat /usr/share/doc/zabbix-$type-postgresql/timescaledb.sql | psql -q \ + -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ + -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + fi + unset PGPASSWORD unset PGOPTIONS fi diff --git a/java-gateway/ubuntu/docker-entrypoint.sh b/java-gateway/ubuntu/docker-entrypoint.sh index e7b95037f..fb08a76e5 100755 --- a/java-gateway/ubuntu/docker-entrypoint.sh +++ b/java-gateway/ubuntu/docker-entrypoint.sh @@ -30,6 +30,9 @@ ZBX_SERVER_PORT=${ZBX_SERVER_PORT:-"10051"} # Default timezone for web interface PHP_TZ=${PHP_TZ:-"Europe/Riga"} +#Enable PostgreSQL timescaleDB feature: +ENABLE_TIMESCALEDB=${ENABLE_TIMESCALEDB:-"false"} + # Default directories # User 'zabbix' home directory ZABBIX_USER_HOME_DIR="/var/lib/zabbix" @@ -439,7 +442,7 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '$DB_SERVER_SCHEMA' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." @@ -449,6 +452,10 @@ create_db_schema_postgresql() { if [ -z "${ZBX_DB_VERSION}" ]; then echo "** Creating '${DB_SERVER_DBNAME}' schema in PostgreSQL" + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + psql_query "CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;" + fi + if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi @@ -462,6 +469,12 @@ create_db_schema_postgresql() { -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + cat /usr/share/doc/zabbix-$type-postgresql/timescaledb.sql | psql -q \ + -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ + -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + fi + unset PGPASSWORD unset PGOPTIONS fi diff --git a/proxy-mysql/alpine/docker-entrypoint.sh b/proxy-mysql/alpine/docker-entrypoint.sh index e7b95037f..fb08a76e5 100755 --- a/proxy-mysql/alpine/docker-entrypoint.sh +++ b/proxy-mysql/alpine/docker-entrypoint.sh @@ -30,6 +30,9 @@ ZBX_SERVER_PORT=${ZBX_SERVER_PORT:-"10051"} # Default timezone for web interface PHP_TZ=${PHP_TZ:-"Europe/Riga"} +#Enable PostgreSQL timescaleDB feature: +ENABLE_TIMESCALEDB=${ENABLE_TIMESCALEDB:-"false"} + # Default directories # User 'zabbix' home directory ZABBIX_USER_HOME_DIR="/var/lib/zabbix" @@ -439,7 +442,7 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '$DB_SERVER_SCHEMA' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." @@ -449,6 +452,10 @@ create_db_schema_postgresql() { if [ -z "${ZBX_DB_VERSION}" ]; then echo "** Creating '${DB_SERVER_DBNAME}' schema in PostgreSQL" + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + psql_query "CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;" + fi + if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi @@ -462,6 +469,12 @@ create_db_schema_postgresql() { -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + cat /usr/share/doc/zabbix-$type-postgresql/timescaledb.sql | psql -q \ + -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ + -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + fi + unset PGPASSWORD unset PGOPTIONS fi diff --git a/proxy-mysql/centos/docker-entrypoint.sh b/proxy-mysql/centos/docker-entrypoint.sh index e7b95037f..fb08a76e5 100755 --- a/proxy-mysql/centos/docker-entrypoint.sh +++ b/proxy-mysql/centos/docker-entrypoint.sh @@ -30,6 +30,9 @@ ZBX_SERVER_PORT=${ZBX_SERVER_PORT:-"10051"} # Default timezone for web interface PHP_TZ=${PHP_TZ:-"Europe/Riga"} +#Enable PostgreSQL timescaleDB feature: +ENABLE_TIMESCALEDB=${ENABLE_TIMESCALEDB:-"false"} + # Default directories # User 'zabbix' home directory ZABBIX_USER_HOME_DIR="/var/lib/zabbix" @@ -439,7 +442,7 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '$DB_SERVER_SCHEMA' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." @@ -449,6 +452,10 @@ create_db_schema_postgresql() { if [ -z "${ZBX_DB_VERSION}" ]; then echo "** Creating '${DB_SERVER_DBNAME}' schema in PostgreSQL" + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + psql_query "CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;" + fi + if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi @@ -462,6 +469,12 @@ create_db_schema_postgresql() { -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + cat /usr/share/doc/zabbix-$type-postgresql/timescaledb.sql | psql -q \ + -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ + -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + fi + unset PGPASSWORD unset PGOPTIONS fi diff --git a/proxy-mysql/ubuntu/docker-entrypoint.sh b/proxy-mysql/ubuntu/docker-entrypoint.sh index e7b95037f..fb08a76e5 100755 --- a/proxy-mysql/ubuntu/docker-entrypoint.sh +++ b/proxy-mysql/ubuntu/docker-entrypoint.sh @@ -30,6 +30,9 @@ ZBX_SERVER_PORT=${ZBX_SERVER_PORT:-"10051"} # Default timezone for web interface PHP_TZ=${PHP_TZ:-"Europe/Riga"} +#Enable PostgreSQL timescaleDB feature: +ENABLE_TIMESCALEDB=${ENABLE_TIMESCALEDB:-"false"} + # Default directories # User 'zabbix' home directory ZABBIX_USER_HOME_DIR="/var/lib/zabbix" @@ -439,7 +442,7 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '$DB_SERVER_SCHEMA' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." @@ -449,6 +452,10 @@ create_db_schema_postgresql() { if [ -z "${ZBX_DB_VERSION}" ]; then echo "** Creating '${DB_SERVER_DBNAME}' schema in PostgreSQL" + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + psql_query "CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;" + fi + if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi @@ -462,6 +469,12 @@ create_db_schema_postgresql() { -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + cat /usr/share/doc/zabbix-$type-postgresql/timescaledb.sql | psql -q \ + -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ + -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + fi + unset PGPASSWORD unset PGOPTIONS fi diff --git a/proxy-sqlite3/alpine/docker-entrypoint.sh b/proxy-sqlite3/alpine/docker-entrypoint.sh index e7b95037f..fb08a76e5 100755 --- a/proxy-sqlite3/alpine/docker-entrypoint.sh +++ b/proxy-sqlite3/alpine/docker-entrypoint.sh @@ -30,6 +30,9 @@ ZBX_SERVER_PORT=${ZBX_SERVER_PORT:-"10051"} # Default timezone for web interface PHP_TZ=${PHP_TZ:-"Europe/Riga"} +#Enable PostgreSQL timescaleDB feature: +ENABLE_TIMESCALEDB=${ENABLE_TIMESCALEDB:-"false"} + # Default directories # User 'zabbix' home directory ZABBIX_USER_HOME_DIR="/var/lib/zabbix" @@ -439,7 +442,7 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '$DB_SERVER_SCHEMA' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." @@ -449,6 +452,10 @@ create_db_schema_postgresql() { if [ -z "${ZBX_DB_VERSION}" ]; then echo "** Creating '${DB_SERVER_DBNAME}' schema in PostgreSQL" + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + psql_query "CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;" + fi + if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi @@ -462,6 +469,12 @@ create_db_schema_postgresql() { -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + cat /usr/share/doc/zabbix-$type-postgresql/timescaledb.sql | psql -q \ + -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ + -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + fi + unset PGPASSWORD unset PGOPTIONS fi diff --git a/proxy-sqlite3/centos/docker-entrypoint.sh b/proxy-sqlite3/centos/docker-entrypoint.sh index e7b95037f..fb08a76e5 100755 --- a/proxy-sqlite3/centos/docker-entrypoint.sh +++ b/proxy-sqlite3/centos/docker-entrypoint.sh @@ -30,6 +30,9 @@ ZBX_SERVER_PORT=${ZBX_SERVER_PORT:-"10051"} # Default timezone for web interface PHP_TZ=${PHP_TZ:-"Europe/Riga"} +#Enable PostgreSQL timescaleDB feature: +ENABLE_TIMESCALEDB=${ENABLE_TIMESCALEDB:-"false"} + # Default directories # User 'zabbix' home directory ZABBIX_USER_HOME_DIR="/var/lib/zabbix" @@ -439,7 +442,7 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '$DB_SERVER_SCHEMA' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." @@ -449,6 +452,10 @@ create_db_schema_postgresql() { if [ -z "${ZBX_DB_VERSION}" ]; then echo "** Creating '${DB_SERVER_DBNAME}' schema in PostgreSQL" + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + psql_query "CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;" + fi + if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi @@ -462,6 +469,12 @@ create_db_schema_postgresql() { -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + cat /usr/share/doc/zabbix-$type-postgresql/timescaledb.sql | psql -q \ + -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ + -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + fi + unset PGPASSWORD unset PGOPTIONS fi diff --git a/proxy-sqlite3/ubuntu/docker-entrypoint.sh b/proxy-sqlite3/ubuntu/docker-entrypoint.sh index e7b95037f..fb08a76e5 100755 --- a/proxy-sqlite3/ubuntu/docker-entrypoint.sh +++ b/proxy-sqlite3/ubuntu/docker-entrypoint.sh @@ -30,6 +30,9 @@ ZBX_SERVER_PORT=${ZBX_SERVER_PORT:-"10051"} # Default timezone for web interface PHP_TZ=${PHP_TZ:-"Europe/Riga"} +#Enable PostgreSQL timescaleDB feature: +ENABLE_TIMESCALEDB=${ENABLE_TIMESCALEDB:-"false"} + # Default directories # User 'zabbix' home directory ZABBIX_USER_HOME_DIR="/var/lib/zabbix" @@ -439,7 +442,7 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '$DB_SERVER_SCHEMA' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." @@ -449,6 +452,10 @@ create_db_schema_postgresql() { if [ -z "${ZBX_DB_VERSION}" ]; then echo "** Creating '${DB_SERVER_DBNAME}' schema in PostgreSQL" + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + psql_query "CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;" + fi + if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi @@ -462,6 +469,12 @@ create_db_schema_postgresql() { -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + cat /usr/share/doc/zabbix-$type-postgresql/timescaledb.sql | psql -q \ + -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ + -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + fi + unset PGPASSWORD unset PGOPTIONS fi diff --git a/server-mysql/alpine/docker-entrypoint.sh b/server-mysql/alpine/docker-entrypoint.sh index e7b95037f..fb08a76e5 100755 --- a/server-mysql/alpine/docker-entrypoint.sh +++ b/server-mysql/alpine/docker-entrypoint.sh @@ -30,6 +30,9 @@ ZBX_SERVER_PORT=${ZBX_SERVER_PORT:-"10051"} # Default timezone for web interface PHP_TZ=${PHP_TZ:-"Europe/Riga"} +#Enable PostgreSQL timescaleDB feature: +ENABLE_TIMESCALEDB=${ENABLE_TIMESCALEDB:-"false"} + # Default directories # User 'zabbix' home directory ZABBIX_USER_HOME_DIR="/var/lib/zabbix" @@ -439,7 +442,7 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '$DB_SERVER_SCHEMA' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." @@ -449,6 +452,10 @@ create_db_schema_postgresql() { if [ -z "${ZBX_DB_VERSION}" ]; then echo "** Creating '${DB_SERVER_DBNAME}' schema in PostgreSQL" + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + psql_query "CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;" + fi + if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi @@ -462,6 +469,12 @@ create_db_schema_postgresql() { -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + cat /usr/share/doc/zabbix-$type-postgresql/timescaledb.sql | psql -q \ + -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ + -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + fi + unset PGPASSWORD unset PGOPTIONS fi diff --git a/server-mysql/centos/docker-entrypoint.sh b/server-mysql/centos/docker-entrypoint.sh index e7b95037f..fb08a76e5 100755 --- a/server-mysql/centos/docker-entrypoint.sh +++ b/server-mysql/centos/docker-entrypoint.sh @@ -30,6 +30,9 @@ ZBX_SERVER_PORT=${ZBX_SERVER_PORT:-"10051"} # Default timezone for web interface PHP_TZ=${PHP_TZ:-"Europe/Riga"} +#Enable PostgreSQL timescaleDB feature: +ENABLE_TIMESCALEDB=${ENABLE_TIMESCALEDB:-"false"} + # Default directories # User 'zabbix' home directory ZABBIX_USER_HOME_DIR="/var/lib/zabbix" @@ -439,7 +442,7 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '$DB_SERVER_SCHEMA' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." @@ -449,6 +452,10 @@ create_db_schema_postgresql() { if [ -z "${ZBX_DB_VERSION}" ]; then echo "** Creating '${DB_SERVER_DBNAME}' schema in PostgreSQL" + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + psql_query "CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;" + fi + if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi @@ -462,6 +469,12 @@ create_db_schema_postgresql() { -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + cat /usr/share/doc/zabbix-$type-postgresql/timescaledb.sql | psql -q \ + -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ + -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + fi + unset PGPASSWORD unset PGOPTIONS fi diff --git a/server-mysql/ubuntu/docker-entrypoint.sh b/server-mysql/ubuntu/docker-entrypoint.sh index e7b95037f..fb08a76e5 100755 --- a/server-mysql/ubuntu/docker-entrypoint.sh +++ b/server-mysql/ubuntu/docker-entrypoint.sh @@ -30,6 +30,9 @@ ZBX_SERVER_PORT=${ZBX_SERVER_PORT:-"10051"} # Default timezone for web interface PHP_TZ=${PHP_TZ:-"Europe/Riga"} +#Enable PostgreSQL timescaleDB feature: +ENABLE_TIMESCALEDB=${ENABLE_TIMESCALEDB:-"false"} + # Default directories # User 'zabbix' home directory ZABBIX_USER_HOME_DIR="/var/lib/zabbix" @@ -439,7 +442,7 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '$DB_SERVER_SCHEMA' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." @@ -449,6 +452,10 @@ create_db_schema_postgresql() { if [ -z "${ZBX_DB_VERSION}" ]; then echo "** Creating '${DB_SERVER_DBNAME}' schema in PostgreSQL" + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + psql_query "CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;" + fi + if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi @@ -462,6 +469,12 @@ create_db_schema_postgresql() { -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + cat /usr/share/doc/zabbix-$type-postgresql/timescaledb.sql | psql -q \ + -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ + -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + fi + unset PGPASSWORD unset PGOPTIONS fi diff --git a/server-pgsql/alpine/Dockerfile b/server-pgsql/alpine/Dockerfile index b4baf480f..5f13f28f5 100644 --- a/server-pgsql/alpine/Dockerfile +++ b/server-pgsql/alpine/Dockerfile @@ -126,6 +126,7 @@ RUN apk add ${APK_FLAGS_DEV} --virtual build-dependencies \ cat database/${ZBX_DB_TYPE}/data.sql >> database/${ZBX_DB_TYPE}/create.sql && \ gzip database/${ZBX_DB_TYPE}/create.sql && \ cp database/${ZBX_DB_TYPE}/create.sql.gz /usr/share/doc/zabbix-${ZBX_TYPE}-${ZBX_DB_TYPE}/ && \ + cp database/${ZBX_DB_TYPE}/timescaledb.sql /usr/share/doc/zabbix-${ZBX_TYPE}-${ZBX_DB_TYPE}/ && \ cd /tmp/ && \ rm -rf /tmp/zabbix-${ZBX_VERSION}/ && \ apk del ${APK_FLAGS_COMMON} --purge \ diff --git a/server-pgsql/alpine/docker-entrypoint.sh b/server-pgsql/alpine/docker-entrypoint.sh index e7b95037f..fb08a76e5 100755 --- a/server-pgsql/alpine/docker-entrypoint.sh +++ b/server-pgsql/alpine/docker-entrypoint.sh @@ -30,6 +30,9 @@ ZBX_SERVER_PORT=${ZBX_SERVER_PORT:-"10051"} # Default timezone for web interface PHP_TZ=${PHP_TZ:-"Europe/Riga"} +#Enable PostgreSQL timescaleDB feature: +ENABLE_TIMESCALEDB=${ENABLE_TIMESCALEDB:-"false"} + # Default directories # User 'zabbix' home directory ZABBIX_USER_HOME_DIR="/var/lib/zabbix" @@ -439,7 +442,7 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '$DB_SERVER_SCHEMA' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." @@ -449,6 +452,10 @@ create_db_schema_postgresql() { if [ -z "${ZBX_DB_VERSION}" ]; then echo "** Creating '${DB_SERVER_DBNAME}' schema in PostgreSQL" + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + psql_query "CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;" + fi + if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi @@ -462,6 +469,12 @@ create_db_schema_postgresql() { -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + cat /usr/share/doc/zabbix-$type-postgresql/timescaledb.sql | psql -q \ + -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ + -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + fi + unset PGPASSWORD unset PGOPTIONS fi diff --git a/server-pgsql/centos/Dockerfile b/server-pgsql/centos/Dockerfile index 0eddc2ab2..23ed12084 100644 --- a/server-pgsql/centos/Dockerfile +++ b/server-pgsql/centos/Dockerfile @@ -97,6 +97,7 @@ COPY --from=builder /tmp/zabbix-${ZBX_VERSION}/src/zabbix_get/zabbix_get /usr/bi COPY --from=builder /tmp/zabbix-${ZBX_VERSION}/src/zabbix_sender/zabbix_sender /usr/bin/zabbix_sender COPY --from=builder /tmp/zabbix-${ZBX_VERSION}/conf/zabbix_${ZBX_TYPE}.conf /etc/zabbix/zabbix_${ZBX_TYPE}.conf COPY --from=builder /tmp/zabbix-${ZBX_VERSION}/database/${ZBX_DB_TYPE}/create.sql.gz /usr/share/doc/zabbix-${ZBX_TYPE}-${ZBX_DB_TYPE}/create.sql.gz +COPY --from=builder /tmp/zabbix-${ZBX_VERSION}/database/${ZBX_DB_TYPE}/timescaledb.sql /usr/share/doc/zabbix-${ZBX_TYPE}-${ZBX_DB_TYPE}/timescaledb.sql ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /sbin/tini RUN groupadd --system zabbix && \ diff --git a/server-pgsql/centos/docker-entrypoint.sh b/server-pgsql/centos/docker-entrypoint.sh index e7b95037f..fb08a76e5 100755 --- a/server-pgsql/centos/docker-entrypoint.sh +++ b/server-pgsql/centos/docker-entrypoint.sh @@ -30,6 +30,9 @@ ZBX_SERVER_PORT=${ZBX_SERVER_PORT:-"10051"} # Default timezone for web interface PHP_TZ=${PHP_TZ:-"Europe/Riga"} +#Enable PostgreSQL timescaleDB feature: +ENABLE_TIMESCALEDB=${ENABLE_TIMESCALEDB:-"false"} + # Default directories # User 'zabbix' home directory ZABBIX_USER_HOME_DIR="/var/lib/zabbix" @@ -439,7 +442,7 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '$DB_SERVER_SCHEMA' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." @@ -449,6 +452,10 @@ create_db_schema_postgresql() { if [ -z "${ZBX_DB_VERSION}" ]; then echo "** Creating '${DB_SERVER_DBNAME}' schema in PostgreSQL" + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + psql_query "CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;" + fi + if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi @@ -462,6 +469,12 @@ create_db_schema_postgresql() { -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + cat /usr/share/doc/zabbix-$type-postgresql/timescaledb.sql | psql -q \ + -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ + -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + fi + unset PGPASSWORD unset PGOPTIONS fi diff --git a/server-pgsql/ubuntu/Dockerfile b/server-pgsql/ubuntu/Dockerfile index a3770dc09..a4b5b6bd9 100644 --- a/server-pgsql/ubuntu/Dockerfile +++ b/server-pgsql/ubuntu/Dockerfile @@ -142,6 +142,7 @@ RUN apt-get ${APT_FLAGS_COMMON} update && \ cat database/${ZBX_DB_TYPE}/data.sql >> database/${ZBX_DB_TYPE}/create.sql && \ gzip database/${ZBX_DB_TYPE}/create.sql && \ cp database/${ZBX_DB_TYPE}/create.sql.gz /usr/share/doc/zabbix-${ZBX_TYPE}-${ZBX_DB_TYPE}/ && \ + cp database/${ZBX_DB_TYPE}/timescaledb.sql /usr/share/doc/zabbix-${ZBX_TYPE}-${ZBX_DB_TYPE}/ && \ cd /tmp/ && \ rm -rf /tmp/zabbix-${ZBX_VERSION}/ && \ apt-get ${APT_FLAGS_COMMON} purge \ diff --git a/server-pgsql/ubuntu/docker-entrypoint.sh b/server-pgsql/ubuntu/docker-entrypoint.sh index e7b95037f..fb08a76e5 100755 --- a/server-pgsql/ubuntu/docker-entrypoint.sh +++ b/server-pgsql/ubuntu/docker-entrypoint.sh @@ -30,6 +30,9 @@ ZBX_SERVER_PORT=${ZBX_SERVER_PORT:-"10051"} # Default timezone for web interface PHP_TZ=${PHP_TZ:-"Europe/Riga"} +#Enable PostgreSQL timescaleDB feature: +ENABLE_TIMESCALEDB=${ENABLE_TIMESCALEDB:-"false"} + # Default directories # User 'zabbix' home directory ZABBIX_USER_HOME_DIR="/var/lib/zabbix" @@ -439,7 +442,7 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '$DB_SERVER_SCHEMA' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." @@ -449,6 +452,10 @@ create_db_schema_postgresql() { if [ -z "${ZBX_DB_VERSION}" ]; then echo "** Creating '${DB_SERVER_DBNAME}' schema in PostgreSQL" + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + psql_query "CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;" + fi + if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi @@ -462,6 +469,12 @@ create_db_schema_postgresql() { -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + cat /usr/share/doc/zabbix-$type-postgresql/timescaledb.sql | psql -q \ + -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ + -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + fi + unset PGPASSWORD unset PGOPTIONS fi diff --git a/web-apache-mysql/alpine/docker-entrypoint.sh b/web-apache-mysql/alpine/docker-entrypoint.sh index e7b95037f..fb08a76e5 100755 --- a/web-apache-mysql/alpine/docker-entrypoint.sh +++ b/web-apache-mysql/alpine/docker-entrypoint.sh @@ -30,6 +30,9 @@ ZBX_SERVER_PORT=${ZBX_SERVER_PORT:-"10051"} # Default timezone for web interface PHP_TZ=${PHP_TZ:-"Europe/Riga"} +#Enable PostgreSQL timescaleDB feature: +ENABLE_TIMESCALEDB=${ENABLE_TIMESCALEDB:-"false"} + # Default directories # User 'zabbix' home directory ZABBIX_USER_HOME_DIR="/var/lib/zabbix" @@ -439,7 +442,7 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '$DB_SERVER_SCHEMA' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." @@ -449,6 +452,10 @@ create_db_schema_postgresql() { if [ -z "${ZBX_DB_VERSION}" ]; then echo "** Creating '${DB_SERVER_DBNAME}' schema in PostgreSQL" + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + psql_query "CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;" + fi + if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi @@ -462,6 +469,12 @@ create_db_schema_postgresql() { -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + cat /usr/share/doc/zabbix-$type-postgresql/timescaledb.sql | psql -q \ + -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ + -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + fi + unset PGPASSWORD unset PGOPTIONS fi diff --git a/web-apache-mysql/centos/docker-entrypoint.sh b/web-apache-mysql/centos/docker-entrypoint.sh index e7b95037f..fb08a76e5 100755 --- a/web-apache-mysql/centos/docker-entrypoint.sh +++ b/web-apache-mysql/centos/docker-entrypoint.sh @@ -30,6 +30,9 @@ ZBX_SERVER_PORT=${ZBX_SERVER_PORT:-"10051"} # Default timezone for web interface PHP_TZ=${PHP_TZ:-"Europe/Riga"} +#Enable PostgreSQL timescaleDB feature: +ENABLE_TIMESCALEDB=${ENABLE_TIMESCALEDB:-"false"} + # Default directories # User 'zabbix' home directory ZABBIX_USER_HOME_DIR="/var/lib/zabbix" @@ -439,7 +442,7 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '$DB_SERVER_SCHEMA' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." @@ -449,6 +452,10 @@ create_db_schema_postgresql() { if [ -z "${ZBX_DB_VERSION}" ]; then echo "** Creating '${DB_SERVER_DBNAME}' schema in PostgreSQL" + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + psql_query "CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;" + fi + if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi @@ -462,6 +469,12 @@ create_db_schema_postgresql() { -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + cat /usr/share/doc/zabbix-$type-postgresql/timescaledb.sql | psql -q \ + -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ + -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + fi + unset PGPASSWORD unset PGOPTIONS fi diff --git a/web-apache-mysql/ubuntu/docker-entrypoint.sh b/web-apache-mysql/ubuntu/docker-entrypoint.sh index e7b95037f..fb08a76e5 100755 --- a/web-apache-mysql/ubuntu/docker-entrypoint.sh +++ b/web-apache-mysql/ubuntu/docker-entrypoint.sh @@ -30,6 +30,9 @@ ZBX_SERVER_PORT=${ZBX_SERVER_PORT:-"10051"} # Default timezone for web interface PHP_TZ=${PHP_TZ:-"Europe/Riga"} +#Enable PostgreSQL timescaleDB feature: +ENABLE_TIMESCALEDB=${ENABLE_TIMESCALEDB:-"false"} + # Default directories # User 'zabbix' home directory ZABBIX_USER_HOME_DIR="/var/lib/zabbix" @@ -439,7 +442,7 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '$DB_SERVER_SCHEMA' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." @@ -449,6 +452,10 @@ create_db_schema_postgresql() { if [ -z "${ZBX_DB_VERSION}" ]; then echo "** Creating '${DB_SERVER_DBNAME}' schema in PostgreSQL" + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + psql_query "CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;" + fi + if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi @@ -462,6 +469,12 @@ create_db_schema_postgresql() { -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + cat /usr/share/doc/zabbix-$type-postgresql/timescaledb.sql | psql -q \ + -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ + -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + fi + unset PGPASSWORD unset PGOPTIONS fi diff --git a/web-apache-pgsql/alpine/docker-entrypoint.sh b/web-apache-pgsql/alpine/docker-entrypoint.sh index e7b95037f..fb08a76e5 100755 --- a/web-apache-pgsql/alpine/docker-entrypoint.sh +++ b/web-apache-pgsql/alpine/docker-entrypoint.sh @@ -30,6 +30,9 @@ ZBX_SERVER_PORT=${ZBX_SERVER_PORT:-"10051"} # Default timezone for web interface PHP_TZ=${PHP_TZ:-"Europe/Riga"} +#Enable PostgreSQL timescaleDB feature: +ENABLE_TIMESCALEDB=${ENABLE_TIMESCALEDB:-"false"} + # Default directories # User 'zabbix' home directory ZABBIX_USER_HOME_DIR="/var/lib/zabbix" @@ -439,7 +442,7 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '$DB_SERVER_SCHEMA' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." @@ -449,6 +452,10 @@ create_db_schema_postgresql() { if [ -z "${ZBX_DB_VERSION}" ]; then echo "** Creating '${DB_SERVER_DBNAME}' schema in PostgreSQL" + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + psql_query "CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;" + fi + if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi @@ -462,6 +469,12 @@ create_db_schema_postgresql() { -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + cat /usr/share/doc/zabbix-$type-postgresql/timescaledb.sql | psql -q \ + -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ + -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + fi + unset PGPASSWORD unset PGOPTIONS fi diff --git a/web-apache-pgsql/centos/docker-entrypoint.sh b/web-apache-pgsql/centos/docker-entrypoint.sh index e7b95037f..fb08a76e5 100755 --- a/web-apache-pgsql/centos/docker-entrypoint.sh +++ b/web-apache-pgsql/centos/docker-entrypoint.sh @@ -30,6 +30,9 @@ ZBX_SERVER_PORT=${ZBX_SERVER_PORT:-"10051"} # Default timezone for web interface PHP_TZ=${PHP_TZ:-"Europe/Riga"} +#Enable PostgreSQL timescaleDB feature: +ENABLE_TIMESCALEDB=${ENABLE_TIMESCALEDB:-"false"} + # Default directories # User 'zabbix' home directory ZABBIX_USER_HOME_DIR="/var/lib/zabbix" @@ -439,7 +442,7 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '$DB_SERVER_SCHEMA' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." @@ -449,6 +452,10 @@ create_db_schema_postgresql() { if [ -z "${ZBX_DB_VERSION}" ]; then echo "** Creating '${DB_SERVER_DBNAME}' schema in PostgreSQL" + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + psql_query "CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;" + fi + if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi @@ -462,6 +469,12 @@ create_db_schema_postgresql() { -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + cat /usr/share/doc/zabbix-$type-postgresql/timescaledb.sql | psql -q \ + -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ + -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + fi + unset PGPASSWORD unset PGOPTIONS fi diff --git a/web-apache-pgsql/ubuntu/docker-entrypoint.sh b/web-apache-pgsql/ubuntu/docker-entrypoint.sh index e7b95037f..fb08a76e5 100755 --- a/web-apache-pgsql/ubuntu/docker-entrypoint.sh +++ b/web-apache-pgsql/ubuntu/docker-entrypoint.sh @@ -30,6 +30,9 @@ ZBX_SERVER_PORT=${ZBX_SERVER_PORT:-"10051"} # Default timezone for web interface PHP_TZ=${PHP_TZ:-"Europe/Riga"} +#Enable PostgreSQL timescaleDB feature: +ENABLE_TIMESCALEDB=${ENABLE_TIMESCALEDB:-"false"} + # Default directories # User 'zabbix' home directory ZABBIX_USER_HOME_DIR="/var/lib/zabbix" @@ -439,7 +442,7 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '$DB_SERVER_SCHEMA' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." @@ -449,6 +452,10 @@ create_db_schema_postgresql() { if [ -z "${ZBX_DB_VERSION}" ]; then echo "** Creating '${DB_SERVER_DBNAME}' schema in PostgreSQL" + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + psql_query "CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;" + fi + if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi @@ -462,6 +469,12 @@ create_db_schema_postgresql() { -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + cat /usr/share/doc/zabbix-$type-postgresql/timescaledb.sql | psql -q \ + -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ + -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + fi + unset PGPASSWORD unset PGOPTIONS fi diff --git a/web-nginx-mysql/alpine/docker-entrypoint.sh b/web-nginx-mysql/alpine/docker-entrypoint.sh index e7b95037f..fb08a76e5 100755 --- a/web-nginx-mysql/alpine/docker-entrypoint.sh +++ b/web-nginx-mysql/alpine/docker-entrypoint.sh @@ -30,6 +30,9 @@ ZBX_SERVER_PORT=${ZBX_SERVER_PORT:-"10051"} # Default timezone for web interface PHP_TZ=${PHP_TZ:-"Europe/Riga"} +#Enable PostgreSQL timescaleDB feature: +ENABLE_TIMESCALEDB=${ENABLE_TIMESCALEDB:-"false"} + # Default directories # User 'zabbix' home directory ZABBIX_USER_HOME_DIR="/var/lib/zabbix" @@ -439,7 +442,7 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '$DB_SERVER_SCHEMA' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." @@ -449,6 +452,10 @@ create_db_schema_postgresql() { if [ -z "${ZBX_DB_VERSION}" ]; then echo "** Creating '${DB_SERVER_DBNAME}' schema in PostgreSQL" + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + psql_query "CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;" + fi + if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi @@ -462,6 +469,12 @@ create_db_schema_postgresql() { -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + cat /usr/share/doc/zabbix-$type-postgresql/timescaledb.sql | psql -q \ + -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ + -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + fi + unset PGPASSWORD unset PGOPTIONS fi diff --git a/web-nginx-mysql/centos/docker-entrypoint.sh b/web-nginx-mysql/centos/docker-entrypoint.sh index e7b95037f..fb08a76e5 100755 --- a/web-nginx-mysql/centos/docker-entrypoint.sh +++ b/web-nginx-mysql/centos/docker-entrypoint.sh @@ -30,6 +30,9 @@ ZBX_SERVER_PORT=${ZBX_SERVER_PORT:-"10051"} # Default timezone for web interface PHP_TZ=${PHP_TZ:-"Europe/Riga"} +#Enable PostgreSQL timescaleDB feature: +ENABLE_TIMESCALEDB=${ENABLE_TIMESCALEDB:-"false"} + # Default directories # User 'zabbix' home directory ZABBIX_USER_HOME_DIR="/var/lib/zabbix" @@ -439,7 +442,7 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '$DB_SERVER_SCHEMA' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." @@ -449,6 +452,10 @@ create_db_schema_postgresql() { if [ -z "${ZBX_DB_VERSION}" ]; then echo "** Creating '${DB_SERVER_DBNAME}' schema in PostgreSQL" + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + psql_query "CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;" + fi + if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi @@ -462,6 +469,12 @@ create_db_schema_postgresql() { -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + cat /usr/share/doc/zabbix-$type-postgresql/timescaledb.sql | psql -q \ + -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ + -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + fi + unset PGPASSWORD unset PGOPTIONS fi diff --git a/web-nginx-mysql/ubuntu/docker-entrypoint.sh b/web-nginx-mysql/ubuntu/docker-entrypoint.sh index e7b95037f..fb08a76e5 100755 --- a/web-nginx-mysql/ubuntu/docker-entrypoint.sh +++ b/web-nginx-mysql/ubuntu/docker-entrypoint.sh @@ -30,6 +30,9 @@ ZBX_SERVER_PORT=${ZBX_SERVER_PORT:-"10051"} # Default timezone for web interface PHP_TZ=${PHP_TZ:-"Europe/Riga"} +#Enable PostgreSQL timescaleDB feature: +ENABLE_TIMESCALEDB=${ENABLE_TIMESCALEDB:-"false"} + # Default directories # User 'zabbix' home directory ZABBIX_USER_HOME_DIR="/var/lib/zabbix" @@ -439,7 +442,7 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '$DB_SERVER_SCHEMA' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." @@ -449,6 +452,10 @@ create_db_schema_postgresql() { if [ -z "${ZBX_DB_VERSION}" ]; then echo "** Creating '${DB_SERVER_DBNAME}' schema in PostgreSQL" + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + psql_query "CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;" + fi + if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi @@ -462,6 +469,12 @@ create_db_schema_postgresql() { -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + cat /usr/share/doc/zabbix-$type-postgresql/timescaledb.sql | psql -q \ + -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ + -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + fi + unset PGPASSWORD unset PGOPTIONS fi diff --git a/web-nginx-pgsql/alpine/docker-entrypoint.sh b/web-nginx-pgsql/alpine/docker-entrypoint.sh index e7b95037f..fb08a76e5 100755 --- a/web-nginx-pgsql/alpine/docker-entrypoint.sh +++ b/web-nginx-pgsql/alpine/docker-entrypoint.sh @@ -30,6 +30,9 @@ ZBX_SERVER_PORT=${ZBX_SERVER_PORT:-"10051"} # Default timezone for web interface PHP_TZ=${PHP_TZ:-"Europe/Riga"} +#Enable PostgreSQL timescaleDB feature: +ENABLE_TIMESCALEDB=${ENABLE_TIMESCALEDB:-"false"} + # Default directories # User 'zabbix' home directory ZABBIX_USER_HOME_DIR="/var/lib/zabbix" @@ -439,7 +442,7 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '$DB_SERVER_SCHEMA' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." @@ -449,6 +452,10 @@ create_db_schema_postgresql() { if [ -z "${ZBX_DB_VERSION}" ]; then echo "** Creating '${DB_SERVER_DBNAME}' schema in PostgreSQL" + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + psql_query "CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;" + fi + if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi @@ -462,6 +469,12 @@ create_db_schema_postgresql() { -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + cat /usr/share/doc/zabbix-$type-postgresql/timescaledb.sql | psql -q \ + -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ + -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + fi + unset PGPASSWORD unset PGOPTIONS fi diff --git a/web-nginx-pgsql/centos/docker-entrypoint.sh b/web-nginx-pgsql/centos/docker-entrypoint.sh index e7b95037f..fb08a76e5 100755 --- a/web-nginx-pgsql/centos/docker-entrypoint.sh +++ b/web-nginx-pgsql/centos/docker-entrypoint.sh @@ -30,6 +30,9 @@ ZBX_SERVER_PORT=${ZBX_SERVER_PORT:-"10051"} # Default timezone for web interface PHP_TZ=${PHP_TZ:-"Europe/Riga"} +#Enable PostgreSQL timescaleDB feature: +ENABLE_TIMESCALEDB=${ENABLE_TIMESCALEDB:-"false"} + # Default directories # User 'zabbix' home directory ZABBIX_USER_HOME_DIR="/var/lib/zabbix" @@ -439,7 +442,7 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '$DB_SERVER_SCHEMA' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." @@ -449,6 +452,10 @@ create_db_schema_postgresql() { if [ -z "${ZBX_DB_VERSION}" ]; then echo "** Creating '${DB_SERVER_DBNAME}' schema in PostgreSQL" + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + psql_query "CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;" + fi + if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi @@ -462,6 +469,12 @@ create_db_schema_postgresql() { -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + cat /usr/share/doc/zabbix-$type-postgresql/timescaledb.sql | psql -q \ + -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ + -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + fi + unset PGPASSWORD unset PGOPTIONS fi diff --git a/web-nginx-pgsql/ubuntu/docker-entrypoint.sh b/web-nginx-pgsql/ubuntu/docker-entrypoint.sh index e7b95037f..fb08a76e5 100755 --- a/web-nginx-pgsql/ubuntu/docker-entrypoint.sh +++ b/web-nginx-pgsql/ubuntu/docker-entrypoint.sh @@ -30,6 +30,9 @@ ZBX_SERVER_PORT=${ZBX_SERVER_PORT:-"10051"} # Default timezone for web interface PHP_TZ=${PHP_TZ:-"Europe/Riga"} +#Enable PostgreSQL timescaleDB feature: +ENABLE_TIMESCALEDB=${ENABLE_TIMESCALEDB:-"false"} + # Default directories # User 'zabbix' home directory ZABBIX_USER_HOME_DIR="/var/lib/zabbix" @@ -439,7 +442,7 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '$DB_SERVER_SCHEMA' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." @@ -449,6 +452,10 @@ create_db_schema_postgresql() { if [ -z "${ZBX_DB_VERSION}" ]; then echo "** Creating '${DB_SERVER_DBNAME}' schema in PostgreSQL" + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + psql_query "CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;" + fi + if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi @@ -462,6 +469,12 @@ create_db_schema_postgresql() { -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + cat /usr/share/doc/zabbix-$type-postgresql/timescaledb.sql | psql -q \ + -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ + -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + fi + unset PGPASSWORD unset PGOPTIONS fi diff --git a/zabbix-appliance/alpine/docker-entrypoint.sh b/zabbix-appliance/alpine/docker-entrypoint.sh index e7b95037f..fb08a76e5 100755 --- a/zabbix-appliance/alpine/docker-entrypoint.sh +++ b/zabbix-appliance/alpine/docker-entrypoint.sh @@ -30,6 +30,9 @@ ZBX_SERVER_PORT=${ZBX_SERVER_PORT:-"10051"} # Default timezone for web interface PHP_TZ=${PHP_TZ:-"Europe/Riga"} +#Enable PostgreSQL timescaleDB feature: +ENABLE_TIMESCALEDB=${ENABLE_TIMESCALEDB:-"false"} + # Default directories # User 'zabbix' home directory ZABBIX_USER_HOME_DIR="/var/lib/zabbix" @@ -439,7 +442,7 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '$DB_SERVER_SCHEMA' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." @@ -449,6 +452,10 @@ create_db_schema_postgresql() { if [ -z "${ZBX_DB_VERSION}" ]; then echo "** Creating '${DB_SERVER_DBNAME}' schema in PostgreSQL" + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + psql_query "CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;" + fi + if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi @@ -462,6 +469,12 @@ create_db_schema_postgresql() { -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + cat /usr/share/doc/zabbix-$type-postgresql/timescaledb.sql | psql -q \ + -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ + -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + fi + unset PGPASSWORD unset PGOPTIONS fi diff --git a/zabbix-appliance/centos/docker-entrypoint.sh b/zabbix-appliance/centos/docker-entrypoint.sh index e7b95037f..fb08a76e5 100755 --- a/zabbix-appliance/centos/docker-entrypoint.sh +++ b/zabbix-appliance/centos/docker-entrypoint.sh @@ -30,6 +30,9 @@ ZBX_SERVER_PORT=${ZBX_SERVER_PORT:-"10051"} # Default timezone for web interface PHP_TZ=${PHP_TZ:-"Europe/Riga"} +#Enable PostgreSQL timescaleDB feature: +ENABLE_TIMESCALEDB=${ENABLE_TIMESCALEDB:-"false"} + # Default directories # User 'zabbix' home directory ZABBIX_USER_HOME_DIR="/var/lib/zabbix" @@ -439,7 +442,7 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '$DB_SERVER_SCHEMA' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." @@ -449,6 +452,10 @@ create_db_schema_postgresql() { if [ -z "${ZBX_DB_VERSION}" ]; then echo "** Creating '${DB_SERVER_DBNAME}' schema in PostgreSQL" + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + psql_query "CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;" + fi + if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi @@ -462,6 +469,12 @@ create_db_schema_postgresql() { -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + cat /usr/share/doc/zabbix-$type-postgresql/timescaledb.sql | psql -q \ + -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ + -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + fi + unset PGPASSWORD unset PGOPTIONS fi diff --git a/zabbix-appliance/rhel/docker-entrypoint.sh b/zabbix-appliance/rhel/docker-entrypoint.sh index e7b95037f..fb08a76e5 100755 --- a/zabbix-appliance/rhel/docker-entrypoint.sh +++ b/zabbix-appliance/rhel/docker-entrypoint.sh @@ -30,6 +30,9 @@ ZBX_SERVER_PORT=${ZBX_SERVER_PORT:-"10051"} # Default timezone for web interface PHP_TZ=${PHP_TZ:-"Europe/Riga"} +#Enable PostgreSQL timescaleDB feature: +ENABLE_TIMESCALEDB=${ENABLE_TIMESCALEDB:-"false"} + # Default directories # User 'zabbix' home directory ZABBIX_USER_HOME_DIR="/var/lib/zabbix" @@ -439,7 +442,7 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '$DB_SERVER_SCHEMA' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." @@ -449,6 +452,10 @@ create_db_schema_postgresql() { if [ -z "${ZBX_DB_VERSION}" ]; then echo "** Creating '${DB_SERVER_DBNAME}' schema in PostgreSQL" + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + psql_query "CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;" + fi + if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi @@ -462,6 +469,12 @@ create_db_schema_postgresql() { -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + cat /usr/share/doc/zabbix-$type-postgresql/timescaledb.sql | psql -q \ + -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ + -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + fi + unset PGPASSWORD unset PGOPTIONS fi diff --git a/zabbix-appliance/ubuntu/docker-entrypoint.sh b/zabbix-appliance/ubuntu/docker-entrypoint.sh index e7b95037f..fb08a76e5 100755 --- a/zabbix-appliance/ubuntu/docker-entrypoint.sh +++ b/zabbix-appliance/ubuntu/docker-entrypoint.sh @@ -30,6 +30,9 @@ ZBX_SERVER_PORT=${ZBX_SERVER_PORT:-"10051"} # Default timezone for web interface PHP_TZ=${PHP_TZ:-"Europe/Riga"} +#Enable PostgreSQL timescaleDB feature: +ENABLE_TIMESCALEDB=${ENABLE_TIMESCALEDB:-"false"} + # Default directories # User 'zabbix' home directory ZABBIX_USER_HOME_DIR="/var/lib/zabbix" @@ -439,7 +442,7 @@ create_db_schema_postgresql() { local type=$1 DBVERSION_TABLE_EXISTS=$(psql_query "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = - c.relnamespace WHERE n.nspname = '{$DB_SERVER_SCHEMA}' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") + c.relnamespace WHERE n.nspname = '$DB_SERVER_SCHEMA' AND c.relname = 'dbversion'" "${DB_SERVER_DBNAME}") if [ -n "${DBVERSION_TABLE_EXISTS}" ]; then echo "** Table '${DB_SERVER_DBNAME}.dbversion' already exists." @@ -449,6 +452,10 @@ create_db_schema_postgresql() { if [ -z "${ZBX_DB_VERSION}" ]; then echo "** Creating '${DB_SERVER_DBNAME}' schema in PostgreSQL" + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + psql_query "CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;" + fi + if [ -n "${DB_SERVER_ZBX_PASS}" ]; then export PGPASSWORD="${DB_SERVER_ZBX_PASS}" fi @@ -462,6 +469,12 @@ create_db_schema_postgresql() { -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + if [ "${ENABLE_TIMESCALEDB}" == "true" ]; then + cat /usr/share/doc/zabbix-$type-postgresql/timescaledb.sql | psql -q \ + -h ${DB_SERVER_HOST} -p ${DB_SERVER_PORT} \ + -U ${DB_SERVER_ZBX_USER} ${DB_SERVER_DBNAME} 1>/dev/null + fi + unset PGPASSWORD unset PGOPTIONS fi