In this lesson, we will cover:

  • Review of single-threaded Netmiko execution.
  • How to write a multiple threaded Netmiko script.
  • Time testing and comparing single-threaded vs multi-threaded Netmiko execution.

The scripts and code for this lesson can be found within the Netmiko repo under the directory: examples/multithreading.

Introduction

So far through this guide, we have run Netmiko against a single device. However, what about if we want to start running Netmiko across multiple devices? This section will look at how we can use multithreading to scale Netmiko to run across multiple devices.

Single-Threaded

Let's create a script to run a command against multiple devices. To do so, we use many of the commands and Netmiko methods that we have previously learnt, along with:

  • defining a list() of ports and device_types.
  • adding a timer to time how long the script takes using the time module.
  • iterating over our device list(), performing the send_command on each iteration, collects the output of show version.
Members Only Content
Join today and get access to:
  • Full deep-dive course library (inc. Batfish, pyATS, Netmiko)
  • Code repositories inc. full course code, scripts and examples
  • 24x7 Multi-vendor labs (Arista, Cisco, Juniper)
  • Private online community
  • Monthly online meetups

100% Satisfaction Guaranteed!
Cancel your membership at any time.


Join Today
Close You've successfully subscribed to Packet Coders.
Close Success! Your account is fully activated, you now have access to all content.
Close Welcome back! You've successfully signed in.
Close Nearly there! To activate your account, please click the link in the email we just sent you.