From 99a47fb130f6d007ab2cc2a5b8e240300e400133 Mon Sep 17 00:00:00 2001 From: thorstenspille Date: Tue, 14 May 2024 00:19:52 +0200 Subject: [PATCH] update zabbix to 6.5 (7.0 beta) , add timescaledb --- src/zabbix/constants-service.conf | 7 ++++++- src/zabbix/install-service.sh | 25 ++++++++++++++++--------- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/zabbix/constants-service.conf b/src/zabbix/constants-service.conf index 8271c81..9ba34d4 100644 --- a/src/zabbix/constants-service.conf +++ b/src/zabbix/constants-service.conf @@ -13,7 +13,7 @@ LXC_TEMPLATE_VERSION="debian-12-standard" # Create sharefs mountpoint LXC_MP=0 # Defines the mountpoint of the filesystem shared by Zamba inside your LXC container (default: tank) -LXC_SHAREFS_MOUNTPOINT="tank" +LXC_SHAREFS_MOUNTPOINT="data" # Defines the recordsize of mp0 LXC_MP_RECORDSIZE="16K" @@ -42,6 +42,11 @@ ZABBIX_DB_USR="zabbix" # Build a strong password for the SQL user - could be overwritten with something fixed ZABBIX_DB_PWD="$(random_password)" +ZABBIX_VERSION=6.5 #zabbix 7 beta +POSTGRES_VERSION=16 #postgres repo, latest release (2024-05-13) +PHP_VERSION=8.2 # debian 12 default +TS_VERSION=2.14.2 # currently latest by zabbix supported version of timescaledb (2024-05-13) + # Sets the minimum amount of RAM the service needs for operation LXC_MEM_MIN=4096 diff --git a/src/zabbix/install-service.sh b/src/zabbix/install-service.sh index 8a0402a..da85ff1 100644 --- a/src/zabbix/install-service.sh +++ b/src/zabbix/install-service.sh @@ -5,20 +5,20 @@ # (C) 2021 Script design and prototype by Markus Helmke # (C) 2021 Script rework and documentation by Thorsten Spille +set -euo pipefail + source /root/functions.sh source /root/zamba.conf source /root/constants-service.conf -apt-key adv --fetch https://repo.zabbix.com/zabbix-official-repo.key -echo "deb https://repo.zabbix.com/zabbix/6.5/debian/ $(lsb_release -cs) main contrib non-free" > /etc/apt/sources.list.d/zabbix-6.5.list - -wget -q -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - -echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" | tee /etc/apt/sources.list.d/pgdg.list +apt_repo "zabbix" "https://repo.zabbix.com/zabbix-official-repo.key" "https://repo.zabbix.com/zabbix/${ZABBIX_VERSION}/debian/ $(lsb_release -cs) main" +apt_repo "postgresql" "https://www.postgresql.org/media/keys/ACCC4CF8.asc" "http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" +apt_repo "timescaledb" "https://packagecloud.io/timescale/timescaledb/gpgkey" "https://packagecloud.io/timescale/timescaledb/debian/ $(lsb_release -c -s) main" apt update DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical apt -y -qq dist-upgrade -DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical apt -y -qq install --no-install-recommends postgresql nginx php8.2-pgsql php8.2-fpm zabbix-server-pgsql zabbix-frontend-php zabbix-nginx-conf zabbix-sql-scripts zabbix-agent ssl-cert +DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical apt -y -qq install --no-install-recommends postgresql-$POSTGRES_VERSION timescaledb-2-oss-$TS_VERSION-postgresql-$POSTGRES_VERSION postgresql-client timescaledb-tools nginx php$PHP_VERSION-pgsql php$PHP_VERSION-fpm zabbix-server-pgsql zabbix-frontend-php zabbix-nginx-conf zabbix-sql-scripts zabbix-agent ssl-cert unlink /etc/nginx/sites-enabled/default @@ -122,7 +122,7 @@ server { } EOF -cat << EOF > /etc/php/7.4/fpm/pool.d/zabbix-php-fpm.conf +cat << EOF > /etc/php/$PHP_VERSION/fpm/pool.d/zabbix-php-fpm.conf [zabbix] user = www-data group = www-data @@ -220,10 +220,17 @@ sed -i "s/false/true/g" /usr/share/zabbix/include/locales.inc.php zcat /usr/share/zabbix-sql-scripts/postgresql/server.sql.gz | sudo -u zabbix psql ${ZABBIX_DB_NAME} +timescaledb-tune --quiet --yes >> /etc/postgresql/$POSTGRES_VERSION/main/postgresql.conf + +systemctl restart postgresql + +echo "CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;" | sudo -u postgres psql zabbix +cat /usr/share/zabbix-sql-scripts/postgresql/timescaledb/schema.sql | sudo -u zabbix psql ${ZABBIX_DB_NAME} + echo "DBPassword=${ZABBIX_DB_PWD}" >> /etc/zabbix/zabbix_server.conf generate_dhparam -systemctl enable --now zabbix-server zabbix-agent nginx php8.2-fpm +systemctl enable nginx php$PHP_VERSION-fpm zabbix-server zabbix-agent -systemctl restart zabbix-server zabbix-agent nginx php8.2-fpm \ No newline at end of file +systemctl restart nginx php$PHP_VERSION-fpm zabbix-server zabbix-agent > /dev/null 2>&1 \ No newline at end of file