feat(zabbix): an agent that only connects out listens on no port (NetOrk/netork#2683) #128

Closed
christianmanivong wants to merge 0 commits from fix/zabbix-agent-target-2682-2683-2684 into main
pull from: fix/zabbix-agent-target-2682-2683-2684
Owner

An agent whose site only lets it connect out (NetOrk/netork#2683) had nowhere to say so: zabbix_agent_config always wrote Server and left StartAgents at the agent's default, and the firewall step opened listen_port to allowed_sources. netOrk's native install and container replace therefore set up a passive listener on sites marked active-only.

What changes

  • ZabbixAgentSettingsDict.active_only (optional, default False).
  • zabbix_agent_config writes StartAgents=0 for it and comments Server out. Zabbix's agent documentation says Server is mandatory only while StartAgents is not 0, and that StartAgents=0 disables passive checks so the agent listens on no TCP port. This matches the agent image's ZBX_PASSIVE_ALLOW=false.
  • check_zabbix_agent_settings: for active_only, server_active is required and server may be empty. Addresses that are given are still checked. active_only must be a bool.
  • configure_zabbix_agent's firewall step opens nothing for active_only and does not call the driver's _allow_zabbix_agent_sources. The step list stays the same, so callers' step names keep working.
  • An agent that is not active only gets a StartAgents=0 line commented out, because otherwise an agent that was active only before would never listen again. Any other count stays as it is.

All three drivers that implement ZabbixAgentMixin at their current netOrk pins (napalm-linux, napalm-openwrt, napalm-proxmox) write their configuration through zabbix_agent_config and are reached only through the template's firewall step, so none of them needs a change.

Tests

tests/test_zabbix_agent.py: a new TestActiveOnly class (config lines, idempotence, switching back to passive, a listener count of its own, settings checks), plus TestZabbixAgentMixin::test_an_active_only_agent_opens_no_port. pytest tests/test_zabbix_agent.py tests/test_fix_templates.py passes (139 tests). ruff and mypy are clean.

CHANGELOG has an entry under Unreleased and README.md is updated. There is no version bump.

NetOrk/netork#2683

An agent whose site only lets it connect out (NetOrk/netork#2683) had nowhere to say so: `zabbix_agent_config` always wrote `Server` and left `StartAgents` at the agent's default, and the firewall step opened `listen_port` to `allowed_sources`. netOrk's native install and container replace therefore set up a passive listener on sites marked active-only. ## What changes - `ZabbixAgentSettingsDict.active_only` (optional, default False). - `zabbix_agent_config` writes `StartAgents=0` for it and comments `Server` out. Zabbix's agent documentation says `Server` is mandatory only while `StartAgents` is not 0, and that `StartAgents=0` disables passive checks so the agent listens on no TCP port. This matches the agent image's `ZBX_PASSIVE_ALLOW=false`. - `check_zabbix_agent_settings`: for `active_only`, `server_active` is required and `server` may be empty. Addresses that are given are still checked. `active_only` must be a bool. - `configure_zabbix_agent`'s firewall step opens nothing for `active_only` and does not call the driver's `_allow_zabbix_agent_sources`. The step list stays the same, so callers' step names keep working. - An agent that is not active only gets a `StartAgents=0` line commented out, because otherwise an agent that was active only before would never listen again. Any other count stays as it is. All three drivers that implement `ZabbixAgentMixin` at their current netOrk pins (napalm-linux, napalm-openwrt, napalm-proxmox) write their configuration through `zabbix_agent_config` and are reached only through the template's firewall step, so none of them needs a change. ## Tests `tests/test_zabbix_agent.py`: a new `TestActiveOnly` class (config lines, idempotence, switching back to passive, a listener count of its own, settings checks), plus `TestZabbixAgentMixin::test_an_active_only_agent_opens_no_port`. `pytest tests/test_zabbix_agent.py tests/test_fix_templates.py` passes (139 tests). ruff and mypy are clean. CHANGELOG has an entry under Unreleased and README.md is updated. There is no version bump. NetOrk/netork#2683
christianmanivong added 1 commit 2026-11-25 20:37:23 +00:00
feat(zabbix): an agent that only connects out listens on no port (NetOrk/netork#2683)
driver / standard (pull_request) Successful in 17s
driver / lint (pull_request) Successful in 15s
driver / types (pull_request) Successful in 1m7s
driver / test (3.12) (pull_request) Successful in 1m21s
driver / test (3.13) (pull_request) Successful in 1m13s
driver / lowest (pull_request) Successful in 37s
driver / build (pull_request) Successful in 28s
driver / security (pull_request) Successful in 55s
CI / driver (pull_request) Successful in 55s
driver / publish (pull_request) Skipped
b1ea364674
ZabbixAgentSettingsDict.active_only: zabbix_agent_config writes
StartAgents=0 and comments Server out (mandatory only while StartAgents
is not 0); ServerActive is required instead. configure_zabbix_agent's
firewall step opens nothing for it. An agent that is not active only gets
a StartAgents=0 line commented out.
Author
Owner

Merged as part of the release PR #130 (4.42.0, merge commit fb927e7, tag v4.42.0).

Merged as part of the release PR #130 (4.42.0, merge commit fb927e7, tag v4.42.0).

Pull request closed

This pull request cannot be reopened because the branch was deleted.
Sign in to join this conversation.