feat(zabbix): a native Zabbix agent through ZabbixAgentMixin (NetOrk/netork#2571)
driver / lint (pull_request) Successful in 14s
driver / standard (pull_request) Successful in 17s
driver / types (pull_request) Successful in 59s
driver / test (3.13) (pull_request) Successful in 57s
driver / test (3.12) (pull_request) Successful in 1m2s
driver / lowest (pull_request) Successful in 40s
driver / build (pull_request) Successful in 37s
driver / security (pull_request) Successful in 1m17s
CI / driver (pull_request) Successful in 2m32s
driver / publish (pull_request) Skipped

configure_zabbix_agent(settings) installs zabbix-agent from the host's packages,
and where they have none, from Zabbix's repository for the server's release
line. It writes the caller's values into /etc/zabbix/zabbix_agentd.conf (the old
file stays as .bak) and opens tcp/ListenPort for the allowed sources in
firewalld, ufw or iptables.

The firewall step of the SNMP agent is the shared _allow_sources(allowed, port,
proto) now, in _open_port.py; the rules it writes for udp/161 are the same.
Needs napalm-device-types 4.40.0.
This commit is contained in:
Christian Manivong committed 2026-11-17 04:58:46 +01:00
1 parent 0e1c4e7927
commit 2521f9f462
8 files changed
+360 -25

No files matched your search

+7 -2
View File
@@ -38,7 +38,12 @@ _FIREWALLD_ZONES = (
def firewalld_allow_snmp(sources: list[str]) -> str:
"""The shell that opens udp/161 for *sources* (already normalised) in firewalld.
"""The shell that opens udp/161 for *sources* (already normalised) in firewalld."""
return firewalld_allow_port(sources, 161, "udp")
def firewalld_allow_port(sources: list[str], port: int, proto: str) -> str:
"""The shell that opens *proto*/*port* for *sources* (already normalised) in firewalld.
A rich rule per source in every zone of ``_FIREWALLD_ZONES``, at runtime and
permanently, each only when the zone lacks it -- no ``--reload``, which would drop
@@ -49,7 +54,7 @@ def firewalld_allow_snmp(sources: list[str]) -> str:
family = f"ipv{ipaddress.ip_network(source).version}"
rule = _shlex_quote(
f'rule family="{family}" source address="{source}"'
' port port="161" protocol="udp" accept'
f' port port="{port}" protocol="{proto}" accept'
)
for scope in ("", "--permanent "):
zone = f'firewall-cmd {scope}--zone="$z"'