Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements

Welcome to Cisco Support Community. We would love to have your feedback.

For an introduction to the new site, click here. If you'd prefer to explore, try our test area to get started. And see here for current known issues.

New Member

EEM on N3K with regexp / foreach like function

Hi

I noticed that ISR-G2 with IOS can support the subjected function. Actually, I build a function on ISR-G2 with EEM Applet to monitor local interface status. If syslog returns interface down then it will telnet to other device to no shut interface as network resiliency

event manager applet TSET

event syslog pattern "Line protocol on Interface.*changed state to down"

action 1.0 regexp "Interface ([^,]+), changed state to down" "$_syslog_msg" match intf state

action 2.0 syslog msg "$intf is down"

action 3.0 cli command "enable"

action 3.1 cli command "config t"

action 3.2 cli command "interface $intf"

action 3.3 cli command "shut"

action 4.1 cli command "telnet 2.2.2.2" pattern ">"

action 4.2 cli command "enable" pattern "Password:"

action 4.3 cli command "cisco" pattern "#"

action 4.4 cli command "config t" pattern "#"

action 4.5 cli command "inter $intf" pattern "#"

action 4.6 cli command "no shu" pattern "#"

action 4.7 cli command "end" pattern "#"

But when I move to N3K, it seems N3K doesn't provide "regexp", instead it provides "Python" engine. Can someone give me hints to perform such function call on N3K by translating my code on EEM Applet to EEM Python or VSH on NXOS?

Tks

Leon

1 REPLY
Cisco Employee

EEM on N3K with regexp / foreach like function

There is no comparable EEM capability on the N3K for what you have here.  While it is possible to call a Python or Tcl script from an EEM applet on the N3K, such an action has not been tested and thus is not officially supported.  Additionally, I believe you will have to use a socket API in Tcl or Python to do what you want.  Wrapping the telnet command is probably not going to work as you don't have the same CLI library capabilities that you do in IOS.

I don't have any familiarity with sockte programming Python, but perhaps others can offer some guidance there.  In terms of resources, there are plenty of Python courses and documentation out there.  My favorite is

http://www.codecademy.com/tracks/python .

545
Views
0
Helpful
1
Replies