10-22-2012 09:46 AM
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.
10-23-2012 02:54 PM
//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.:)
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide