mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2026-11-07 09:17:54 +01:00
d6e4427ac9
* Zabbix: install on Debian 12 again The install and the update fetched Zabbix's release package for Debian 13 and php8.4-pgsql, so a Debian 12 container stopped with "Unable to locate package php8.4-pgsql" (12 runs in three days). Zabbix publishes 7.0 and 7.4 for Debian 12 too: take the container's Debian version and the distribution's php-pgsql. * Zabbix: leave the update as it was The update refuses Debian 12 on purpose, so its release URL stays as it was.
131 lines
4.4 KiB
Bash
131 lines
4.4 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
# Copyright (c) 2021-2026 community-scripts ORG
|
|
# Author: MickLesk (CanbiZ)
|
|
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
|
|
# Source: https://www.zabbix.com/
|
|
|
|
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
|
|
color
|
|
verb_ip6
|
|
catch_errors
|
|
setting_up_container
|
|
network_check
|
|
update_os
|
|
|
|
PG_VERSION="17" setup_postgresql
|
|
PG_DB_NAME="zabbixdb" PG_DB_USER="zabbix" setup_postgresql_db
|
|
|
|
ZABBIX_CHOICE="${var_zabbix_version:-}"
|
|
[[ -n "$ZABBIX_CHOICE" ]] || read -rp "Choose Zabbix version [1] 7.0 LTS [2] 7.4 (Latest Stable) [3] Latest available (default: 2): " ZABBIX_CHOICE || true
|
|
ZABBIX_CHOICE=${ZABBIX_CHOICE:-2}
|
|
case "$ZABBIX_CHOICE" in
|
|
1) ZABBIX_VERSION="7.0" ;;
|
|
2) ZABBIX_VERSION="7.4" ;;
|
|
3) ZABBIX_VERSION=$(curl -fsSL https://repo.zabbix.com/zabbix/ |
|
|
grep -oP '(?<=href=")[0-9]+\.[0-9]+(?=/")' | sort -V | tail -n1) ;;
|
|
*)
|
|
ZABBIX_VERSION="7.4"
|
|
echo "Invalid choice. Defaulting to 7.4."
|
|
;;
|
|
esac
|
|
|
|
msg_info "Installing Zabbix $ZABBIX_VERSION"
|
|
cd /tmp
|
|
|
|
ZABBIX_REPO_DIR="debian"
|
|
[[ "$ZABBIX_VERSION" == "7.0" && "$(arch_resolve)" == "arm64" ]] && ZABBIX_REPO_DIR="debian-arm64"
|
|
if [[ "$ZABBIX_VERSION" == "7.0" ]]; then
|
|
ZABBIX_DEB_URL="https://repo.zabbix.com/zabbix/${ZABBIX_VERSION}/${ZABBIX_REPO_DIR}/pool/main/z/zabbix-release/zabbix-release_latest_${ZABBIX_VERSION}+debian$(get_os_version_major)_all.deb"
|
|
ZABBIX_DEB_FILE="zabbix-release_latest_${ZABBIX_VERSION}+debian$(get_os_version_major)_all.deb"
|
|
else
|
|
ZABBIX_DEB_URL="https://repo.zabbix.com/zabbix/${ZABBIX_VERSION}/release/debian/pool/main/z/zabbix-release/zabbix-release_latest+debian$(get_os_version_major)_all.deb"
|
|
ZABBIX_DEB_FILE="zabbix-release_latest+debian$(get_os_version_major)_all.deb"
|
|
fi
|
|
|
|
curl -fsSL "$ZABBIX_DEB_URL" -o /tmp/"$ZABBIX_DEB_FILE"
|
|
$STD dpkg -i /tmp/"$ZABBIX_DEB_FILE"
|
|
apt_update_safe
|
|
$STD apt install -y zabbix-server-pgsql zabbix-frontend-php php-pgsql zabbix-apache-conf zabbix-sql-scripts
|
|
|
|
if [[ "$ZABBIX_VERSION" == "7.0" ]]; then
|
|
ZABBIX_SQL="/usr/share/zabbix-sql-scripts/postgresql/server.sql.gz"
|
|
else
|
|
ZABBIX_SQL="/usr/share/zabbix/sql-scripts/postgresql/server.sql.gz"
|
|
fi
|
|
|
|
zcat "$ZABBIX_SQL" | sudo -u "$PG_DB_USER" psql "$PG_DB_NAME" &>/dev/null
|
|
sed -i "s/^DBName=.*/DBName=$PG_DB_NAME/" /etc/zabbix/zabbix_server.conf
|
|
sed -i "s/^DBUser=.*/DBUser=$PG_DB_USER/" /etc/zabbix/zabbix_server.conf
|
|
sed -i "s/^# DBPassword=.*/DBPassword=$PG_DB_PASS/" /etc/zabbix/zabbix_server.conf
|
|
msg_ok "Installed Zabbix $ZABBIX_VERSION"
|
|
|
|
AGENT_CHOICE="${var_zabbix_agent:-}"
|
|
while true; do
|
|
[[ -n "$AGENT_CHOICE" ]] || read -rp "Which agent do you want to install? [1=agent (classic), 2=agent2 (modern), default=1]: " AGENT_CHOICE || AGENT_CHOICE="1"
|
|
case "$AGENT_CHOICE" in
|
|
2)
|
|
AGENT_PKG="zabbix-agent2"
|
|
break
|
|
;;
|
|
"" | 1)
|
|
AGENT_PKG="zabbix-agent"
|
|
break
|
|
;;
|
|
*)
|
|
echo "Invalid choice. Please enter 1 or 2."
|
|
AGENT_CHOICE=""
|
|
;;
|
|
esac
|
|
done
|
|
msg_ok "Selected $AGENT_PKG"
|
|
|
|
if [ "$AGENT_PKG" = "zabbix-agent2" ]; then
|
|
echo "Choose plugins for Zabbix Agent2:"
|
|
echo "1) PostgreSQL only (default, recommended)"
|
|
echo "2) All plugins except NVIDIA GPU (may cause issues)"
|
|
PLUGIN_CHOICE="${var_zabbix_plugins:-}"
|
|
[[ -n "$PLUGIN_CHOICE" ]] || read -rp "Choose option [1-2]: " PLUGIN_CHOICE || true
|
|
|
|
case "$PLUGIN_CHOICE" in
|
|
2)
|
|
# The NVIDIA plugin fails the agent's config test without NVML, which aborts the package install
|
|
mapfile -t AGENT2_PLUGINS < <(apt-cache search --names-only '^zabbix-agent2-plugin-' | awk '{print $1}' | grep -v nvidia)
|
|
$STD apt install -y zabbix-agent2 "${AGENT2_PLUGINS[@]}"
|
|
;;
|
|
*)
|
|
$STD apt install -y zabbix-agent2 zabbix-agent2-plugin-postgresql
|
|
;;
|
|
esac
|
|
else
|
|
$STD apt install -y zabbix-agent
|
|
fi
|
|
|
|
msg_info "Configuring Fping"
|
|
if command -v fping >/dev/null 2>&1; then
|
|
FPING_PATH=$(command -v fping)
|
|
sed -i "s|^#\?FpingLocation=.*|FpingLocation=$FPING_PATH|" /etc/zabbix/zabbix_server.conf
|
|
fi
|
|
|
|
if command -v fping6 >/dev/null 2>&1; then
|
|
FPING6_PATH=$(command -v fping6)
|
|
sed -i "s|^#\?Fping6Location=.*|Fping6Location=$FPING6_PATH|" /etc/zabbix/zabbix_server.conf
|
|
fi
|
|
msg_ok "Configured Fping"
|
|
|
|
msg_info "Starting Services"
|
|
if [ "$AGENT_PKG" = "zabbix-agent2" ]; then
|
|
AGENT_SERVICE="zabbix-agent2"
|
|
else
|
|
AGENT_SERVICE="zabbix-agent"
|
|
fi
|
|
|
|
systemctl restart zabbix-server apache2
|
|
systemctl enable -q --now zabbix-server $AGENT_SERVICE apache2
|
|
rm -rf /tmp/zabbix-release_*.deb
|
|
msg_ok "Started Services"
|
|
|
|
motd_ssh
|
|
customize
|
|
cleanup_lxc
|