HOW TO USE "SIMPLE" PYTHON SCRIPT to RUN "PING" command on "MULTIPLE " ROUTERS | SWITCHES (Part-2)

Опубликовано: 29 Март 2026
на канале: Network Tips and Topics - Plexinor
62
0

"Want more expert insights and updates? Follow us on LinkedIn and explore our company page to connect with us directly. Don’t miss out - click the link and join the conversation!"

Follow us on LinkedIn   / plexinor  
Company Website Https://www.plexinor.com

HOW TO USE "SIMPLE" PYTHON SCRIPT to RUN "PING" command on "MULTIPLE " ROUTERS | SWITCHES

full script is below

lab@admin:~$ cat PING-from-MULTIPLE_ROUTERS
from napalm import get_network_driver
from pprint import pprint
from datetime import datetime
from getpass import getpass
import json
username = input('Enter your SSH username: ')
password=getpass()

devices_ip = [ "192.168.0.85",
"192.168.0.122",
]
for ip in devices_ip:
print ("Connecting to Device =======================================" + str(ip))
junos_driver = get_network_driver("junos")
mx_router = junos_driver(hostname=ip,
username=username,
password=password)
mx_router.open()
if mx_router.is_alive()["is_alive"]:
output = mx_router.ping("194.145.149.88")
print (json.dumps(output,indent=4))