Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements

Welcome to Cisco Support Community. We would love to have your feedback.

For an introduction to the new site, click here. And see here for current known issues.

New Member

EEM : traceroute output to a file

Hi,

I am working on an applet which would get triggered if there is a state change on an object.

One of the requirements is to collect the traceroute output.

I am able to append the output of most of the commands to a text file but not the output of traceroute. I tried the following method however that doesn't help either:

action 8.0 cli command "more $_cli_result | append log-failure.txt"

How can I write the output of ping and traceroute to a file?

Thanks,

Nishant Hura

Device :

Cisco IOS Software, C3900 Software (C3900-UNIVERSALK9-M), Version 15.1(4)M6, RELEASE SOFTWARE (fc2)

Technical Support: http://www.cisco.com/techsupport

Copyright (c) 1986-2013 by Cisco Systems, Inc.

Compiled Thu 14-Feb-13 07:40 by prod_rel_team

ROM: System Bootstrap, Version 15.0(1r)M16, RELEASE SOFTWARE (fc1)

mla1-rpi-wan-1 uptime is 35 weeks, 6 days, 5 minutes

System returned to ROM by reload at 08:26:29 CST Fri Jun 21 2013

System restarted at 08:33:38 CST Fri Jun 21 2013

System image file is "flash0:c3900-universalk9-mz.SPA.151-4.M6.bin"

Last reload type: Normal Reload

Last reload reason: Reload Command

This product contains cryptographic features and is subject to United

States and local country laws governing import, export, transfer and

use. Delivery of Cisco cryptographic products does not imply

third-party authority to import, export, distribute or use encryption.

Importers, exporters, distributors and users are responsible for

compliance with U.S. and local country laws. By using this product you

agree to comply with applicable laws and regulations. If you are unable

to comply with U.S. and local laws, return this product immediately.

A summary of U.S. laws governing Cisco cryptographic products may be found at:

http://www.cisco.com/wwl/export/crypto/tool/stqrg.html

If you require further assistance please contact us by sending email to

export@cisco.com.

Cisco CISCO3945-CHASSIS (revision 1.0) with C3900-SPE150/K9 with 2029568K/67584K bytes of memory.

Processor board ID FCZ16337QPJ

3 Gigabit Ethernet interfaces

62 Serial interfaces

1 terminal line

4 Channelized E1/PRI ports

DRAM configuration is 72 bits wide with parity enabled.

255K bytes of non-volatile configuration memory.

4013856K bytes of ATA System CompactFlash 0 (Read/Write)

License Info:

License UDI:

-------------------------------------------------

Device#   PID                   SN

-------------------------------------------------

*0        C3900-SPE150/K9       FOC16461CXM

Technology Package License Information for Module:'c3900'

-----------------------------------------------------------------

Technology    Technology-package           Technology-package

              Current       Type           Next reboot

------------------------------------------------------------------

ipbase        ipbasek9      Permanent      ipbasek9

security      None          None           None

uc            uck9          Permanent      uck9

data          None          None           None

Configuration register is 0x2102

Everyone's tags (3)
8 REPLIES
Cisco Employee

EEM : traceroute output to a file

You can take your applet to http://www.marcuscom.com/convert_applet/ to convert it to Tcl.  Then, you can add this code to output the traceroute:

set fd [open "flash:log-failure.txt" "a"]

puts $fd $_cli_result

close $fd

New Member

Thanks for the reply Joseph.I

Thanks for the reply Joseph.

I tried the TCL conversion tool for the following script.

# event manager applet log-failure
#  event track 13 state any
#  action 1.0 cli command "enable"
#  action 7.0 cli command "trace 4.2.2.2 source lo 0"

 

 

It got converted into

 

::cisco::eem::event_register_track 13 state any

#
# 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 log-failure
#  event track 13 state any
#  action 1.0 cli command "enable"
#  action 7.0 cli command "trace 4.2.2.2 source lo 0"
#

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
}

if [catch {cli_exec $cli1(fd) "trace 4.2.2.2 source lo 0"} _cli_result] {
    error $_cli_result $errorInfo
}

#Added the following script as suggested by yourself.

set fd [open "flash:log-failure.txt" "a"]

puts $fd $_cli_result

close $fds


# Close open cli before exit.
catch {cli_close $cli1(fd) $cli1(tty_id)} result

 

 

Following is the error i get

 

mla1-rpi-wan-1#tclsh flash:test.tcl
invalid command name "::cisco::eem::event_register_track"
    while executing
"::cisco::eem::event_register_track 13 state any"
    (file "flash:test.tcl" line 1)

 

 

Cisco Employee

This is an EEM Tcl script not

This is an EEM Tcl script not a tclsh script.  You need to register it by following the instructions at http://www.cisco.com/c/en/us/td/docs/ios/netmgmt/configuration/guide/12_2sx/nm_12_2sx_book/nm_eem_policy_tcl.html .

New Member

Hello Joseph,I need your

Hello Joseph,

I need your expert advice on this. I have EEM that pings several sites...

I went further by instructing the EEM to send the ping output to my mail.

Now the problem is that output of all before that last are omitted in the mail.

How can I have everything( all pings to sites) sent in one mail.

 

Thanks to treat...

 

New Member

Hello,

Hello,

I have a requirement to capture the Traceroute command output through EEM Script.

---------------------------------------------------------------------------------------------

Applet needs to be converted in to TCL script & add the below code:

set fd [open "flash:log-failure.txt" "a"]

puts $fd $_cli_result

close $fd

----------------------------------------------------------------------------------------------

It would be really great, if you share the remaining steps for achieving this task.

Best Regards,

Manjesh Michael

Cisco Employee

Take the code you have pasted

Take the code you have pasted here and paste it to the bottom of the Tcl script you get back from my conversion tool.  Then follow the link I included above for how you can register the resulting EEM Tcl policy.

New Member

Thanks Joe for the quick

Thanks Joe for the quick response. I referred the URL, however it seems a bit difficult. Could you please assist with the steps, if its readily available ?

Cisco Employee

Create flash:/eem

Create flash:/eem

Configure:

event manager directory user policy flash:/eem

Copy your Tcl policy into that directory.

Configure:

event manager policy mypol.tcl

Where mypol.tcl is the name of the Tcl policy file.

1407
Views
0
Helpful
8
Replies
CreatePlease login to create content