Skip to main content

Simplified Paramiko Library to Fetch Data From MultiVendor Network Devices

Project description

simplefetch

Simplified Paramiko Library to Fetch Data From MultiVendor Network Devices

Supports

  • Cisco IOS
  • Cisco IOS-XE
  • Cisco NX-OS
  • Cisco IOS-XR
  • Juniper Junos
  • Huawei VRP5/8
  • ZTE ZXROS
  • DELL OS10
  • Ericsson IPOS

Script is based on paramiko and catches device-prompt to understand the output is fetched, thus there is a strong possibility that script could work with many network devices from different vendors, i only do not have the chance to test.

Accepted Network Device OS Types

  • huawei-vrp
  • cisco-ios
  • cisco-iosxe
  • cisco-iosxr
  • cisco-nxos
  • junos
  • dell-os10
  • zte-zxros
  • ericsson-ipos
  • nokia-sros

For the above device type pagination commands (e.g. "terminal length 0") send automatically.

Simple Example

import simplefetch

test_router = simplefetch.SSH("192.168.1.1", port=22,user="admin", passwd="secret", network_os="cisco-ios")
print (test_router.fetchdata("show version"))
test_router.disconnect()

Example with Logging

import simplefetch,logging
logging.basicConfig(filename='info.log', filemode='a', level=logging.INFO,
                    format='%(asctime)s [%(name)s] %(levelname)s (%(threadName)-10s): %(message)s')

test_router = simplefetch.SSH("192.168.1.1" port=22, user="admin", passwd="secret", network_os="cisco-ios")
print (test_router.fetchdata("show version"))
test_router.disconnect() 

Example with Multithreading Python3

# -*- coding: utf-8 -*-
import simplefetch
import logging, time
from threading import Thread
timestr = time.strftime("%Y%m%d-%H%M%S")
log_filename="connection_logs"+str(timestr)+".txt"

#================== Logging
logging.basicConfig(filename=log_filename, filemode='a', level=logging.INFO,
                    format='%(asctime)s [%(name)s] %(levelname)s (%(threadName)-10s): %(message)s')

#==================USER, PASS, ROUTER_LIST==============
username= "username"
password="password"
router_list=["router_name1","192.168.1.1"]

#================== MEMORY check function for huawei devices
def get_memory_usages(router_name):
	try:
		connection = simplefetch.SSH(user=username, passwd=password, network_os="huawei-vrp")
		try:
			display_health_raw= connection.fetchdata("display startup")
			print (router_name)
			print (display_health_raw)
		except:
			logging.warning ("could not get output of command from %s",router_name)
			connection.disconnect()
	except:
		logging.warning ("connection unsuccessful to %s",router_name)

#================== multithread part 
import concurrent.futures 
with concurrent.futures.ThreadPoolExecutor(max_workers=10) as executor: 
	for items in router_list:
		executor.submit(get_memory_usages,items) 
executor.shutdown(wait=True)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

simplefetch-0.1.0.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

simplefetch-0.1.0-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file simplefetch-0.1.0.tar.gz.

File metadata

  • Download URL: simplefetch-0.1.0.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.22.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.3

File hashes

Hashes for simplefetch-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e2625e033f53c8373cd525551ce115cdb8855cfa759ec1b4f5e73f48c76dd6a1
MD5 a5e60ec917a0b87513ef098b21fc28bd
BLAKE2b-256 92d6036a5de8812867187888c808e5b630d70c61cccdd410c384b38304479246

See more details on using hashes here.

File details

Details for the file simplefetch-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: simplefetch-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.22.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.3

File hashes

Hashes for simplefetch-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 76985eb8c40ae297fa2271ee17cb1085e4fd79387272cc65cc54a7f2df1aacf8
MD5 c26498427ad1b8834ea2e2f4527ea8f6
BLAKE2b-256 724ec9dbdb540f1250b4e9d01742d05a6d773ba68d2bdf8750a31ab8f6eda88b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page