cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
766
Views
5
Helpful
1
Replies

Advice on how to create a SLA/track function with scripting

Difan_Zhao
Level 1
Level 1

Hi experts,

I have this Nexus 5596 chassis that doesn't support SLA configuration. I want to create a static route only if TCP on port 80 is open for another IP. I got the similar thing working on a Nexus 9K with a TCP-type SLA and a track and EEM that monitors the syslog and add/remove the route.

What option do I have on the 5596? I see that it supports Python. Is it the best option I have? If so, which library or module can do the work for me? I found people using "socket" but I got error with the interactive console

 

#  python
Copyright (c) 2001-2012 Python Software Foundation; All Rights Reserved

>>> import socket
>>> sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
Permission denied for the role
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/isan/python/scripts/socket.py", line 187, in __init__
    _sock = _realsocket(family, type, proto)
SystemError: NULL result without error in PyObject_Call

 

Is there a way to fix the permission issue, or is there a more proper Cisco way to do this? I am hoping that it will check and generate a Syslog message. Then my EEM script can capture it and do the rest. Of course, if easy enough, I can also try to do everything with Python. Let me know your advice. Thanks!

 

 

1 Reply 1

qsnyder
Cisco Employee
Cisco Employee

So -- this is a very non-trivial problem to solve.
I assume that you're using Python on a 3rd party box (i.e. not directly on the Nexus)?  If so -- it may be possible to leverage Python to check the status of the open port on the target host -- and then perform an "if, then" matching statement that will then leverage the JSON-RPC API within the N5K to install the static route.  You'd obviously need to perform the reverse logic to pull the route out if needed.

In this case -- you could use the socket module on a recently modern version of Python on the 3rd party machine using something similar to this article

https://stackoverflow.com/questions/19196105/how-to-check-if-a-network-port-is-open

Hope this helps.
q.