@@ -13,20 +13,61 @@ setting_up_container
1313network_check
1414update_os
1515
16+ PG_VERSION=" 17" setup_postgresql
17+
1618msg_info " Installing Zabbix"
1719cd /tmp
1820curl -fsSL " $( curl -fsSL https://repo.zabbix.com/zabbix/ |
1921 grep -oP ' (?<=href=")[0-9]+\.[0-9]+(?=/")' | sort -V | tail -n1 |
20- xargs -I{} echo " https://repo.zabbix.com/zabbix/{}/release/debian/pool/main/z/zabbix-release/zabbix-release_latest+debian12_all.deb" ) " \
21- -o /tmp/zabbix-release_latest+debian12_all.deb
22- $STD dpkg -i /tmp/zabbix-release_latest+debian12_all.deb
23- $STD apt-get update
24- $STD apt-get install -y zabbix-server-pgsql zabbix-frontend-php php8.2-pgsql zabbix-apache-conf zabbix-sql-scripts
25- $STD apt-get install -y zabbix-agent2 zabbix-agent2-plugin-*
22+ xargs -I{} echo " https://repo.zabbix.com/zabbix/{}/release/debian/pool/main/z/zabbix-release/zabbix-release_latest+debian13_all.deb" ) " \
23+ -o /tmp/zabbix-release_latest+debian13_all.deb
24+ $STD dpkg -i /tmp/zabbix-release_latest+debian13_all.deb
25+ $STD apt update
26+ $STD apt install -y zabbix-server-pgsql zabbix-frontend-php php8.4-pgsql zabbix-apache-conf zabbix-sql-scripts
2627msg_ok " Installed Zabbix"
2728
29+ while true ; do
30+ read -rp " Which agent do you want to install? [1=agent (classic), 2=agent2 (modern), default=1]: " AGENT_CHOICE
31+ case " $AGENT_CHOICE " in
32+ 2)
33+ AGENT_PKG=" zabbix-agent2"
34+ break
35+ ;;
36+ " " | 1)
37+ AGENT_PKG=" zabbix-agent"
38+ break
39+ ;;
40+ * )
41+ echo " Invalid choice. Please enter 1 or 2."
42+ ;;
43+ esac
44+ done
45+ msg_ok " Selected $AGENT_PKG "
46+
47+ if [ " $AGENT_PKG " = " zabbix-agent2" ]; then
48+ echo " Choose plugins for Zabbix Agent2:"
49+ echo " 1) PostgreSQL only (default, recommended)"
50+ echo " 2) All plugins (may cause issues)"
51+ read -rp " Choose option [1-2]: " PLUGIN_CHOICE
52+
53+ case " $PLUGIN_CHOICE " in
54+ 2)
55+ $STD apt install -y zabbix-agent2 zabbix-agent2-plugin-*
56+ ;;
57+ * )
58+ $STD apt install -y zabbix-agent2 zabbix-agent2-plugin-postgresql
59+ ;;
60+ esac
61+
62+ if [ -f /etc/zabbix/zabbix_agent2.d/plugins.d/nvidia.conf ]; then
63+ sed -i ' s|^Plugins.NVIDIA.System.Path=.*|# Plugins.NVIDIA.System.Path=/usr/libexec/zabbix/zabbix-agent2-plugin-nvidia-gpu|' \
64+ /etc/zabbix/zabbix_agent2.d/plugins.d/nvidia.conf
65+ fi
66+ else
67+ $STD apt install -y zabbix-agent
68+ fi
69+
2870msg_info " Setting up PostgreSQL"
29- $STD apt-get install -y postgresql
3071DB_NAME=zabbixdb
3172DB_USER=zabbix
3273DB_PASS=$( openssl rand -base64 18 | tr -dc ' a-zA-Z0-9' | cut -c1-13)
@@ -35,18 +76,33 @@ $STD sudo -u postgres psql -c "CREATE DATABASE $DB_NAME WITH OWNER $DB_USER ENCO
3576$STD sudo -u postgres psql -c " ALTER ROLE $DB_USER SET client_encoding TO 'utf8';"
3677$STD sudo -u postgres psql -c " ALTER ROLE $DB_USER SET default_transaction_isolation TO 'read committed';"
3778$STD sudo -u postgres psql -c " ALTER ROLE $DB_USER SET timezone TO 'UTC'"
79+ {
80+ echo " Zabbix-Credentials"
81+ echo " Zabbix Database User: $DB_USER "
82+ echo " Zabbix Database Password: $DB_PASS "
83+ echo " Zabbix Database Name: $DB_NAME "
84+ echo " Zabbix Admin Email: $ADMIN_EMAIL "
85+ echo " Zabbix Admin Password: $ADMIN_PASSWORD "
86+ } >> ~/zabbix.creds
87+
3888zcat /usr/share/zabbix/sql-scripts/postgresql/server.sql.gz | sudo -u $DB_USER psql $DB_NAME & > /dev/null
3989sed -i " s/^DBName=.*/DBName=$DB_NAME /" /etc/zabbix/zabbix_server.conf
4090sed -i " s/^DBUser=.*/DBUser=$DB_USER /" /etc/zabbix/zabbix_server.conf
4191sed -i " s/^# DBPassword=.*/DBPassword=$DB_PASS /" /etc/zabbix/zabbix_server.conf
42- echo " " > ~/zabbix.creds
43- echo " zabbix Database Credentials" >> ~/zabbix.creds
44- echo " " >> ~/zabbix.creds
45- echo -e " zabbix Database User: \e[32m$DB_USER \e[0m" >> ~/zabbix.creds
46- echo -e " zabbix Database Password: \e[32m$DB_PASS \e[0m" >> ~/zabbix.creds
47- echo -e " zabbix Database Name: \e[32m$DB_NAME \e[0m" >> ~/zabbix.creds
4892msg_ok " Set up PostgreSQL"
4993
94+ msg_info " Configuring Fping"
95+ if command -v fping > /dev/null 2>&1 ; then
96+ FPING_PATH=$( command -v fping)
97+ sed -i " s|^#\?FpingLocation=.*|FpingLocation=$FPING_PATH |" /etc/zabbix/zabbix_server.conf
98+ fi
99+
100+ if command -v fping6 > /dev/null 2>&1 ; then
101+ FPING6_PATH=$( command -v fping6)
102+ sed -i " s|^#\?Fping6Location=.*|Fping6Location=$FPING6_PATH |" /etc/zabbix/zabbix_server.conf
103+ fi
104+ msg_ok " Configured Fping"
105+
50106msg_info " Starting Services"
51107systemctl restart zabbix-server zabbix-agent2 apache2
52108systemctl enable -q --now zabbix-server zabbix-agent2 apache2
@@ -56,7 +112,8 @@ motd_ssh
56112customize
57113
58114msg_info " Cleaning up"
59- rm -rf /tmp/zabbix-release_latest+debian12_all.deb
60- $STD apt-get -y autoremove
61- $STD apt-get -y autoclean
115+ rm -rf /tmp/zabbix-release_latest+debian13_all.deb
116+ $STD apt -y autoremove
117+ $STD apt -y autoclean
118+ $STD apt -y clean
62119msg_ok " Cleaned"
0 commit comments