New update for 32-bit ARM
This commit is contained in:
@@ -1,7 +1,9 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#
|
#
|
||||||
# Zabbix Agent 2 Deployment Script - Linux ARM (aarch64 / armhf)
|
# Zabbix Agent 2 Deployment Script - Linux ARM (aarch64 / armhf / armv6)
|
||||||
# Installs and configures Zabbix Agent 2 with PSK auto-registration
|
# Installs and configures Zabbix Agent 2 with PSK auto-registration
|
||||||
|
# For armhf/armv6: falls back to Zabbix Agent (v1) since Agent 2 is not
|
||||||
|
# available for 32-bit ARM (see ZBX-24905).
|
||||||
# Target server: zabbix.snarfnet.net
|
# Target server: zabbix.snarfnet.net
|
||||||
#
|
#
|
||||||
# Usage: sudo bash deploy_zabbix_agent_linux_arm.sh [psk_key]
|
# Usage: sudo bash deploy_zabbix_agent_linux_arm.sh [psk_key]
|
||||||
@@ -16,6 +18,7 @@ PSK_FILE="/etc/zabbix/zabbix_agent2.psk"
|
|||||||
AGENT_CONF="/etc/zabbix/zabbix_agent2.conf"
|
AGENT_CONF="/etc/zabbix/zabbix_agent2.conf"
|
||||||
HOST_METADATA="Linux"
|
HOST_METADATA="Linux"
|
||||||
INSTALL_DIR="/opt/zabbix-agent2"
|
INSTALL_DIR="/opt/zabbix-agent2"
|
||||||
|
USING_AGENT_V1=false
|
||||||
|
|
||||||
# --- Functions ---
|
# --- Functions ---
|
||||||
|
|
||||||
@@ -66,9 +69,11 @@ install_agent_package_manager() {
|
|||||||
|
|
||||||
# Zabbix provides separate repos for ARM architectures:
|
# Zabbix provides separate repos for ARM architectures:
|
||||||
# - debian-arm64 / ubuntu-arm64 for aarch64 (Bookworm/Trixie+ only)
|
# - debian-arm64 / ubuntu-arm64 for aarch64 (Bookworm/Trixie+ only)
|
||||||
# - raspbian for armhf (Raspberry Pi OS)
|
# - raspbian for armhf (Raspberry Pi OS) — but NOTE: Zabbix 7.0 does NOT
|
||||||
|
# ship zabbix-agent2 for armhf (see ZBX-24905). Only zabbix-agent (v1).
|
||||||
# The standard debian/ubuntu repos only carry amd64.
|
# The standard debian/ubuntu repos only carry amd64.
|
||||||
local repo_distro=""
|
local repo_distro=""
|
||||||
|
local has_agent2=true
|
||||||
case "${dpkg_arch}" in
|
case "${dpkg_arch}" in
|
||||||
arm64)
|
arm64)
|
||||||
if [ "${OS_ID}" = "ubuntu" ]; then
|
if [ "${OS_ID}" = "ubuntu" ]; then
|
||||||
@@ -79,6 +84,9 @@ install_agent_package_manager() {
|
|||||||
;;
|
;;
|
||||||
armhf)
|
armhf)
|
||||||
repo_distro="raspbian"
|
repo_distro="raspbian"
|
||||||
|
# Zabbix 7.0 raspbian repo does NOT include zabbix-agent2 for armhf.
|
||||||
|
# Only zabbix-agent (v1) is available.
|
||||||
|
has_agent2=false
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
log "Unexpected dpkg arch '${dpkg_arch}' on ARM script. Falling back to binary..."
|
log "Unexpected dpkg arch '${dpkg_arch}' on ARM script. Falling back to binary..."
|
||||||
@@ -103,8 +111,13 @@ install_agent_package_manager() {
|
|||||||
# then fall back to extracting from the bookworm .deb.
|
# then fall back to extracting from the bookworm .deb.
|
||||||
case "${codename}" in
|
case "${codename}" in
|
||||||
buster|bullseye|stretch|jessie)
|
buster|bullseye|stretch|jessie)
|
||||||
|
if [ "${has_agent2}" = true ]; then
|
||||||
log "Zabbix arm64 apt repo not available for EOL release '${codename}'."
|
log "Zabbix arm64 apt repo not available for EOL release '${codename}'."
|
||||||
log "Attempting install from Debian's own repositories..."
|
log "Attempting install from Debian's own repositories..."
|
||||||
|
else
|
||||||
|
log "Zabbix raspbian repo not available for EOL release '${codename}'."
|
||||||
|
log "Attempting install from Debian's own repositories..."
|
||||||
|
fi
|
||||||
|
|
||||||
# Disable defunct backports repos first
|
# Disable defunct backports repos first
|
||||||
local backports_list
|
local backports_list
|
||||||
@@ -119,9 +132,19 @@ install_agent_package_manager() {
|
|||||||
# Try installing from existing repos (Debian's own packages)
|
# Try installing from existing repos (Debian's own packages)
|
||||||
apt-get update 2>&1 | grep -v "^W:" || true
|
apt-get update 2>&1 | grep -v "^W:" || true
|
||||||
if apt-get install -y zabbix-agent2 2>/dev/null; then
|
if apt-get install -y zabbix-agent2 2>/dev/null; then
|
||||||
log "Installed from Debian repositories."
|
log "Installed zabbix-agent2 from Debian repositories."
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
# On armhf, try zabbix-agent (v1) as well
|
||||||
|
if [ "${has_agent2}" = false ]; then
|
||||||
|
log "zabbix-agent2 not available. Trying zabbix-agent (v1)..."
|
||||||
|
if apt-get install -y zabbix-agent 2>/dev/null; then
|
||||||
|
log "Installed zabbix-agent (v1) from Debian repositories."
|
||||||
|
AGENT_CONF="/etc/zabbix/zabbix_agentd.conf"
|
||||||
|
USING_AGENT_V1=true
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
log "Not available in Debian repos. Falling back to binary extraction..."
|
log "Not available in Debian repos. Falling back to binary extraction..."
|
||||||
install_agent_binary
|
install_agent_binary
|
||||||
@@ -139,8 +162,9 @@ install_agent_package_manager() {
|
|||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Download and install the Zabbix release package for the ARM-specific repo
|
# Download and install the Zabbix release package for the ARM-specific repo.
|
||||||
local release_url="https://repo.zabbix.com/zabbix/7.0/${repo_distro}/pool/main/z/zabbix-release/zabbix-release_latest_7.0+${OS_ID}${OS_VERSION}_all.deb"
|
# URL format: zabbix-release_latest+debian12_all.deb (for both raspbian & debian-arm64)
|
||||||
|
local release_url="https://repo.zabbix.com/zabbix/7.0/${repo_distro}/pool/main/z/zabbix-release/zabbix-release_latest+debian${OS_VERSION}_all.deb"
|
||||||
log "Adding Zabbix repository: ${repo_distro} (${codename})"
|
log "Adding Zabbix repository: ${repo_distro} (${codename})"
|
||||||
log "Release package URL: ${release_url}"
|
log "Release package URL: ${release_url}"
|
||||||
|
|
||||||
@@ -157,11 +181,25 @@ install_agent_package_manager() {
|
|||||||
|
|
||||||
dpkg -i /tmp/zabbix-release.deb
|
dpkg -i /tmp/zabbix-release.deb
|
||||||
apt-get update
|
apt-get update
|
||||||
if apt-get install -y zabbix-agent2; then
|
|
||||||
|
# Try zabbix-agent2 first
|
||||||
|
if apt-get install -y zabbix-agent2 2>/dev/null; then
|
||||||
rm -f /tmp/zabbix-release.deb
|
rm -f /tmp/zabbix-release.deb
|
||||||
log "Package installation successful."
|
log "zabbix-agent2 package installation successful."
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# On armhf, agent2 won't exist — fall back to zabbix-agent (v1)
|
||||||
|
if [ "${has_agent2}" = false ]; then
|
||||||
|
log "zabbix-agent2 not available for armhf. Installing zabbix-agent (v1)..."
|
||||||
|
if apt-get install -y zabbix-agent; then
|
||||||
|
rm -f /tmp/zabbix-release.deb
|
||||||
|
AGENT_CONF="/etc/zabbix/zabbix_agentd.conf"
|
||||||
|
USING_AGENT_V1=true
|
||||||
|
log "zabbix-agent (v1) package installation successful."
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
log "Package manager install failed, falling back to binary tarball..."
|
log "Package manager install failed, falling back to binary tarball..."
|
||||||
@@ -175,20 +213,93 @@ install_agent_package_manager() {
|
|||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
install_agent_v1_armhf() {
|
||||||
|
# Zabbix 7.0 raspbian repo provides zabbix-agent (v1) for armhf but NOT agent2.
|
||||||
|
# This function installs agent v1 as a fallback for 32-bit ARM systems.
|
||||||
|
detect_os
|
||||||
|
local codename=""
|
||||||
|
if [ -f /etc/os-release ]; then
|
||||||
|
codename=$(. /etc/os-release && echo "${VERSION_CODENAME:-}")
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Try adding the raspbian repo and installing zabbix-agent (v1)
|
||||||
|
local release_url="https://repo.zabbix.com/zabbix/7.0/raspbian/pool/main/z/zabbix-release/zabbix-release_latest+debian${OS_VERSION}_all.deb"
|
||||||
|
log "Trying Zabbix raspbian repo for zabbix-agent (v1)..."
|
||||||
|
log "Release URL: ${release_url}"
|
||||||
|
|
||||||
|
if wget -q "${release_url}" -O /tmp/zabbix-release.deb 2>/dev/null || \
|
||||||
|
curl -sfL "${release_url}" -o /tmp/zabbix-release.deb 2>/dev/null; then
|
||||||
|
if dpkg-deb --info /tmp/zabbix-release.deb >/dev/null 2>&1; then
|
||||||
|
dpkg -i /tmp/zabbix-release.deb 2>/dev/null || true
|
||||||
|
apt-get update 2>/dev/null || true
|
||||||
|
if apt-get install -y zabbix-agent 2>/dev/null; then
|
||||||
|
rm -f /tmp/zabbix-release.deb
|
||||||
|
AGENT_CONF="/etc/zabbix/zabbix_agentd.conf"
|
||||||
|
USING_AGENT_V1=true
|
||||||
|
log "Installed zabbix-agent (v1) successfully from raspbian repository."
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
rm -f /tmp/zabbix-release.deb
|
||||||
|
|
||||||
|
# Also try installing directly if it's already in repos
|
||||||
|
if apt-get install -y zabbix-agent 2>/dev/null; then
|
||||||
|
AGENT_CONF="/etc/zabbix/zabbix_agentd.conf"
|
||||||
|
USING_AGENT_V1=true
|
||||||
|
log "Installed zabbix-agent (v1) from existing repositories."
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
log "Could not install zabbix-agent (v1) either."
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
install_agent_binary() {
|
install_agent_binary() {
|
||||||
log "Installing Zabbix Agent 2 from direct .deb package..."
|
log "Installing Zabbix Agent 2 from direct .deb package..."
|
||||||
|
|
||||||
# Zabbix does not publish static binary tarballs for ARM architectures.
|
# Zabbix does not publish static binary tarballs for ARM architectures.
|
||||||
# Strategy: download the .deb and extract the binary without running post-install
|
# Strategy: download the .deb and extract the binary without running post-install
|
||||||
# scripts (which try to start the service before we've configured it).
|
# scripts (which try to start the service before we've configured it).
|
||||||
|
#
|
||||||
|
# IMPORTANT: Zabbix 7.0 only provides zabbix-agent2 for arm64, NOT armhf.
|
||||||
|
# For armhf/armv6 systems, we try arm64 .deb extraction (unlikely to work due to
|
||||||
|
# arch mismatch), then fall back to zabbix-agent (v1) from the raspbian repo,
|
||||||
|
# or suggest upgrading to a 64-bit OS.
|
||||||
|
|
||||||
local deb_path="/tmp/zabbix_agent2.deb"
|
local deb_path="/tmp/zabbix_agent2.deb"
|
||||||
local pool_base="https://repo.zabbix.com/zabbix/7.0/debian-arm64/pool/main/z/zabbix"
|
local dpkg_arch
|
||||||
|
dpkg_arch=$(dpkg --print-architecture 2>/dev/null || echo "unknown")
|
||||||
|
|
||||||
|
# Select the correct pool and architecture for the .deb download
|
||||||
|
local pool_base=""
|
||||||
|
local deb_arch=""
|
||||||
|
case "${dpkg_arch}" in
|
||||||
|
arm64)
|
||||||
|
pool_base="https://repo.zabbix.com/zabbix/7.0/debian-arm64/pool/main/z/zabbix"
|
||||||
|
deb_arch="arm64"
|
||||||
|
;;
|
||||||
|
armhf)
|
||||||
|
# Zabbix 7.0 does NOT publish agent2 for armhf. Try the raspbian pool
|
||||||
|
# for zabbix-agent (v1) first, then fall back to arm64 extraction attempt.
|
||||||
|
log "NOTE: Zabbix 7.0 does not provide zabbix-agent2 for armhf (32-bit ARM)."
|
||||||
|
log "Attempting to install zabbix-agent (v1) from raspbian repository..."
|
||||||
|
if install_agent_v1_armhf; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
# Last resort: try arm64 binary (won't work on 32-bit kernel)
|
||||||
|
pool_base="https://repo.zabbix.com/zabbix/7.0/debian-arm64/pool/main/z/zabbix"
|
||||||
|
deb_arch="arm64"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
pool_base="https://repo.zabbix.com/zabbix/7.0/debian-arm64/pool/main/z/zabbix"
|
||||||
|
deb_arch="arm64"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
# Try bookworm (Debian 12) arm64 .deb
|
|
||||||
local deb_urls=(
|
local deb_urls=(
|
||||||
"${pool_base}/zabbix-agent2_${ZABBIX_VERSION}-1+debian12_arm64.deb"
|
"${pool_base}/zabbix-agent2_${ZABBIX_VERSION}-1+debian12_${deb_arch}.deb"
|
||||||
"${pool_base}/zabbix-agent2_${ZABBIX_VERSION}-1%2Bdebian12_arm64.deb"
|
"${pool_base}/zabbix-agent2_${ZABBIX_VERSION}-1%2Bdebian12_${deb_arch}.deb"
|
||||||
)
|
)
|
||||||
|
|
||||||
local downloaded=false
|
local downloaded=false
|
||||||
@@ -276,10 +387,18 @@ install_agent_binary() {
|
|||||||
# Clean up the broken install
|
# Clean up the broken install
|
||||||
dpkg --remove --force-remove-reinstreq zabbix-agent2 2>/dev/null || true
|
dpkg --remove --force-remove-reinstreq zabbix-agent2 2>/dev/null || true
|
||||||
|
|
||||||
|
# On armhf, try zabbix-agent (v1) before giving up
|
||||||
|
if [ "${dpkg_arch}" = "armhf" ]; then
|
||||||
|
log "Attempting zabbix-agent (v1) as final fallback..."
|
||||||
|
if install_agent_v1_armhf; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
log "ERROR: Zabbix Agent 2 binary from Debian 12 is not compatible with this system."
|
log "ERROR: Zabbix Agent 2 binary from Debian 12 is not compatible with this system."
|
||||||
log " Your system runs glibc $(ldd --version 2>&1 | head -1 | grep -oP '\\d+\\.\\d+$' || echo 'unknown') but the package requires glibc 2.36+."
|
log " Your system runs glibc $(ldd --version 2>&1 | head -1 | grep -oP '\\d+\\.\\d+$' || echo 'unknown') but the package requires glibc 2.36+."
|
||||||
log " Options:"
|
log " Options:"
|
||||||
log " 1. Upgrade to Debian 12 (Bookworm): https://www.debian.org/releases/bookworm/"
|
log " 1. Upgrade to a 64-bit OS (Raspberry Pi OS 64-bit): https://www.raspberrypi.com/software/"
|
||||||
log " 2. Use Zabbix Agent (v1) instead: apt install zabbix-agent"
|
log " 2. Use Zabbix Agent (v1) instead: apt install zabbix-agent"
|
||||||
log " 3. Build from source: https://www.zabbix.com/documentation/current/en/manual/installation/install"
|
log " 3. Build from source: https://www.zabbix.com/documentation/current/en/manual/installation/install"
|
||||||
rm -f "${deb_path}"
|
rm -f "${deb_path}"
|
||||||
@@ -404,6 +523,34 @@ configure_agent() {
|
|||||||
# Back up existing config if present
|
# Back up existing config if present
|
||||||
[ -f "${AGENT_CONF}" ] && cp "${AGENT_CONF}" "${AGENT_CONF}.bak.$(date +%s)"
|
[ -f "${AGENT_CONF}" ] && cp "${AGENT_CONF}" "${AGENT_CONF}.bak.$(date +%s)"
|
||||||
|
|
||||||
|
if [ "${USING_AGENT_V1}" = true ]; then
|
||||||
|
# Zabbix Agent (v1) configuration — slightly different directives
|
||||||
|
cat > "${AGENT_CONF}" << EOF
|
||||||
|
# Zabbix Agent (v1) Configuration
|
||||||
|
# Auto-generated by ARM deployment script on $(date '+%Y-%m-%d %H:%M:%S')
|
||||||
|
# Architecture: ${ARCH} (${ARCH_LABEL})
|
||||||
|
# Note: Agent v1 installed because Agent 2 is not available for armhf
|
||||||
|
|
||||||
|
Server=${ZABBIX_SERVER}
|
||||||
|
ServerActive=${ZABBIX_SERVER}
|
||||||
|
HostnameItem=system.hostname
|
||||||
|
HostMetadata=${HOST_METADATA}
|
||||||
|
|
||||||
|
# PSK Encryption
|
||||||
|
TLSConnect=psk
|
||||||
|
TLSAccept=psk
|
||||||
|
TLSPSKIdentity=${PSK_IDENTITY}
|
||||||
|
TLSPSKFile=${PSK_FILE}
|
||||||
|
|
||||||
|
# Logging
|
||||||
|
LogFile=/var/log/zabbix/zabbix_agentd.log
|
||||||
|
LogFileSize=10
|
||||||
|
|
||||||
|
# Performance
|
||||||
|
BufferSend=5
|
||||||
|
BufferSize=100
|
||||||
|
EOF
|
||||||
|
else
|
||||||
cat > "${AGENT_CONF}" << EOF
|
cat > "${AGENT_CONF}" << EOF
|
||||||
# Zabbix Agent 2 Configuration
|
# Zabbix Agent 2 Configuration
|
||||||
# Auto-generated by ARM deployment script on $(date '+%Y-%m-%d %H:%M:%S')
|
# Auto-generated by ARM deployment script on $(date '+%Y-%m-%d %H:%M:%S')
|
||||||
@@ -428,25 +575,35 @@ LogFileSize=10
|
|||||||
BufferSend=5
|
BufferSend=5
|
||||||
BufferSize=100
|
BufferSize=100
|
||||||
EOF
|
EOF
|
||||||
|
fi
|
||||||
|
|
||||||
chown root:zabbix "${AGENT_CONF}"
|
chown root:zabbix "${AGENT_CONF}"
|
||||||
chmod 644 "${AGENT_CONF}"
|
chmod 644 "${AGENT_CONF}"
|
||||||
}
|
}
|
||||||
|
|
||||||
start_agent() {
|
start_agent() {
|
||||||
log "Enabling and starting zabbix-agent2..."
|
local service_name="zabbix-agent2"
|
||||||
systemctl enable zabbix-agent2
|
if [ "${USING_AGENT_V1}" = true ]; then
|
||||||
systemctl restart zabbix-agent2
|
service_name="zabbix-agent"
|
||||||
|
fi
|
||||||
|
|
||||||
|
log "Enabling and starting ${service_name}..."
|
||||||
|
systemctl enable "${service_name}"
|
||||||
|
systemctl restart "${service_name}"
|
||||||
|
|
||||||
sleep 2
|
sleep 2
|
||||||
if systemctl is-active --quiet zabbix-agent2; then
|
if systemctl is-active --quiet "${service_name}"; then
|
||||||
log "Zabbix Agent 2 is running."
|
log "${service_name} is running."
|
||||||
systemctl status zabbix-agent2 --no-pager
|
systemctl status "${service_name}" --no-pager
|
||||||
else
|
else
|
||||||
log "WARNING: Agent may not have started. Check logs:"
|
log "WARNING: Agent may not have started. Check logs:"
|
||||||
log " journalctl -u zabbix-agent2 -n 20"
|
log " journalctl -u ${service_name} -n 20"
|
||||||
|
if [ "${USING_AGENT_V1}" = true ]; then
|
||||||
|
log " cat /var/log/zabbix/zabbix_agentd.log"
|
||||||
|
else
|
||||||
log " cat /var/log/zabbix/zabbix_agent2.log"
|
log " cat /var/log/zabbix/zabbix_agent2.log"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# --- Main ---
|
# --- Main ---
|
||||||
@@ -480,6 +637,11 @@ configure_agent "${PSK_KEY}"
|
|||||||
start_agent
|
start_agent
|
||||||
|
|
||||||
log "=== Deployment Complete ==="
|
log "=== Deployment Complete ==="
|
||||||
|
if [ "${USING_AGENT_V1}" = true ]; then
|
||||||
|
log "Agent Version: Zabbix Agent (v1) — agent2 not available for ${ARCH_LABEL}"
|
||||||
|
else
|
||||||
|
log "Agent Version: Zabbix Agent 2"
|
||||||
|
fi
|
||||||
log "PSK Identity: ${PSK_IDENTITY}"
|
log "PSK Identity: ${PSK_IDENTITY}"
|
||||||
log "PSK Key: ${PSK_KEY}"
|
log "PSK Key: ${PSK_KEY}"
|
||||||
log ""
|
log ""
|
||||||
|
|||||||
Reference in New Issue
Block a user