cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1763
Views
0
Helpful
2
Replies

Python scripts running slowly on Nexus 7000

yazdani.behnam
Level 1
Level 1

I have a problem with running python scripts on my Nexus 7000 switches.

Due to a SNMP counter bug on my switches, I can't get accurate interface counters via SNMP.

As a workaround I'm running a python script on Nexus 7000s where it reads interfaces counters and write them into a file, monitoring software then fetches the output to create graphs.

 

Now the problem is there is a performance issue where each  time I run the python script it take about 15 minutes to finish. It takes too long for the python interpreter to run show commands, read and process the output and write them to the output file.

I've attached my script and sample output file.

 

Has anyone had similar issue with running python scripts on Nexus 7000 switches?

 

2 Replies 2

On Cisco Nexus 7000 Series devices, Python is integrated with the underlying Cisco NX-OS network interfaces. You can switch from one virtual routing context to another by setting up a context through the set_vrf() API. The following example shows how to retrieve an HTML document over the management interface of a device. You can also establish a connection to an external entity over the inband interface by switching to a desired virtual routing context. SWITCH# >>> import urllib2 SWITCH# >>> set_vrf('management') SWITCH# >>> page=urllib2.urlopen('http://172.23.40.211:8000/welcome.html') SWITCH# >>> print page.read() Hello Cisco Nexus 7000 >>> SWITCH# >>> import cisco SWITCH# >>> help(cisco.set_vrf) Help on built-in function set_vrf in module cisco: set_vrf(...) specify the vrf name for socket operations SWITCH# >>> Cisco NX-OS Security with Python Cisco NX-OS resources are protected by the Cisco NX-OS Sandbox layer of software and by the CLI role-based access control (RBAC). All users associated with a Cisco NX-OS network-admin or dev-ops role are privileged users. Users who are granted access to Python with a custom role are regarded as non-privileged users. Non-privileged users have a limited access to Cisco NX-OS resources, such as file system, guest shell, and Bash commands. Privileged users have greater access to all the resources of Cisco NX-OS. Examples of Security and User Authority Example of Running Script with Scheduler For more details refer the link:- https://www.cisco.com/c/en/us/td/docs/switches/datacenter/nexus7000/sw/programmability/guide/b_Cisco_Nexus_7000_Series_NX-OS_Programmability_Guide/b_Cisco_Nexus_7000_Series_NX-OS_Programmability_Guide_chapter_0100.html#concept_E7510931AF6F4412B55E605...

Thanks

but the problem is my script works but its actually really slow as it goes through each iteration in script?