cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2762
Views
0
Helpful
31
Replies

Custom Tcl Script for an Event Help

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

31 Replies 31

Is there anybody else that can help with this issue in the meantime?

Cheers

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

Strange thing is I can't get the above Tcl to register, however I can get the attached policy to register ... weird

I'm trying to get the attached policy to register as well.

As I suspected.  You appear to be using some rich text editor to store your file.  The quotes in the first line have changed to fancy quotes, and thus this is no longer an ASCII text file.  Here is the ASCII version.

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.

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

I'm transferring the script via tftp

Sorry, I didn't notice your ascii version.

Going to try that now...

Cheers

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

Joseph,

You're a star!

Cheers mate.

I think I added five stars, but I'm not sure

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

You can separate pattern strings with a | such as {OSPF|EIGRP|RIP}

Fantastic

Review Cisco Networking for a $25 gift card