feat: set up SNMP with net-snmp
CI / test (3.10) (pull_request) Successful in 30s
CI / test (3.11) (pull_request) Successful in 32s
CI / test (3.12) (pull_request) Successful in 36s
CI / test (3.10) (push) Successful in 45s
CI / test (3.11) (push) Successful in 30s
CI / test (3.12) (push) Successful in 29s

run_device_action("fix_snmp") and get_snmp_config for both drivers, as
decided in NetOrk/netork#800: net-snmp from packages rather than the base
daemons, because it answers UCD-SNMP-MIB, which netOrk's health metrics
read.

- fix_snmp installs net-snmp, writes the configuration netOrk uses on
  Linux (v2c, community "public", agentAddress udp:161) through stdin as
  root, enables and restarts the agent (FreeBSD `service snmpd`, OpenBSD
  `rcctl ... netsnmpd`, as `snmpd` is OpenBSD's own daemon) and asks it
  for sysDescr. It stops at the first step that fails and says why.
- get_snmp_config reports a running net-snmp's community and port.
- FreeBSD's install_package bootstraps pkg on a classic system that never
  had it instead of waiting for an answer that never comes.

Checked live: FreeBSD from a bare system, OpenBSD again over an existing
setup. Memory, swap and load answer on both; FreeBSD's ssCpuIdle about a
minute after start; OpenBSD's CPU figures from net-snmp are wrong (#800).
This commit is contained in:
2026-10-08 10:05:09 +02:00
parent 7bf028ef4d
commit aef58ca161
6 changed files with 190 additions and 4 deletions
+5 -1
View File
@@ -36,7 +36,8 @@ class FreeBSDDriver(BsdDriver):
return parse.sockstat(output)
PKG_QUERY = "pkg query '%n\t%v\t%R\t%sb\t%c'"
INSTALL_COMMAND = "pkg install -y {name}"
# Bootstraps pkg on a classic system that never had it, instead of asking.
INSTALL_COMMAND = "env ASSUME_ALWAYS_YES=yes pkg install -y {name}"
UNINSTALL_COMMAND = "pkg delete -y {name}"
# Root reads every daemon's pidfile; one-shot scripts have no status.
SERVICE_STATUS_COMMAND = (
@@ -44,6 +45,9 @@ class FreeBSDDriver(BsdDriver):
'printf "%s\\t%s\\n" "$n" "$(service $n status 2>&1 | head -1)"; done'
)
SERVICE_ACTION_COMMAND = "service {name} {action}"
SNMPD_CONF = "/usr/local/etc/snmp/snmpd.conf"
# The rc script drops to the snmpd user, so the file stays readable (644).
SNMPD_START = "sysrc snmpd_enable=YES && service snmpd restart"
def _parse_services(self, output: str) -> list[dict]:
return parse.service_status(output)