cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
4587
Views
0
Helpful
5
Replies

EEM TCL Script IOS XR

Hello,

I´m with TCL and EEM on a ASR9K a newbie. I have a script running already on IOS.

event manager applet forbidden-commands-bgp trap

event cli pattern "(.*)(no router)(.*)" sync no skip yes occurs 1

action 2.1 syslog msg "$_cli_msg not executed"

 

I want that this IOS script will run under IOS XR, but I have huge problems.

 

These commands I´ve configured on the ASR9K router:

- disk0a:/usr/eem_scripts

- aaa authorization eventmanager default local

- vty-pool eem 100 105 line-template eem-template-1

 

- line template eem-template-1

   transport input telnet ssh

   transport output telnet ssh

 

I think these command are fine.

 

Can anybody translate the IOS commands into TCL script languages? And If you are working with event manager variables, how will you configure these values?

 

Thx in advance

 

Lorenz

5 Replies 5

Joe Clarke
Cisco Employee
Cisco Employee

You can use the converter tool at http://www.marcuscom.com/convert_applet to convert an EEM applet to a corresponding Tcl policy.  The resulting policy should work on XR.

Hello Joe,

thank you very much for your input. Okay sorry for that, I have to talk more in detail what I have done. I searched lot in the Internet and found a lot of what can I do. I found your link and I past the IOS applet into and get the TCL Script back. But it is not working with IOS XR.

This is the output from your link:

::cisco::eem::event_register_cli pattern {(.*)(no router)(.*)} sync no skip yes occurs 1

namespace import ::cisco::eem::*
namespace import ::cisco::lib::*
array set arr_einfo [event_reqinfo]
action_syslog msg "$arr_einfo(msg) not executed"

I´ve enabled the "debug event manager all"

RP/0/RSP0/CPU0:dor1101eiuc202(config)#event manager policy eem-basic.tcl user eemuser ty user                                                            

RP/0/RSP0/CPU0:dor1101eiuc202(config)#commit
Mon Nov 23 11:34:14.272 CET
RP/0/RSP0/CPU0:Nov 23 11:34:14.310 : eem_policy_dir[200]: fh_verify_policy: policyname = eem-basic.tcl, fc=0x422fce0
RP/0/RSP0/CPU0:Nov 23 11:34:14.310 : eem_policy_dir[200]: fh_verify_policy: fh_policyname=eem-basic.tcl, username=eemuser, persist_time=3600,type=1
RP/0/RSP0/CPU0:Nov 23 11:34:14.310 : eem_policy_dir[200]: fh_create_vec_member: Total vector entries, total:18, valid: 16
RP/0/RSP0/CPU0:Nov 23 11:34:14.314 : eem_policy_dir[200]: New vector member added for policy eem-basic.tcl, user eemuser
RP/0/RSP0/CPU0:Nov 23 11:34:14.314 : eem_policy_dir[200]: EEM Inside fh_set_policy()
RP/0/RSP0/CPU0:Nov 23 11:34:14.314 : eem_policy_dir[200]: fh_reg_unreg_policy: policyname = eem-basic.tcl
RP/0/RSP0/CPU0:Nov 23 11:34:14.314 : eem_policy_dir[200]: checksum type = FH_POLICY_CHECKSUM_UNKNOWN
RP/0/RSP0/CPU0:Nov 23 11:34:14.314 : eem_policy_dir[200]: found user policy absolute path /disk0a:/usr/eem_scripts/eem-basic.tcl
RP/0/RSP0/CPU0:Nov 23 11:34:14.314 : eem_policy_dir[200]: found type = 1
RP/0/RSP0/CPU0:Nov 23 11:34:14.314 : eem_policy_dir[200]: fh_reg_policy_core: register eem eem-basic.tcl policy /disk0a:/usr/eem_scripts/eem-basic.tcl type:1
RP/0/RSP0/CPU0:Nov 23 11:34:14.314 : eem_policy_dir[200]: check 1: not duplicate registration
RP/0/RSP0/CPU0:Nov 23 11:34:14.314 : eem_policy_dir[200]: No valid digital signature found or Tcl digital signatures are not supported in this image, registering as a user script.
RP/0/RSP0/CPU0:Nov 23 11:34:14.314 : eem_policy_dir[200]: spawn script /disk0a:/usr/eem_scripts/eem-basic.tcl
RP/0/RSP0/CPU0:Nov 23 11:34:14.314 : eem_policy_dir[200]: spawn program /pkg/bin/tclsh
RP/0/RSP0/CPU0:Nov 23 11:34:14.314 : eem_policy_dir[200]: arg[0] = /pkg/bin/tclsh
RP/0/RSP0/CPU0:Nov 23 11:34:14.314 : eem_policy_dir[200]: arg[2] = 0
RP/0/RSP0/CPU0:Nov 23 11:34:14.314 : eem_policy_dir[200]: arg[1] = -FMPRE
RP/0/RSP0/CPU0:Nov 23 11:34:14.314 : eem_policy_dir[200]: arg[3] = /disk0a:/usr/eem_scripts/eem-basic.tcl
RP/0/RSP0/CPU0:Nov 23 11:34:14.314 : eem_policy_dir[200]: no env specified
RP/0/RSP0/CPU0:Nov 23 11:34:14.315 : eem_policy_dir[200]: spawn on priority 10
RP/0/RSP0/CPU0:Nov 23 11:34:14.315 : eem_policy_dir[200]: progname /pkg/bin/tclsh vname N/A
RP/0/RSP0/CPU0:Nov 23 11:34:14.317 : eem_policy_dir[200]: waiting for tclsh W_READ
RP/0/RSP0/CPU0:Nov 23 11:34:15.388 : eem_server[201]: received FH_MSG_API_INIT; jobid=65881, processid=1089016153, threadid=0, client=69, job name=pkg/bin/tclsh
RP/0/RSP0/CPU0:Nov 23 11:34:15.388 : eem_server[201]: fms_chkpt_tbl_add: add chkpt obj 0x80002b98 from table 0x80001c90successful
RP/0/RSP0/CPU0:Nov 23 11:34:15.389 : eem_server[201]: received msg FH_MSG_EVENT_REGISTER_CHKPT from client 69 (process:pkg/bin/tclsh) (pid/eph 1089016153/65620)
RP/0/RSP0/CPU0:Nov 23 11:34:15.389 : eem_server[201]: received msg FH_MSG_APPL_PUBLISH_CHKPT from client 69 (process:pkg/bin/tclsh) (pid/eph 1089016153/65620)
RP/0/RSP0/CPU0:Nov 23 11:34:15.393 : eem_server[201]: received msg FH_MSG_EVENT_PARSE_BUFFER from client 69 (process:pkg/bin/tclsh) (pid/eph 1089016153/65620)
RP/0/RSP0/CPU0:Nov 23 11:34:15.393 : eem_server[201]: EEM: Server PARSE_BUFFER: extracted event_name=cli
RP/0/RSP0/CPU0:Nov 23 11:34:15.393 : eem_server[201]: EEM: Server PARSE_BUFFER: found ED cli on node0_RSP0_CPU0
RP/0/RSP0/CPU0:Nov 23 11:34:15.393 : eem_server[201]: EEM server sends FH_MSG_EVENT_PARSE_BUFFER message to FD:cli xos_ipc_sync_send to fdc->eph = 65540)
RP/0/RSP0/CPU0:Nov 23 11:34:15.393 : eem_ed_cli[186]: received msg : 130-FH_MSG_EVENT_PARSE_BUFFER ipc handle:65536
RP/0/RSP0/CPU0:Nov 23 11:34:15.393 : eem_server[201]: EEM server sends FH_MSG_EVENT_PARSE_BUFFER message to FD:cli event passed to fdc->eph = 65540 status 0
RP/0/RSP0/CPU0:Nov 23 11:34:15.394 : eem_server[201]: received msg FH_MSG_API_CLOSE from client 69 (process:pkg/bin/tclsh) (pid/eph 1089016153/65620)
RP/0/RSP0/CPU0:Nov 23 11:34:15.394 : eem_server[201]: received FH_MSG_API_CLOSE client=69 pid:1089016153 eph:65620
RP/0/RSP0/CPU0:Nov 23 11:34:15.394 : eem_server[201]: pid:1089016153 free_client:pkg/bin/tclsh eph:65620
RP/0/RSP0/CPU0:Nov 23 11:34:15.394 : eem_server[201]: fms_chkpt_tbl_remove: delete chkpt obj 0x80002b98 from table 0x80001c90successful
RP/0/RSP0/CPU0:Nov 23 11:34:15.395 : eem_server[201]: received XOS_IPC_CLIENT_DISCONNECTED, eph=65620 FO_READ
RP/0/RSP0/CPU0:Nov 23 11:34:16.404 : eem_policy_dir[200]: fhtcl_get_event_spec: reg file path = /tmp/eem-basic.tcl.reg

% Failed to commit one or more configuration items during a pseudo-atomic opeRP/0/RSP0/CPU0:Nov 23 11:34:16.404 : eem_policy_dir[200]: fhtcl_get_event_spec: Unable to open file /tmp/eem-basic.tcl.reg: No such file or directory
ration. All changes made have been reverted. Please issue 'show configuration failed' from this session to view the errors
RP/0/RSP0/CPU0:dor1101eiuc202(config)#
RP/0/RSP0/CPU0:dor1101eiuc202(config)#RP/0/RSP0/CPU0:Nov 23 11:34:16.404 : eem_policy_dir[200]: No valid digital signature found or Tcl digital signatures are not supported in this image, registering as a user script.
RP/0/RSP0/CPU0:Nov 23 11:34:16.404 : eem_policy_dir[200]: fh_reg_policy_core failed: failed to retrieve intermediate registration result for policy eem-basic.tcl
RP/0/RSP0/CPU0:Nov 23 11:34:16.405 : eem_policy_dir[200]: %HA-HA_EM-4-FMPD_POLICY_APPLY : Could not apply policy 'eem-basic.tcl': 'Embedded Event Manager' detected the 'fatal' condition 'Embedded Event Manager configuration'

I´m not sure but I think that is my problem:

RP/0/RSP0/CPU0:Nov 23 11:34:14.314 : eem_policy_dir[200]: no env specified

I tried different commands but nothing fix that problem. An Cisco engineer told me that the command "sync xxx skip xxx" is on IOS XR not supported or not implemented.

Correct.  The CLI ED does not accept the sync and skip arguments on XR.  Try removing them and make sure your event manager directory user policy is configured correctly.

I removed the sync and skip command. The TCL file is registered without any errors. Here are the output.

RP/0/RSP0/CPU0:dor1101eiuc202#sh event manager pol registered
Tue Nov 24 08:14:58.205 CET
No.  Class     Type    Event Type          Trap  Time Registered           Name
1    script    user    cli                 Off   Tue Nov 24 08:07:25 2015  eem-basic.tcl
 pattern {(no router)(.*)} occurs 1
 nice 0 queue-priority normal maxrun 20.000 scheduler rp_primary Secu none
 persist_time: 3600 seconds,  username: eemuser

 

Here are the debug output:

RP/0/RSP0/CPU0:Nov 24 08:09:38.564 : eem_ed_cli[186]: fh_process_sync:FH_MSG_EEM_ED_CLI_GET received
RP/0/RSP0/CPU0:Nov 24 08:09:38.565 : eem_ed_cli[186]: fh_fd_cli_history_chkpt_tbl_remove: objid deleted=420e23c
RP/0/RSP0/CPU0:Nov 24 08:09:38.565 : eem_ed_cli[186]: cli_history_entry_add: free_hist_list size=0, hist_list size=7
RP/0/RSP0/CPU0:Nov 24 08:09:38.565 : eem_ed_cli[186]: history_chkpt_tbl_add: objid added=420e23c
RP/0/RSP0/CPU0:Nov 24 08:09:38.565 : eem_ed_cli[186]: clicmd_occur_entry_create: me = 0x100f49c4
RP/0/RSP0/CPU0:Nov 24 08:09:38.565 : eem_ed_cli[186]: cli_pubinfo_enqueue: publish_entry EOK
RP/0/RSP0/CPU0:Nov 24 08:09:38.565 : eem_ed_cli[186]: fh_fd_cli_event_match: re=0x1002e03c, ptp=0x0, str=no router ospf 1
RP/0/RSP0/CPU0:Nov 24 08:09:38.565 : eem_ed_cli[186]: check_eem_cli_policy_handler: command_string=no router ospf 1
RP/0/RSP0/CPU0:Nov 24 08:09:38.565 : eem_ed_cli[186]: check_eem_cli_policy_handler: num_matches = 1, response_code = 2
RP/0/RSP0/CPU0:Nov 24 08:09:38.565 : eem_ed_cli[186]: received msg : 64-FH_MSG_SERVER_POLL ipc handle:65536
RP/0/RSP0/CPU0:Nov 24 08:09:38.565 : eem_ed_cli[186]: fh_fd_process_server_msg ED REPLY : 14-FH_MSG_EVENT_PUBLISH
RP/0/RSP0/CPU0:dor1101eiuc202(config)#commit
RP/0/RSP0/CPU0:Nov 24 08:10:47.426 : eem_ed_cli[186]: fh_process_sync:FH_MSG_EEM_ED_CLI_GET received
RP/0/RSP0/CPU0:Nov 24 08:10:47.426 : eem_ed_cli[186]: fh_fd_cli_history_chkpt_tbl_remove: objid deleted=420e248
RP/0/RSP0/CPU0:Nov 24 08:10:47.426 : eem_ed_cli[186]: cli_history_entry_add: free_hist_list size=0, hist_list size=7
RP/0/RSP0/CPU0:Nov 24 08:10:47.426 : eem_ed_cli[186]: history_chkpt_tbl_add: objid added=420e248
RP/0/RSP0/CPU0:Nov 24 08:10:47.426 : eem_ed_cli[186]: check_eem_cli_policy_handler: command_string=commit
RP/0/RSP0/CPU0:Nov 24 08:10:47.426 : eem_ed_cli[186]: check_eem_cli_policy_handler: num_matches = 0, response_code = 1
Tue Nov 24 08:10:48.837 CET

You can see a match with the eem script, but

1.) I don´t become a syslog message and

2.) The command is not forbidden. I can do the commit command and the routing protocol is deleted. What I don´t want.

Have you an example where I can forbid a special command (no router ospf for example), so that I can´t commit it?

Thx in advance

Lorenz

Two things.  One, the script needs to execute successfully to skip the command.  This is not happening.  The reason for that is likely that the "msg" element isn't defined in by the ED.  Print array keys arr_einfo to see what is defined.  My guess is "line":

puts [array keys arr_einfo]

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: