cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2369
Views
0
Helpful
11
Replies

generate custom snmp trap and match it

Mahmoud
Level 1
Level 1

Dears,

I am new in EEM scripting so appreciate your help

I have a business need that require to shut down interface based on other interface in other routes

for example I we have R1 and R2 , if the interface fa 0/0 in R1 goes down generate a snmp trap from R1 directed to R2 and therefore R2 will un shutdown its loopback interface Lo0 accordingly.

I made this sample script at R1 to send snmp trap one fa 0/0 goes down

event manager applet fa0/0down
 event syslog pattern "Interface FastEthernet0/0, changed state to down"
 action 1.0 snmp-trap strdata "SNMP_HI_THERE_FA0/0_IS_DOWN"

and tried to match this trap in R2 by event manger with action to unshut the loop0 with no luck

11 Replies 11

Joe Clarke
Cisco Employee
Cisco Employee

How is R2 configured with respect to SNMP and EEM?

hello Joe,

I made R2 act as snmp manager to recieve R1 traps but I cant match this custom trap from R1

You need to post your SNMP and EEM config for me to be able to help you.

Hello Joe,

R2

snmp-server group cisco v3 auth match exact
snmp-server group cisco v3 priv match exact read testview write testview
snmp-server view testview iso included
snmp-server manager session-timeout 1000
snmp-server manager

event manager applet unshut

event snmp
 action 1.0 cli command "enable"
 action 2.0 cli command "conf t"
 action 3.0 cli command "int loo 0"
 action 4.0 cli command "no shut"

I can see snmp traps received at R2 from R1 but how I can match "SNMP_HI_THERE_FA0/0_IS_DOWN"in the R2 eem

This won't work.  Look at the attached steps and make sure both devices are configured correctly.

thanks Joe it is working fine but can we send words like I used above instead of numbers in your example

It's much easier and more reliable to match on numbers.  Why do you want to match on text?

no specific words , may be interface X is down

-If I use action 1.0 snmp-trap strdata can we match it in the other side with the same way like your example

There's no advantage gained from that approach.  Just choose numbers to stand for those events.  For example, interface X being down is 1001 whereas interface Y being down is 1002.  This will be easier to match and more reliable.

One would still be able to determine the purpose of the applet from the actions within it. 

thanks joe for your great support , I appreciate that

can I match other traps from cisco routers (snmp manger) that generated from 3rd party devices (snmp clients) with the same way.

Yes, this same technique works with all kinds of traps including those from third-party devices.

Review Cisco Networking for a $25 gift card