cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2476
Views
0
Helpful
6
Replies

EEM - problem with generate outputs with determined line numbers

Hi

Could you help me with this problem

- Data

> IOS 12.4(15)T13

- EEM config

CONFIG-SET

+---------------------------------------------------------------------------------------

event manager applet TEST trap

event syslog pattern "%SYS-5-CONFIG_I:"

action 1.0 cli command "enable"

action 1.1 cli command "terminal length 20"

action 2.0 cli command "sh running-config linenum"

action 3.0 mail server "192.168.1.101" to "engineer@cisco.com" from "devtest@cisco.com" subject "B25 PBX Alert" body "$_cli_result"

+---------------------------------------------------------------------------------------

- Debug output

OUTPUT-SET

+---------------------------------------------------------------------------------------

R1#conf t

Enter configuration commands, one per line.  End with CNTL/Z.

R1(config)#^Z

*Mar  1 02:28:07.983: cli_history_entry_add: free_hist_list size=0, hist_list size=7

*Mar  1 02:28:07.987: check_eem_cli_policy_handler: command_string=configure terminal

*Mar  1 02:28:07.987: check_eem_cli_policy_handler: num_matches = 0, response_code = 1

*Mar  1 02:28:08.523: %SYS-5-CONFIG_I: Configured from console by console

*Mar  1 02:28:08.527: fh_fd_syslog_event_match: num_matches = 1

*Mar  1 02:28:08.531: fh_fd_data_syslog: num_matches = 1

*Mar  1 02:28:08.531: fh_send_server_sig_hndlr: received a pulse from Syslog Event Detector on node0/0 with fdid: 2

*Mar  1 02:28:08.535: fh_send_syslog_fd_msg: msg_type=62

*Mar  1 02:28:08.535: fh_send_syslog_fd_msg: sval=0

*Mar  1 02:28:08.535: fh_send_server_sig_hndlr: received FH_MSG_EVENT_PUBLISH

*Mar  1 02:28:08.539: fh_schedule_callback: fh_schedule_callback: cc=67390D40 prev_epc=0; epc=66779170

*Mar  1 02:28:08.555: fh_schedule_callback: EEM callback policy TEST has been scheduled to run

*Mar  1 02:28:08.563: fh_io_msg: received FH_MSG_API_INIT; jobid=37, processid=192, client=27, job name=EEM Callback Thread

*Mar  1 02:28:08.571: fh_server: fh_io_msg: received msg FH_MSG_EVENT_REQINFO from client 27 pclient 1

*Mar  1 02:28:08.603: %HA_EM-6-LOG: TEST : DEBUG(cli_lib) : : CTL : cli_open called.

*Mar  1 02:28:08.651: %HA_EM-6-LOG: TEST : DEBUG(cli_lib) : : OUT : R1>

*Mar  1 02:28:08.655: %HA_EM-6-LOG: TEST : DEBUG(cli_lib) : : IN  : R1>enable

*Mar  1 02:28:08.675: cli_history_entry_add: free_hist_list size=0, hist_list size=7

*Mar  1 02:28:08.675: eem_no_scan flag set, skipping scan of command_string=check_eem_cli_policy_handler

*Mar  1 02:28:08.743: %HA_EM-6-LOG: TEST : DEBUG(cli_lib) : : OUT : R1#

*Mar  1 02:28:08.751: %HA_EM-6-LOG: TEST : DEBUG(cli_lib) : : IN  : R1#terminal length 20

*Mar  1 02:28:08.787: cli_history_entry_add: free_hist_list size=0, hist_list size=7

*Mar  1 02:28:08.791: eem_no_scan flag set, skipping scan of command_string=check_eem_cli_policy_handler

*Mar  1 02:28:08.839: %HA_EM-6-LOG: TEST : DEBUG(cli_lib) : : OUT : R1#

*Mar  1 02:28:08.847: %HA_EM-6-LOG: TEST : DEBUG(cli_lib) : : IN  : R1#sh running-config linenum

*Mar  1 02:28:08.907: cli_history_entry_add: free_hist_list size=0, hist_list size=7

*Mar  1 02:28:08.907: eem_no_scan flag set, skipping scan of command_string=check_eem_cli_policy_handler

*Mar  1 02:28:28.631: %HA_EM-6-LOG: TEST : DEBUG(cli_lib) : : CTL : cli_close called.

*Mar  1 02:28:28.647: fh_server: fh_io_msg: received msg FH_MSG_CALLBACK_DONE from client 27 pclient 1

*Mar  1 02:28:28.651: fh_io_msg: EEM callback policy TEST has ended with abnormal exit status of 0xFFFFFFFF

*Mar  1 02:28:28.651: EEM policy TEST has exceeded it's elapsed time limit of 20.0 seconds

*Mar  1 02:28:28.655: fh_schedule_callback: fh_schedule_callback: cc=67390D40 prev_epc=66779170; epc=0

*Mar  1 02:28:28.655: fh_schedule_policy: prev_epc=0x00000000; epc=0x00000000

*Mar  1 02:28:28.667: fh_server: fh_io_msg: received msg FH_MSG_API_CLOSE from client 27 pclient 1

*Mar  1 02:28:28.667: fh_io_msg: received FH_MSG_API_CLOSE client=27

+---------------------------------------------------------------------------------------

- Problem

> I need 20 lines output on my email?

   But router don't send email when I add below

   "action 1.1 cli command "terminal length 20"

   without this command send all output.

- Question

> How to determine line numbers sent to email address?

6 Replies 6

Joe Clarke
Cisco Employee
Cisco Employee

You cannot rely on "terminal length" within EEM policies.  Setting a terminal length will break prompt matching.  You could do:

action 1.1 cli command "terminal length 20" pattern "--More--"

action 1.2 cli command "q"

But the better thing to do would be to use Tcl to limit the output.  You can convert this applet to a Tcl policy at http://www.marcuscom.com/convert_applet/ then tweak it to send only the number of lines you want.  For example:

set email_out [join [lrange [split $_cli_output "\n"] 0 19] "\n"]

# Send the $email_out string in email

Hi

Thank you for answer.

- But I have some restrictions

> Use EEM

> Don't use pipe

> Don't use pattern

> Don't have "if" option

The Tcl example above is EEM, so I do not understand that "restriction."  Your code does support the "pattern" option.  It was introduced in EEM 2.3, which you are running.  You can either do that or convert the applet policy to a Tcl policy as I mentioned above.  The Tcl policy will give you much more control.

Hi Joseph

My IOS code support"pattern" option but restrictions are obligatory :-( and they didn't depend from me. And I need find another solution for my problem, but now all what I tested - failed.

There is no other solution to your problem.  You either need to use "pattern", convert to Tcl, or post-process the email to eliminate the unneeded lines.

Ok I understand.

Thank you Joseph for your support.

Review Cisco Networking for a $25 gift card