QuestionQ61
VerifiedDevice-Level Network AutomationAn engineer needs to add basic reliability to a monitoring script that polls uptime from multiple Cisco IOS routers. Implement appropriate exception handling for timeouts and authentication failures while preserving successful output. Construct the artifact by dragging the code snippets into the code boxes. Not every option is needed, and options can be used more than once.
Drag & Drop
from netmiko import from netmiko.ssh_exception import , devices = [ {"device_type": "cisco_ios", "ip": "203.0.113.31", "username": "netops", "password": "C1sco12345"}, {"device_type": "cisco_ios", "ip": "203.0.113.32", "username": "netops", "password": "C1sco12345"} ] for dev in devices: try: with (**dev) as conn: uptime = conn.("show version | inc uptime") print(f"{dev['ip']}: {uptime.strip()}") except (, ) as err: print(f"{dev['ip']}: ERROR {err}")
Community Discussion