monitor.factory¶
Shared monitor-collector factory.
Used by both otto monitor (live dashboard) and otto test --monitor
(session-scoped collection during a test run). Centralising this here keeps
both call sites consistent — same parser-registry lookup, same per-host log
silencing, same target construction.
-
otto.monitor.factory.build_monitor_collector(hosts: Sequence[RemoteHost], db: MetricDB | None =
None, tunnel_source: Callable[[], Awaitable[list[TunnelRecord]]] | None =None) MetricCollector¶ Build a
MetricCollectorover hosts.Creates one
MonitorTargetper host, silences host logging (collection is chatty), and chooses each host’s collection mode:a host with an
snmpblock is polled over SNMP — itsSnmpOptionsbecomes a liveSnmpClient(address defaulting to the host’s ownip) plus the OID list to GET;otherwise it is polled by running shell commands, with its parser set resolved via
get_host_parsers()so per-host customisations registered by init modules are honoured.
- Parameters:¶
hosts – Hosts to sample on each tick.
db – Optional session-bound
MetricDBfor persistence (unopened);Nonemeans in-memory. The frame (session identity) is the caller’s job — this factory stays session-blind, same as the collector it builds.tunnel_source – Optional full-lab tunnel discovery callable for the collector’s tunnel loop (spec 2026-07-16). The CLI composes this over the WHOLE lab — tunnels may traverse hosts that metric collection was never pointed at.