diff --git a/README.md b/README.md index 55bd4a0..3ee8f84 100644 --- a/README.md +++ b/README.md @@ -35,11 +35,27 @@ The installer adds the official Zabbix apt repository, so minor/patch updates ** ```bash sudo apt-get update sudo apt-get install --only-upgrade 'zabbix-proxy*' 'zabbix-sql-scripts' -sudo systemctl restart zabbix-proxy-sqlite3 # or zabbix-proxy-mysql / -pgsql to match your DB +sudo systemctl restart zabbix-proxy ``` To move to a **new major version** (e.g. 7.0 → 7.4), the repository definition itself must change. Re-run the installer and enter the new version when prompted — it adds the new repo and upgrades in place. +> The systemd unit is **`zabbix-proxy`** whichever database backend you chose — all three packages (`zabbix-proxy-sqlite3`, `-mysql`, `-pgsql`) ship the same `zabbix-proxy.service`. There is no `zabbix-proxy-sqlite3.service`. + +##### ICMP checks need fping + +The proxy uses `fping` for all `icmpping*` items, and Zabbix looks for it at `/usr/sbin/fping` by default — but Debian and Ubuntu install it to `/usr/bin/fping`. The installer now adds the package and writes the detected path into the config. + +Proxies built before that change have neither, so **every ping check behind them fails silently** while the log fills with `At least one of '/usr/sbin/fping', '/usr/sbin/fping6' must exist`. To check and fix an existing proxy: + +```bash +command -v fping; grep -E '^Fping' /etc/zabbix/zabbix_proxy.conf # both empty = affected + +sudo apt-get install -y fping +printf '\nFpingLocation=/usr/bin/fping\nFping6Location=/usr/bin/fping6\n' | sudo tee -a /etc/zabbix/zabbix_proxy.conf +sudo systemctl restart zabbix-proxy +``` + ### Zabbix Agent Installs Zabbix Agent 2 on systems to be monitored. Configures it to connect to a local proxy. diff --git a/install-zabbix-proxy-full.sh b/install-zabbix-proxy-full.sh index db0c34f..3602534 100644 --- a/install-zabbix-proxy-full.sh +++ b/install-zabbix-proxy-full.sh @@ -300,7 +300,10 @@ log_ok "Repository added" # --- Install packages -------------------------------------------------------- print_section "Installing Packages" -PACKAGES=("$PROXY_PACKAGE" "zabbix-sql-scripts") +# fping is required for ICMP checks (icmpping / icmppingsec / icmppingloss). +# Without it every ping item on every host behind this proxy fails as +# "unsupported", and the proxy logs the missing-binary error once a second. +PACKAGES=("$PROXY_PACKAGE" "zabbix-sql-scripts" "fping") [[ "$DB_TYPE" == "MySQL" ]] && PACKAGES+=("default-mysql-client") [[ "$DB_TYPE" == "PostgreSQL" ]] && PACKAGES+=("postgresql-client") @@ -308,6 +311,22 @@ log_info "Installing: ${PACKAGES[*]}" DEBIAN_FRONTEND=noninteractive apt-get install -y -q "${PACKAGES[@]}" log_ok "Packages installed" +# Locate fping rather than assuming a path: Debian/Ubuntu ship it in /usr/bin, +# while Zabbix defaults to /usr/sbin/fping. Guessing wrong is exactly what makes +# ICMP checks fail silently. +FPING_BIN=$(command -v fping 2>/dev/null || true) +FPING6_BIN=$(command -v fping6 2>/dev/null || true) +FPING_BLOCK="" +if [[ -n "$FPING_BIN" ]]; then + FPING_BLOCK="FpingLocation=${FPING_BIN}" + log_ok "fping found at $FPING_BIN" +else + log_warn "fping not found — ICMP (ping) checks will not work on this proxy" +fi +if [[ -n "$FPING6_BIN" ]]; then + FPING_BLOCK="${FPING_BLOCK}${FPING_BLOCK:+$'\n'}Fping6Location=${FPING6_BIN}" +fi + # --- Database setup ---------------------------------------------------------- if [[ "$DB_SETUP_NEEDED" == "true" ]]; then print_section "Database Setup" @@ -451,6 +470,8 @@ ProxyBufferMode=hybrid ProxyMemoryBufferSize=64M Timeout=10 + +${FPING_BLOCK} EOF chown root:zabbix "$PROXY_CONF" @@ -459,6 +480,15 @@ log_ok "Configuration written to $PROXY_CONF" # --- Enable and start -------------------------------------------------------- print_section "Starting Service" + +# Validate before starting so a config error reports the proxy's own message +# rather than a bare systemd exit code. +log_info "Validating configuration..." +if ! CONFIG_TEST=$(zabbix_proxy -T -c "$PROXY_CONF" 2>&1); then + echo "$CONFIG_TEST" | sed 's/^/ /' + die "Configuration test failed — not starting the proxy" +fi +log_ok "Configuration valid" systemctl daemon-reload systemctl enable zabbix-proxy --quiet systemctl restart zabbix-proxy diff --git a/install-zabbix-proxy.sh b/install-zabbix-proxy.sh index da195b6..2b0fde4 100644 --- a/install-zabbix-proxy.sh +++ b/install-zabbix-proxy.sh @@ -245,9 +245,28 @@ log_ok "Repository added" # --- Install packages -------------------------------------------------------- print_section "Installing Packages" -log_info "Installing $PROXY_PACKAGE..." -DEBIAN_FRONTEND=noninteractive apt-get install -y -q "$PROXY_PACKAGE" -log_ok "Package installed" +# fping is required for ICMP checks (icmpping / icmppingsec / icmppingloss). +# Without it every ping item on every host behind this proxy fails as +# "unsupported", and the proxy logs the missing-binary error once a second. +log_info "Installing $PROXY_PACKAGE and fping..." +DEBIAN_FRONTEND=noninteractive apt-get install -y -q "$PROXY_PACKAGE" fping +log_ok "Packages installed" + +# Locate fping rather than assuming a path: Debian/Ubuntu ship it in /usr/bin, +# while Zabbix defaults to /usr/sbin/fping. Guessing wrong is exactly what makes +# ICMP checks fail silently. +FPING_BIN=$(command -v fping 2>/dev/null || true) +FPING6_BIN=$(command -v fping6 2>/dev/null || true) +FPING_BLOCK="" +if [[ -n "$FPING_BIN" ]]; then + FPING_BLOCK="FpingLocation=${FPING_BIN}" + log_ok "fping found at $FPING_BIN" +else + log_warn "fping not found — ICMP (ping) checks will not work on this proxy" +fi +if [[ -n "$FPING6_BIN" ]]; then + FPING_BLOCK="${FPING_BLOCK}${FPING_BLOCK:+$'\n'}Fping6Location=${FPING6_BIN}" +fi # --- Prepare SQLite directory ------------------------------------------------ print_section "Preparing Database" @@ -327,6 +346,8 @@ ProxyBufferMode=hybrid ProxyMemoryBufferSize=64M Timeout=10 + +${FPING_BLOCK} EOF chown root:zabbix "$PROXY_CONF" @@ -335,6 +356,16 @@ log_ok "Configuration written to $PROXY_CONF" # --- Enable and start -------------------------------------------------------- print_section "Starting Service" + +# Validate before starting so a config error reports the proxy's own message +# rather than a bare systemd exit code. +log_info "Validating configuration..." +if ! CONFIG_TEST=$(zabbix_proxy -T -c "$PROXY_CONF" 2>&1); then + echo "$CONFIG_TEST" | sed 's/^/ /' + die "Configuration test failed — not starting the proxy" +fi +log_ok "Configuration valid" + systemctl daemon-reload systemctl enable zabbix-proxy --quiet systemctl restart zabbix-proxy