Skip to content

Commit 19678e2

Browse files
authored
Update Zabbix install for Debian 13 and agent selection (#7819)
1 parent 1ac8f90 commit 19678e2

File tree

3 files changed

+135
-35
lines changed

3 files changed

+135
-35
lines changed

ct/zabbix.sh

Lines changed: 51 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ var_cpu="${var_cpu:-2}"
1111
var_ram="${var_ram:-4096}"
1212
var_disk="${var_disk:-6}"
1313
var_os="${var_os:-debian}"
14-
var_version="${var_version:-12}"
14+
var_version="${var_version:-13}"
1515
var_unprivileged="${var_unprivileged:-1}"
1616

1717
header_info "$APP"
@@ -23,37 +23,72 @@ function update_script() {
2323
header_info
2424
check_container_storage
2525
check_container_resources
26+
2627
if [[ ! -f /etc/zabbix/zabbix_server.conf ]]; then
2728
msg_error "No ${APP} Installation Found!"
2829
exit
2930
fi
30-
msg_info "Stopping ${APP} Services"
31-
systemctl stop zabbix-server zabbix-agent2
32-
msg_ok "Stopped ${APP} Services"
3331

34-
msg_info "Updating $APP LXC"
32+
. /etc/os-release
33+
if [ "$VERSION_CODENAME" != "trixie" ]; then
34+
msg_error "Unsupported Debian version: $VERSION_CODENAME – please upgrade to Debian 13 (Trixie) before updating Zabbix."
35+
exit 1
36+
fi
37+
38+
if systemctl list-unit-files | grep -q zabbix-agent2.service; then
39+
AGENT_SERVICE="zabbix-agent2"
40+
else
41+
AGENT_SERVICE="zabbix-agent"
42+
fi
43+
44+
msg_info "Stopping Services"
45+
systemctl stop zabbix-server $AGENT_SERVICE
46+
msg_ok "Stopped Services"
47+
48+
msg_info "Updating Zabbix"
3549
mkdir -p /opt/zabbix-backup/
3650
cp /etc/zabbix/zabbix_server.conf /opt/zabbix-backup/
3751
cp /etc/apache2/conf-enabled/zabbix.conf /opt/zabbix-backup/
3852
cp -R /usr/share/zabbix/ /opt/zabbix-backup/
39-
#cp -R /usr/share/zabbix-* /opt/zabbix-backup/ Remove temporary
53+
4054
rm -Rf /etc/apt/sources.list.d/zabbix.list
4155
cd /tmp
4256
curl -fsSL "$(curl -fsSL https://repo.zabbix.com/zabbix/ |
4357
grep -oP '(?<=href=")[0-9]+\.[0-9]+(?=/")' | sort -V | tail -n1 |
44-
xargs -I{} echo "https://repo.zabbix.com/zabbix/{}/release/debian/pool/main/z/zabbix-release/zabbix-release_latest+debian12_all.deb")" \
45-
-o /tmp/zabbix-release_latest+debian12_all.deb
46-
$STD dpkg -i zabbix-release_latest+debian12_all.deb
47-
$STD apt-get update
48-
$STD apt-get install --only-upgrade zabbix-server-pgsql zabbix-frontend-php zabbix-agent2 zabbix-agent2-plugin-*
49-
50-
msg_info "Starting ${APP} Services"
51-
systemctl start zabbix-server zabbix-agent2
58+
xargs -I{} echo "https://repo.zabbix.com/zabbix/{}/release/debian/pool/main/z/zabbix-release/zabbix-release_latest+debian13_all.deb")" \
59+
-o /tmp/zabbix-release_latest+debian13_all.deb
60+
$STD dpkg -i zabbix-release_latest+debian13_all.deb
61+
$STD apt update
62+
63+
$STD apt install --only-upgrade zabbix-server-pgsql zabbix-frontend-php php8.4-pgsql
64+
65+
if [ "$AGENT_SERVICE" = "zabbix-agent2" ]; then
66+
$STD apt install --only-upgrade zabbix-agent2 zabbix-agent2-plugin-postgresql
67+
if [ -f /etc/zabbix/zabbix_agent2.d/plugins.d/nvidia.conf ]; then
68+
sed -i 's|^Plugins.NVIDIA.System.Path=.*|# Plugins.NVIDIA.System.Path=/usr/libexec/zabbix/zabbix-agent2-plugin-nvidia-gpu|' \
69+
/etc/zabbix/zabbix_agent2.d/plugins.d/nvidia.conf
70+
fi
71+
else
72+
$STD apt install --only-upgrade zabbix-agent
73+
fi
74+
75+
if command -v fping >/dev/null 2>&1; then
76+
FPING_PATH=$(command -v fping)
77+
sed -i "s|^#\?FpingLocation=.*|FpingLocation=$FPING_PATH|" /etc/zabbix/zabbix_server.conf
78+
fi
79+
if command -v fping6 >/dev/null 2>&1; then
80+
FPING6_PATH=$(command -v fping6)
81+
sed -i "s|^#\?Fping6Location=.*|Fping6Location=$FPING6_PATH|" /etc/zabbix/zabbix_server.conf
82+
fi
83+
msg_ok "Updated Zabbix"
84+
85+
msg_info "Starting Services"
86+
systemctl start zabbix-server $AGENT_SERVICE
5287
systemctl restart apache2
53-
msg_ok "Started ${APP} Services"
88+
msg_ok "Started Services"
5489

5590
msg_info "Cleaning Up"
56-
rm -rf /tmp/zabbix-release_latest+debian12_all.deb
91+
rm -rf /tmp/zabbix-release_latest+debian13_all.deb
5792
msg_ok "Cleaned"
5893
msg_ok "Updated Successfully"
5994
exit

frontend/public/json/zabbix.json

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"ram": 4096,
2424
"hdd": 6,
2525
"os": "debian",
26-
"version": "12"
26+
"version": "13"
2727
}
2828
}
2929
],
@@ -33,11 +33,19 @@
3333
},
3434
"notes": [
3535
{
36-
"text": "Database credentials: `cat zabbix.creds`",
36+
"text": "Database credentials: `cat ~/zabbix.creds`",
3737
"type": "info"
3838
},
3939
{
40-
"text": "Zabbix agent 2 is used by default",
40+
"text": "You can choose between Zabbix agent (classic) and agent2 (modern) during installation",
41+
"type": "info"
42+
},
43+
{
44+
"text": "For agent2 the PostgreSQL plugin is installed by default; all plugins are optional",
45+
"type": "info"
46+
},
47+
{
48+
"text": "If agent2 with NVIDIA plugin is installed in an environment without GPU, the installer disables it automatically",
4149
"type": "info"
4250
}
4351
]

install/zabbix-install.sh

Lines changed: 73 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,61 @@ setting_up_container
1313
network_check
1414
update_os
1515

16+
PG_VERSION="17" setup_postgresql
17+
1618
msg_info "Installing Zabbix"
1719
cd /tmp
1820
curl -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
2627
msg_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+
2870
msg_info "Setting up PostgreSQL"
29-
$STD apt-get install -y postgresql
3071
DB_NAME=zabbixdb
3172
DB_USER=zabbix
3273
DB_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+
3888
zcat /usr/share/zabbix/sql-scripts/postgresql/server.sql.gz | sudo -u $DB_USER psql $DB_NAME &>/dev/null
3989
sed -i "s/^DBName=.*/DBName=$DB_NAME/" /etc/zabbix/zabbix_server.conf
4090
sed -i "s/^DBUser=.*/DBUser=$DB_USER/" /etc/zabbix/zabbix_server.conf
4191
sed -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
4892
msg_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+
50106
msg_info "Starting Services"
51107
systemctl restart zabbix-server zabbix-agent2 apache2
52108
systemctl enable -q --now zabbix-server zabbix-agent2 apache2
@@ -56,7 +112,8 @@ motd_ssh
56112
customize
57113

58114
msg_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
62119
msg_ok "Cleaned"

0 commit comments

Comments
 (0)