Traffic

async OPNsenseClient.get_interface_traffic()

Return a normalized diagnostics traffic snapshot.

Returns:

Normalized diagnostics traffic sample. Returns an

empty traffic sample when the endpoint fetch or response parsing fails. With throw_errors enabled, a failure is raised as an OPNsenseError subclass instead.

Return type:

dict[str, Any]

async OPNsenseClient.stream_interface_traffic(poll_interval=1)

Yield normalized diagnostics traffic stream samples.

Parameters:

poll_interval (int) – Requested stream interval in seconds. Values below 1 are clamped to 1, and the clamped value selects the stream endpoint.

Yields:

dict[str, Any] –

Normalized traffic samples after the initial valid timing

event is discarded because it cannot represent an interval delta. Later samples use elapsed time between strictly increasing server timestamps; after a timing reset, the next valid sample uses the selected stream interval. The stream ends empty when checking the stream endpoint fails; with throw_errors enabled, that failure is raised as an OPNsenseError subclass instead.

Return type:

AsyncIterator[dict[str, Any]]