cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1666
Views
0
Helpful
1
Replies

Shut and send a trap

krim
Level 1
Level 1

Hello there ,

I have the following requirement . Will be great to know your thoughts .

I need to shut a port down , when a device connected to that port is removed and send an SNMP trap stating the so and so interface has been shut down.

The following is what I came up with

event manager applet SHUTNSEND

event none

event syslog occurs 1 pattern ".*UPDOWN:.*"             //this is where I am matching UPDOWN , that indicates a device disconnect

action 0 syslog msg "Syslog error: $_syslog_pattern"      // i publish a syslog pattern that has been collected using the above mentioned

action 1.0 cli command "enable"

action 2.0 regexp Interface\s([^\s\,]+) $_syslog_pattern inter       //copy the data from _syslog_pattern(ie. eg Interface e0/0) to variable "$inter"

action 3.0 cli command "config term"

action 4.0 cli command "$inter"  

action 5.0 cli command "shut"

action 6.0 cli command "end"

action 7.0 cli command "write mem"

action 8.0 label snmp-trap strdata "EEM shutdown $inter as the device connected to it was unplugged"    //send trap to snmp

The EEM version that my device(3825 isr)  runs is 3.0 .The problem is i get the error message that "

*Oct 22 15:51:55.042: %HA_EM-3-FMPD_UNKNOWN_ENV: fh_parse_var: could not find environment variable: _syslog_pattern "

I am wondering which variable will store the data collected by the "event syslog occurs 1 pattern ".*UPDOWN:.*"  " , if it is not present in

$_syslog_pattern

Please let me know your thoughts .

Thanks much

KRishna.

1 Reply 1

krim
Level 1
Level 1

//i used the incorrect variable should have been $_syslog_msg.

event manager applet SHUTNSEND

event none

event syslog occurs 1 pattern ".*UPDOWN:.*"           

//this is where I am matching UPDOWN , that indicates a device disconnect

action 0 regexp Interface\s([^\s\,]+) $_syslog_msg ignore inter    

//copy the data from _syslog_pattern(ie. eg Interface e0/0) to variable "$inter"

action 1 syslog msg "Status changed for $inter"     

// i publish a syslog pattern that has been collected using the above mentioned

action 2.0 cli command "enable"

action 3.0 cli command "config term"

action 4.0 cli command "$inter" 

action 5.0 cli command "shut"

action 6.0 cli command "end"

action 7.0 cli command "write mem"

action 8.0 label snmp-trap strdata "EEM shutdown $inter"

Yet to test . + my fingers.:)