cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1944
Views
5
Helpful
8
Replies

eem in n9k

nvanhaute
Level 1
Level 1

hi,

I'm trying to build an eem script on my n9k to be warn when bgp state changes but it doesn't work because of syntax and I'm a bit lost so if anyone could help that would be great :

event manager applet BGP
event syslog pattern ".*%BGP-5-ADJCHANGE:.*"
action 1.0 cli command "enable"
action 2.0 cli command "sh run | i 'snmp-server location'"
action 2.1 cli command "sh hostname"
action 2.2 cli command "sh ip bgp nei | in 'BGP nei|BGP state|route-map'"
action 3.0 mail server "xxx.xxx.xxx.xxx" from "xxx@xxxx" to "xxxx@xxxxx" subject "Change BGP DC" body "$_cli_result"

First I tried to mix all commands in one with ";" but syntax is not ok so I did it line per line
Then the mail action, when I enter this line, it tells me wrong syntax at "BGP", so I removed spaces now error on body.

Any idea ?

Thanks

1 Accepted Solution

Accepted Solutions

thanks for your reply but that's the same

I fixed my issue in launching a python file from eem and it works great

View solution in original post

8 Replies 8

Nik1709
Level 1
Level 1

Hi @nvanhaute

I am not quite sure if that could be the problem since I was not able to test it myself yet but look at the command reference for the "action mail" command: 

action labe mail server server-address to to-address from from-address [cc cc-addresssubject subject body body-text...

So i think it might be possible that the problem is a wrong order since the "to"-value has to come first. But i am not sure how restrictive EEM is with that. 
Maybe it is worth a try.

Best regards
Niklas

thanks for your reply but I tried and it's not better :

action 3.0 mail server "xxxxxx" to "xxxxxx" from "yyyyyyy" subject "Changes_BGP_DC" body "$_cli_result"

% Invalid command at '^' marker.
the "^" is placed under subject.. no idea why

NIco

Hi @nvanhaute

Can you try to just enclose subject and body in double-quotation marks. 
(So dont enclose the mailserver,to and from values into quotation marks)

Best regards
Niklas

not better

nvanhaute
Level 1
Level 1

maybe I need to use python to send email and just call it from eem...

Hello,

EEM support on the Nexus 9K is limited. The below script works on 'normal' IOS systems, see if you can get it to work. Make sure the syslog pattern match is exactly as in the example below:

event manager environment _email_to your-to-mail@domain.com
event manager environment _email_server your.mail.server
event manager environment _email_from your-from-mail@domain.com
!
event manager applet BGP
event syslog pattern "BGP-5-ADJCHANGE:.*"
action 1.0 cli command "enable"
action 2.0 cli command "sh run | i 'snmp-server location'"
action 2.1 cli command "sh hostname"
action 2.2 cli command "sh ip bgp nei | in 'BGP nei|BGP state|route-map'"
action 3.0 mail server "$_email_server" to "$_email_to" from "$_email_from" subject "$_event_pub_time: BGP Adjacency Change" body "$_syslog_msg"

thanks for your reply but that's the same

I fixed my issue in launching a python file from eem and it works great

Hello,

good stuff. That is typically how EEM works on the Nexus...with python.

Review Cisco Networking for a $25 gift card