Skip to content

fix(driver): run netmiko off the event loop and use send_command_timing - #375

Open
WilhelmZA wants to merge 2 commits into
thatmattlove:mainfrom
WilhelmZA:pr/netmiko-timing
Open

fix(driver): run netmiko off the event loop and use send_command_timing#375
WilhelmZA wants to merge 2 commits into
thatmattlove:mainfrom
WilhelmZA:pr/netmiko-timing

Conversation

@WilhelmZA

@WilhelmZA WilhelmZA commented Jun 14, 2026

Copy link
Copy Markdown

Summary

Fixes the netmiko SSH driver so blocking I/O no longer runs on the asyncio event loop, and switches to send_command_timing for more reliable output collection on devices with unpredictable prompts/pacing.

Changes

  • Run the synchronous netmiko calls in a worker thread instead of blocking the event loop.
  • Use send_command_timing to avoid prompt-detection failures and premature truncation.

hyperglass/execution/drivers/ssh_netmiko.py — +26/−11.

Notes

Standalone bug fix; independent of the structured-output PR series.

…mpty reads

MikroTik can take a couple seconds to start emitting output for larger queries
(the command executes before any bytes return). netmiko send_command_timing's
default last_read (2.0s) elapses during that initial silence and returns an
empty string, so hyperglass parses 0 routes even though the device would return
a full table. It is latency-sensitive: it shows up for devices tens of ms away
(e.g. a Cape Town router queried from a Johannesburg node) while nearby devices
squeak through, and the empty-table retry cannot help since every attempt hits
the same window.

Set last_read=5.0 for mikrotik_routeros/switchos so the read waits for output
to begin. Empirically last_read>=4.0 reliably returns the full output where 2.0
returns empty; trade-off is ~5s added per MikroTik query (last_read is also the
trailing quiet-wait).

send_command (prompt-based) was tried and rejected: RouterOS prompt detection
truncates output through the driver, which is why send_command_timing is used.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant