05-18-2013 12:29 PM
Hello Community,
Can someone please show me how to compile a EEM (Tcl) script that will be activated when a syslog event occurs. For example, I would like the script to be activated when the following syslog event occurs:
%OSPF-5-ADJCHG:
Also I would like a similar script to be activated when the following syslog event occurs:
VDC_MGR-2-VDC_BAD: vdc_mgr
VDC_MGR-2-VDC_UNGRACEFUL: vdc_mgr:
Cheers
Solved! Go to Solution.
05-19-2013 05:19 AM
Is there anybody else that can help with this issue in the meantime?
Cheers
05-19-2013 05:41 AM
OK,
So I have attempted to register this simple policy and I couldn't get it to work either:
::cisco::eem::event_register_syslog pattern {test2}
#
# This EEM tcl policy was generated by the EEM applet conversion
# utility at http://www.marcuscom.com/convert_applet/
# using the following applet:
#
# event manager applet test2
# event syslog pattern "test2"
# action 1.0 cli command "enable"
# action 1.1 syslog msg "test"
#
namespace import ::cisco::eem::*
namespace import ::cisco::lib::*
array set arr_einfo [event_reqinfo]
if [catch {cli_open} result] {
error $result $errorInfo
} else {
array set cli1 $result
}
if [catch {cli_exec $cli1(fd) "enable"} _cli_result] {
error $_cli_result $errorInfo
}
action_syslog msg "test"
# Close open cli before exit.
catch {cli_close $cli1(fd) $cli1(tty_id)} result
Any help would be greatly appreciated....
Cheers
05-19-2013 06:11 AM
05-19-2013 06:12 AM
05-19-2013 07:52 AM
05-19-2013 07:49 AM
There's nothing wrong with this script. What error did you get registering it? How are you storing it and transferring it? If you put it into Word or some other rich test editor, it might be modifying or inserting characters that change it from being ASCII text on the device.
05-19-2013 07:57 AM
Hi Joseph,
The error message I'm getting when registering it is:
R1(config)#event manager pol foobar.tcl
Compile check and registration failed:policy file does not start with event register cmd
Tcl policy execute failed: policy file does not start with event register cmd
Embedded Event Manager configuration: failed to retrieve intermediate registration result for policy foobar.tcl: Unknown error 0
05-19-2013 07:59 AM
I'm transferring the script via tftp
05-19-2013 08:08 AM
Sorry, I didn't notice your ascii version.
Going to try that now...
Cheers
05-19-2013 08:14 AM
Brilliant! Your ASCII file worked.
So, how do I ensure that I'm creating an ascii file? I'm using Notepad. Is there a certain way of saving the file in ascii mode?
Cheers
05-19-2013 08:27 AM
Joseph,
You're a star!
Cheers mate.
05-19-2013 08:28 AM
I think I added five stars, but I'm not sure
05-19-2013 08:34 AM
Joseph,
I have you're still here.
Can you show me how add more patterns? For example, the following only looks for the pattern %OSPF.
::cisco::eem::event_register_syslog pattern {%OSPF}
#
# This EEM tcl policy was generated by the EEM applet conversion
# utility at http://www.marcuscom.com/convert_applet/
# using the following applet:
#
# event manager applet ospf
# event none
# event syslog pattern "%OSPF"
# action 1.0 syslog msg "testlog_osfp"
#
namespace import ::cisco::eem::*
namespace import ::cisco::lib::*
array set arr_einfo [event_reqinfo]
action_syslog msg "testlog_osfp"
Cheers
05-19-2013 08:37 AM
You can separate pattern strings with a | such as {OSPF|EIGRP|RIP}
05-19-2013 09:03 AM
Fantastic
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